Skip to content

Relay the caller's Authorization to the agent when fetching its card - #75

Merged
esnible merged 1 commit into
mainfrom
relay-card-authorization
Aug 20, 2026
Merged

Relay the caller's Authorization to the agent when fetching its card#75
esnible merged 1 commit into
mainfrom
relay-card-authorization

Conversation

@esnible

@esnible esnible commented Aug 20, 2026

Copy link
Copy Markdown
Member

The agent-card endpoint sent no Authorization header to the agent, so an agent hosted by authbridge exec could never have its card fetched — the inbound pipeline answered the unauthenticated request with 401 and WWW-Authenticate: Bearer. agents card and agents chat both failed, and --with-authorization did not help: that flag attaches the token to the A2A message, sent only after the card lookup that was failing.

Confirmed against a live agent by AuthBridge's own policy header:

before: X-Policy-Violation: auth.malformed_header   # no header arrived
after:  X-Policy-Violation: auth.token_expired      # relayed token arrived, parsed

The header is forwarded verbatim rather than read from the config file. This handler proxies one request and the caller has already chosen an identity; reading a token from disk would attach a credential to a request that deliberately carried none. The destination is the instance record's loopback inbound address, never request-controlled.

Also fixes the 401 hint, which named the one remedy that cannot work here — a relayed 401 now says the credentials were accepted and signing in will not help, pointing at the pipeline policy and token audience. An unrecognized body still gets the original hint.

Two smaller things: agents chat help claimed the card lookup always carries the context's token (untrue with --server), and the weather-service example comments out its spiffe/mtls blocks since mTLS needs the SPIFFE block and a local run has no workload API socket.

Assisted by Claude.

GET /chat/{ns}/{name}/agent-card sent no Authorization header to the agent, so
an agent hosted by `authbridge exec` could never have its card fetched: the
inbound pipeline answered the unauthenticated request with 401 and
WWW-Authenticate: Bearer. `agents card` and `agents chat` both failed, and
--with-authorization did not help — that flag attaches the token to the A2A
message, which is sent after the card lookup that was failing.

Confirmed against a live agent by the pipeline's own policy header: the
violation was auth.malformed_header before, meaning no header arrived, and
auth.token_expired after, meaning the relayed token arrived and was parsed. A
stub agent driven through the real command logs the full bearer token.

The header is forwarded verbatim rather than read from the config file. This
handler proxies one request and the caller has already chosen which identity to
present; reading a token from disk would attach a credential to a request that
deliberately carried none, and would make the response depend on state the
caller cannot see. The destination is the instance record's loopback inbound
address, never anything the request controls, which is what makes relaying a
bearer token acceptable here.

The 401 hint was also wrong for this case, naming the one remedy that cannot
work. A 401 the server relayed from an agent now says the credentials were
accepted and that signing in will not help, pointing at the pipeline policy and
the token's audience instead. An unrecognized body still gets the original
sign-in hint, so nothing regresses.

`agents chat` help claimed the card lookup always carries the context's token;
it does not when --server is given.

The weather-service example comments out its spiffe and mtls blocks, since mTLS
requires the SPIFFE block and a local run has no workload API socket.

Assisted by Claude.

Signed-off-by: Ed Snible <snible@us.ibm.com>
@esnible
esnible merged commit eee0b8d into main Aug 20, 2026
2 checks passed
@esnible
esnible deleted the relay-card-authorization branch August 20, 2026 17:15
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.

1 participant