Skip to content

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

Closed

Description

@jfallows

Problem

options.authorization.credentials on binding-http lets a pattern like "Bearer {credentials}" be declared (headers/parameters/cookies, schema-enforced to contain {credentials} — see http.schema.patch.json). Today this is server-kind only: HttpBindingConfig.asAccessor() turns {credentials} into a regex capture group to extract a token from an inbound header/param/cookie and pass it to guard.reauthorize().

kind: client is explicitly blocked from ever setting options.authorization — the client-kind schema override sets "authorization": false (http.schema.patch.json, client kind block). Correspondingly, HttpClientFactory has no guard resolution or credential-injection logic anywhere; the only outbound header mechanism is the static overrides map (literal key→value, used e.g. for :authority).

This means an HTTP client binding has no way to authenticate its own outbound requests using a guard-resolved identity/credential — there's no way to say "resolve this guard, then set Authorization: Bearer {credentials} on the outbound request using the resolved value."

This surfaced while auditing binding-openapi's composite generator (OpenapiClientGenerator): an OpenAPI spec's security scheme is currently dropped entirely when generating the outbound http_client0 binding, because there is nothing in binding-http for the generator to wire it to.

Proposed design

Reuse the existing options.authorization / HttpCredentialsConfig config shape (same {credentials} template token, same schema constraint), but add the inverse operation for the client kind:

  1. Allow options.authorization on kind: client in the HTTP binding schema (currently hard-blocked).
  2. Add client-side credential templating to HttpClientFactory/HttpBindingConfig: given a guard-resolved identity/credential for the outbound stream, render credentials.headers[].pattern by substituting {credentials} with the resolved value, and apply it as an outbound header (likely alongside/via the existing overrides mechanism).
  3. Once available, wire OpenapiClientGenerator (and the equivalent HTTP-client paths in AsyncapiClientGenerator and binding-openapi-asyncapi) to populate options.authorization from the spec's security scheme plus a referenced guard.

Scope note

This is net-new capability in binding-http's client hot path (not a small wiring fix), so it's being tracked separately from the options.* abstraction-leak cleanup in #2113 / PR #2128, to allow it to proceed in parallel without blocking that PR.

Activity

  1. self-assigned this
    on Jul 11, 2026
  2. added a commit that references this issue on Jul 13, 2026
    a290256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions