Repository navigation
Description
Summary
Add an a2a auth <token> command that verifies a bearer token against an A2A server, plus the global --token / --auth-header flags that every other command (tasks *, interactive, agent-card) needs to talk to an auth-enabled server at all. Today the debugger has no way to send credentials: initA2AClient() in cli/cli.go builds the ADK client with an empty Headers map, so any server started with A2A_AUTH_ENABLED=true answers 401 to everything except the public card.
Obtaining the token stays out of band (cURL against the IdP); the debugger only transmits it. That matches the A2A spec: authentication is card-driven, the client never runs an OAuth flow in-protocol.
How authentication works in A2A (context for the implementer)
Spec: https://a2a-protocol.org/latest/specification/#7-authentication-and-authorization and the extended-card contract in 3.3.4. ADK write-up: https://github.com/inference-gateway/adk/blob/v0.26.4/docs/authentication.md
GET /.well-known/agent-card.jsonis always unauthenticated. The card advertisessecuritySchemes(named schemes:apiKey,http,oauth2,openIdConnect,mutualTLS),security(OR-of-ANDs requirement list) andsupportsExtendedAgentCard.- The client obtains a credential out of band and sends it on every request. The ADK server middleware (
server/middlewares/auth.go) only understandsAuthorization: Bearer <jwt>and verifies the JWT against the configured OIDC issuer; other schemes are declared on the card but not enforced by ADK. - Missing header -> HTTP
401+WWW-Authenticate: Bearer. Wrong format ->401+error="invalid_request". Bad/expired token ->401+error="invalid_token". The ADK client surfaces these asunexpected status code: 401, body: {"error":"..."}. - An authenticated client calls JSON-RPC
agent/getAuthenticatedExtendedCardonPOST /a2a. Error contract:-32004when the card does not setsupportsExtendedAgentCard,-32007when the flag is set but no extended card is configured, otherwise the extended card.
Getting a token for a local test (Keycloak realm shipped in adk/examples/authentication/docker-compose.yaml):
TOKEN=$(curl -s http://localhost:8080/realms/inference-gateway-realm/protocol/openid-connect/token \
-d grant_type=password -d client_id=inference-gateway-client \
-d client_secret=inference-gateway-secret -d username=demo -d password=demo -d scope=openid \
| jq -r .access_token)
a2a auth "$TOKEN" --server-url http://localhost:8090Implementation path
Everything already exists in the ADK client (github.com/inference-gateway/adk/client v0.26.4); this is wiring only, all in cli/cli.go plus README.
-
Global flags, bound to viper like the existing ones (in
init()):--token(string, default empty): bearer token / credential value.--auth-header(string, defaultAuthorization): header that carries the token.
Because they are viper keys,a2a config set token <jwt>and env vars work for free with no new persistence code. Document thatconfig setwrites the token in plaintext to~/.a2a.yamland that env / flag is preferred.
-
Attach the credential in
initA2AClient()so every command and the interactive mode inherit it:if token := viper.GetString("token"); token != "" { name := viper.GetString("auth-header") if strings.EqualFold(name, "Authorization") && !strings.HasPrefix(token, "Bearer ") { token = "Bearer " + token } config.Headers[name] = token }
client.Config.Headersis applied bysetHeaders()to every JSON-RPC and streaming request. Note:GetAgentCardandGetHealthdeliberately do not send custom headers (public endpoints), which is correct per spec. -
authcommand onrootCmd,Args: cobra.ExactArgs(1), registered next toconnectCmd:-
viper.Set("token", args[0])thenensureA2AClient()(reuses step 2, no second code path). -
a2aClient.GetAgentCard(ctx): fail fast if unreachable. Keep the card for the output. -
If
card.SupportsExtendedAgentCardis nil/false: printauthenticated: falsewith a clear reason and the card'ssecuritySchemes, exit 1. Do not call the RPC, the server would answer-32004regardless of the token. -
a2aClient.GetAuthenticatedExtendedCard(ctx, adk.GetAuthenticatedExtendedCardParams{}), unmarshalresp.Resultintoadk.AgentCard(samejson.Marshal/Unmarshalround-trip the other commands use). -
Success output through
printFormattedso-o json|yamlis honored:authenticated: true header: Authorization security_schemes: { ... from the public card ... } extended_card: { ... }
-
Errors go through
handleA2AError(err, "agent/getAuthenticatedExtendedCard"). Extend that helper with two more mappings alongside the existing-32601one:-32007-> "extended agent card not configured on the server", and an HTTP401body -> "authentication rejected: (check the token and --auth-header)". Non-zero exit on any failure so the command is usable in scripts.
-
-
Tests in
cli/cli_test.gousing the existingmockA2AClient(it already implementsGetAuthenticatedExtendedCard), following the save/restorea2aClientandos.Pipestdout pattern:- happy path: extended card returned, output contains
authenticated: true. - card without
supportsExtendedAgentCard: exits with error, RPC not called. - RPC returns
-32007/ a 401-shaped error: friendly message. initA2AClientheader composition:Authorizationgets theBearerprefix, a custom header (X-Api-Key) gets the raw value.
- happy path: extended card returned, output contains
-
Docs: README "Server Commands" (
a2a auth <token>), "Global Options" (--token,--auth-header), a short "Authentication" example section with the cURL snippet above, and the new keys in the~/.a2a.yamlexample. AGENTS.md namespace list getsauth.
Acceptance Criteria
-
a2a auth <token>fetches the public card, callsagent/getAuthenticatedExtendedCardwith the token, prints the extended card viaprintFormatted, exits 0 on success and 1 on any failure - The token is sent in the header named by
--auth-header(defaultAuthorization, value prefixed withBearerfor that header only) -
--token/--auth-headerare global, viper-bound flags, sotasks *,interactiveandagent-cardwork against an auth-enabled server anda2a config set token ...persists them -
401,-32004and-32007produce actionable messages instead of raw ADK errors - Unit tests cover the happy path, the unsupported-card path, and the error mappings
- README and AGENTS.md document the command, the flags, and how to obtain a token out of band
Out of scope
- Running an OAuth / OIDC flow inside the debugger (spec 7.3: credential acquisition is out of band)
- API key or mTLS enforcement (ADK only enforces OIDC bearer today)
- Token refresh or secure storage beyond the existing
~/.a2a.yamlconfig file
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
edenreich commentedon Sep 14, 2026
@claude Can you work on this? use /ponytail:ponytail
inference-gateway-maintainer commentedon Sep 14, 2026
Claude finished @edenreich's task in 4m 53s —— View job •
feat/issue-4-20260914-2039• Create PR ➔Done -
a2a authimplementedcli/cli.goand understand wiring--token/--auth-headerflags, viper-bound, injected ininitA2AClient()a2a auth <token>command on root401,-32004,-32007go build,go vet,go test ./...- all passWhat changed
cli/cli.go--tokenand--auth-header(defaultAuthorization) persistent flags, viper-bound. The five repeatedBindPFlagblocks collapsed into one loop over the key list.authHeader()helper returns the header name/value (Bearerprefix only when the header isAuthorizationand the token is not already prefixed);initA2AClient()puts it intoclient.Config.Headers, sotasks *,interactiveandagent-cardall inherit the credential.authCmd: sets the token, fetches the public card, short-circuits withauthenticated: false+ the card'ssecuritySchemeswhensupportsExtendedAgentCardis unset (RPC not called), otherwise callsagent/getAuthenticatedExtendedCardand printsauthenticated / header / security_schemes / extended_cardviaprintFormatted. Any failure returns an error, so the process exits 1.handleA2AErrornow derives the JSON-RPC code once and maps-32601,-32004,-32007andunexpected status code: 401to friendly messages.cli/auth_test.go(new) + agetAuthenticatedExtendedCardFunchook on the existingmockA2AClient: happy path, unsupported-card path (fails the test if the RPC is called), table test for the three error mappings, table test for header composition includingX-Api-Key.Docs: README gets the command, the two global options, the config-file keys and an "Authentication" section with the Keycloak cURL snippet plus the plaintext-storage warning; AGENTS.md gets
authin the root namespace list and a short authentication note.Skipped: no OAuth flow, no token refresh or secure storage, no API-key/mTLS enforcement - all listed out of scope in the issue.
Note
The commit is pushed to
feat/issue-4-20260914-2039, but this run's sandbox refused everyghinvocation ("This command requires approval"), so I could not open the PR or set the Roadmap board item to In progress / QA. That is a local tool-permission limit, not a missing GitHub scope, so I did not file an escalation issue. Please open the PR with the link below and move the board item.| Branch: feat/issue-4-20260914-2039
inference-gateway-releaser commentedon Oct 3, 2026
🎉 This issue has been resolved in version 0.11.0 🎉
The release is available on GitHub release
Your semantic-release bot 📦🚀