Skip to content

feat(auth): add auth command and credential flags - #114

Merged
edenreich merged 4 commits into
mainfrom
feat/issue-4-20260914-2039
Sep 16, 2026
Merged

edenreich merged 4 commits into
mainfrom
feat/issue-4-20260914-2039

Conversation

@edenreich

@edenreich edenreich commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a2a auth <token> plus the global --token / --auth-header flags so every command can talk to an auth-enabled A2A server.

  • --token / --auth-header are viper-bound persistent flags; initA2AClient() injects the credential into client.Config.Headers via authHeader() (Bearer prefix only for the Authorization header), so tasks *, interactive and agent-card inherit it. a2a config set token ... and the TOKEN env var work for free.
  • a2a auth <token> verifies a credential the way spec 7.3/7.4 describe it: fetch the public card, send one authenticated request (tasks/list), treat a 401 as rejection and any JSON-RPC error as "dispatched, therefore accepted". When the card advertises supportsExtendedAgentCard the authenticated extended card is fetched and printed too. Output goes through printFormatted, non-zero exit on failure.
  • handleA2AError maps -32004, -32007 and HTTP 401 to actionable messages.
  • example/ gains an auth compose profile: Keycloak with a service-account client (client credentials grant, access-token audience mapper, pinned KC_HOSTNAME) and an auth-enabled mock agent configured with only the issuer and client ID, mirroring the gateway's auth-keycloak example.
  • README, example/README.md, AGENTS.md and CLAUDE.md document the command, the flags, how to obtain a token out of band and the example.

Depends on

Tests

  • task test green (cli/auth_test.go: happy path, no extended card, 401 on the probe, -32004 / -32007 / 401 on the extended card RPC, header composition).
  • End to end with a locally built mock-agent pinned to the ADK branch:
$ docker compose --profile auth up -d --wait
$ TOKEN=$(curl -s http://localhost:8081/realms/inference-gateway-realm/protocol/openid-connect/token \
    -d grant_type=client_credentials -d client_id=inference-gateway-client -d client_secret=very-secret | jq -r .access_token)

$ docker compose run --rm a2a-debugger tasks list --server-url http://a2a-server-auth:8080
Error: ❌ Authentication rejected: unexpected status code: 401, body: {"error":"missing authorization header"} (check the token and --auth-header)

$ docker compose run --rm a2a-debugger auth "$TOKEN" --server-url http://a2a-server-auth:8080
authenticated: true
extended_card_supported: false
header: Authorization
security_schemes: {}

$ docker compose run --rm a2a-debugger auth bad-token --server-url http://a2a-server-auth:8080
Error: ❌ Authentication rejected: unexpected status code: 401, body: {"error":"invalid token"} (check the token and --auth-header)

$ docker compose run --rm a2a-debugger tasks submit "Hello" --server-url http://a2a-server-auth:8080 --token "$TOKEN"
        state: TASK_STATE_SUBMITTED

$ docker compose run --rm -e TOKEN a2a-debugger tasks list --server-url http://a2a-server-auth:8080
        state: TASK_STATE_COMPLETED
total: 1

Closes #4

@inference-gateway-maintainer inference-gateway-maintainer Bot moved this to Todo in 2026 Sep 15, 2026
@edenreich edenreich moved this from Todo to QA in 2026 Sep 15, 2026
@edenreich
edenreich force-pushed the feat/issue-4-20260914-2039 branch from 535e75f to 49515ea Compare September 16, 2026 15:23
@edenreich edenreich changed the title feat(auth): add auth command and credential flags feat(auth): Add auth command and credential flags Sep 16, 2026
`a2a auth` now verifies a credential the way the A2A spec describes it:
the token is sent on an authenticated request (tasks/list) and a 401 means
rejection, while any JSON-RPC error proves the request was dispatched. The
extended card is fetched only when the public card advertises it, so the
command works against agents without one.

The example gains an `auth` compose profile with Keycloak (service-account
client, client credentials grant, pinned KC_HOSTNAME) and an auth-enabled
mock agent that needs only the issuer and client ID, mirroring the
gateway's auth-keycloak example.
@edenreich edenreich changed the title feat(auth): Add auth command and credential flags feat(auth): add auth command and credential flags Sep 16, 2026
@edenreich
edenreich merged commit b40e02a into main Sep 16, 2026
1 check passed
@edenreich
edenreich deleted the feat/issue-4-20260914-2039 branch September 16, 2026 16:16
@edenreich edenreich moved this from QA to Done in 2026 Sep 16, 2026
inference-gateway-releaser Bot added a commit that referenced this pull request Oct 3, 2026
## [0.11.0](v0.10.0...v0.11.0) (2026-10-03)

### ✨ Features

* **auth:** add auth command and credential flags ([#114](#114)) ([b40e02a](b40e02a))

### ♻️ Improvements

* adopt A2A v1.0.1 method names via adk v0.31.0 ([#133](#133)) ([18f5323](18f5323))

### 👷 CI

* **claude:** centralize claude.yml via reusable workflow ([#123](#123)) ([c64f10f](c64f10f))
* **claude:** centralize claude.yml via reusable workflow ([#126](#126)) ([d2c0b71](d2c0b71))

### 📚 Documentation

* **agents:** refresh AGENTS.md for current code layout ([#118](#118)) ([efee952](efee952))

### 🔧 Miscellaneous

* **deps:** bump claude-code 2.1.245 -> 2.1.266 ([#112](#112)) ([2c185f0](2c185f0))
* **deps:** bump claude-code 2.1.266 -> 2.1.278 ([#121](#121)) ([8a66dea](8a66dea))
* **deps:** bump claude-code 2.1.278 -> 2.1.280 ([#124](#124)) ([de903b9](de903b9))
* **deps:** bump claude-code 2.1.280 -> 2.1.283 ([#127](#127)) ([9fc5ace](9fc5ace))
* **deps:** bump claude-code 2.1.283 -> 2.1.285 ([#131](#131)) ([b2b57c2](b2b57c2))
* **deps:** bump infer CLI v0.183.0 -> v0.192.0 ([#113](#113)) ([58338f7](58338f7))
* **deps:** bump infer CLI v0.192.0 -> v0.205.3 ([#122](#122)) ([dcc41b7](dcc41b7))
* **deps:** bump infer CLI v0.205.3 -> v0.208.0 ([#125](#125)) ([921b772](921b772))
* **deps:** bump infer CLI v0.208.0 -> v0.218.0 ([#128](#128)) ([b1dbfed](b1dbfed))
* **deps:** bump infer CLI v0.218.0 -> v0.221.1 ([#130](#130)) ([775c18c](775c18c))
* **lint:** enforce Go import grouping and named imports with gci and importas ([#117](#117)) ([ca24b08](ca24b08)), closes [#116](#116)

### 🔨 Miscellaneous

* **deps:** bump docker/setup-buildx-action in the github-actions group ([#120](#120)) ([2c42a52](2c42a52))
* **deps:** bump github.com/inference-gateway/adk in the gomod group ([#115](#115)) ([479f614](479f614))
* **deps:** bump github.com/inference-gateway/adk in the gomod group ([#119](#119)) ([e8bf20c](e8bf20c))
* **deps:** bump github.com/inference-gateway/adk in the gomod group ([#129](#129)) ([d1b7019](d1b7019))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.11.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement Authentication command

1 participant