Repository navigation
feat(binding-http): support outbound credential injection on kind: client - #2135
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds outbound credential injection to
binding-http'skind: client, using the sameoptions.authorization/HttpCredentialsConfigshape already supported bykind: 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) andbinding-mqtt(MqttBindingConfig.asInjector), both of which reuse an identical schema forkind: serverandkind: clientand differ only in Java behavior (extract vs. inject).Changes:
http.schema.patch.json): removed theauthorization: falseoverride forkind: client, so it now shares#/$defs/options/binding/http/authorizationwithkind: server.HttpBindingConfig: resolves the configuredGuardHandlerand builds aninjecttemplate function +injectHeadername fromoptions.authorization.credentials.headers[0].HttpClientFactory: at request-begin time, callsguard.credentials(authorization)(falling back toguard.reauthorize(...)when unauthorized, mirroringbinding-mcp'sMcpClientFactory.proceedWithRequestprecedent), templates the resolved credential into the configured header, and merges it into the outbound request alongside the existingoptions.overridesmechanism.Wiring
OpenapiClientGenerator/AsyncapiClientGenerator/binding-openapi-asyncapito populateoptions.authorizationfrom an OpenAPI/AsyncAPIsecurityscheme (step 3 of the issue's proposed design) is left as follow-on work now that this capability exists inbinding-http.Fixes #2132
Test plan
v1.1/client.authorization.credentials.yaml,v2/client.authorization.credentials.yaml) +SchemaTestmethods, confirmed failing before the schema patch and passing afterinject.credentials.header(application + network.rptscripts) exercising atype: clientbinding wired to atype: testguardruntime/binding-httpAuthorizationIT(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:checkcleanGenerated by Claude Code