Skip to content

feat(binding-http): support outbound credential injection on kind: client - #2135

Merged
jfallows merged 6 commits into
developfrom
claude/github-issue-2132-w48hqz
Jul 13, 2026
Merged

jfallows merged 6 commits into
developfrom
claude/github-issue-2132-w48hqz

Conversation

@jfallows

Copy link
Copy Markdown
Contributor

Description

Adds outbound credential injection to binding-http's kind: client, using the same options.authorization / HttpCredentialsConfig shape already supported by kind: server (which only extracts {credentials} from inbound requests). This lets a client binding resolve a guard-issued credential and inject it into an outbound request header (e.g. Authorization: Bearer {credentials}).

Design mirrors the existing precedent in binding-kafka (KafkaBindingConfig.resolveGuard) and binding-mqtt (MqttBindingConfig.asInjector), both of which reuse an identical schema for kind: server and kind: client and differ only in Java behavior (extract vs. inject).

Changes:

  • Schema (http.schema.patch.json): removed the authorization: false override for kind: client, so it now shares #/$defs/options/binding/http/authorization with kind: server.
  • HttpBindingConfig: resolves the configured GuardHandler and builds an inject template function + injectHeader name from options.authorization.credentials.headers[0].
  • HttpClientFactory: at request-begin time, calls guard.credentials(authorization) (falling back to guard.reauthorize(...) when unauthorized, mirroring binding-mcp's McpClientFactory.proceedWithRequest precedent), templates the resolved credential into the configured header, and merges it into the outbound request alongside the existing options.overrides mechanism.
  • Duplicate-header fix: outbound header merging (shared by the HTTP/1.1, h2c-upgrade, and HTTP/2 encode paths) is now case-insensitive, so a guard-injected or statically-overridden header always replaces any application-supplied header of the same name regardless of case, instead of both landing on the wire as separate headers.

Wiring OpenapiClientGenerator/AsyncapiClientGenerator/binding-openapi-asyncapi to populate options.authorization from an OpenAPI/AsyncAPI security scheme (step 3 of the issue's proposed design) is left as follow-on work now that this capability exists in binding-http.

Fixes #2132

Test plan

  • New JSON schema fixtures (v1.1/client.authorization.credentials.yaml, v2/client.authorization.credentials.yaml) + SchemaTest methods, confirmed failing before the schema patch and passing after
  • New K3PO scenario inject.credentials.header (application + network .rpt scripts) exercising a type: client binding wired to a type: test guard
  • New runtime/binding-http AuthorizationIT (client package), confirmed failing before the Java changes and passing after
  • ./mvnw verify -pl runtime/binding-http — all unit tests, all ITs, checkstyle, JaCoCo coverage pass
  • ./mvnw verify -pl specs/binding-http.spec — all schema/spec tests pass
  • ./mvnw checkstyle:check / ./mvnw license:check clean

Generated by Claude Code

claude added 6 commits July 11, 2026 08:26
…ient

Allow options.authorization on binding-http kind: client, mirroring the
existing kind: server extraction. HttpBindingConfig resolves the
configured guard and, at request-begin time, HttpClientFactory calls
guard.credentials(authorization) (falling back to reauthorize when
unauthorized) and templates the resolved value into
credentials.headers[].pattern, injecting it as an outbound header
alongside options.overrides.

Also make override header merging case-insensitive so a guard-injected
(or statically configured) header always replaces any application-
supplied header of the same name regardless of case, instead of
producing a duplicate header on the wire.

Closes #2132.
…tion

Fixes for PR #2135 code review:

- Gate guard.credentials(authorization) on MASK_AUTHORIZED before trusting
  its result, and deauthorize any session created via the null-credentials
  reauthorize fallback immediately after use, closing an unbounded
  per-request session leak and preventing a stale/static credential from
  being injected on an unauthenticated stream (guard-identity).
- Support the Basic "{username}:{password}" composite header pattern in
  asInjector (base64-encoding the resolved credential), mirroring the
  existing server-side asAccessor.
- Restrict kind: client authorization.credentials to headers only (single
  entry) in the JSON schema, turning the previous silent no-op for
  cookies/query into a validation error.
- Add the missing paired client.rpt/server.rpt scripts and spec-level
  self-consistency IT methods for the inject.credentials.header scenario,
  plus a new inject.credentials.header.basic scenario covering Basic auth
  end-to-end.
- Add a containsKey fast path to mergeOverrides, avoiding the
  case-insensitive scan and String allocation for the common case where a
  header is already present under its exact configured casing.
- Collapse the repeated options.authorization null-check in
  HttpBindingConfig's constructor into a single local variable.
- Reformat the client.authorization.credentials.yaml fixtures to 2-space
  indentation per the project's YAML style.
…y credentials symmetrically

resolveOverrides only relayed an already-authorized session's credential, but
retained a self-issuing reauthorize/deauthorize fallback with no live caller
and an unclear session lifetime; removed it entirely so the method just reads
guard.credentials(authorization) and merges overrides.

Extended credential injection to cookies and query parameters (via new
injectCookie/injectQuery in HttpBindingConfig), symmetric with the existing
header injection, appending to any existing Cookie header or query string
rather than overwriting. Reverted the client-kind schema restriction that
disallowed cookies/query, since both are now implemented, and added matching
K3PO scenarios (network + application) plus config fixtures and self-
consistency ITs.
@jfallows
jfallows merged commit a290256 into develop Jul 13, 2026
43 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

binding-http client kind: support outbound credential injection via options.authorization

2 participants