Repository navigation
Description
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:
- Allow
options.authorizationonkind: clientin the HTTP binding schema (currently hard-blocked). - Add client-side credential templating to
HttpClientFactory/HttpBindingConfig: given a guard-resolved identity/credential for the outbound stream, rendercredentials.headers[].patternby substituting{credentials}with the resolved value, and apply it as an outbound header (likely alongside/via the existingoverridesmechanism). - Once available, wire
OpenapiClientGenerator(and the equivalent HTTP-client paths inAsyncapiClientGeneratorandbinding-openapi-asyncapi) to populateoptions.authorizationfrom the spec'ssecurityscheme 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
feat(binding-http): support outbound credential injection on kind: cl…