Skip to content

[DOCS] Document OIDC/OAuth2 authentication middleware in the TypeScript ADK #79

Closed

Description

@claude

Summary

The TypeScript ADK (@inference-gateway/adk) now ships an OIDC/OAuth2 Bearer-token authentication middleware mirroring the Go ADK's server/middlewares/auth.go. The feature is disabled by default and opted into via AUTH_ENABLE=true. It needs documentation in the docs site so consumers can discover and configure it.

The implementation was tracked in:

What ships

  • New module src/auth/ exposing:
    • loadAuthConfigFromEnv() - reads AUTH_ENABLE, AUTH_ISSUER_URL, AUTH_CLIENT_ID, AUTH_CLIENT_SECRET.
    • createAuthenticator() - async factory that performs OIDC discovery at boot, builds a JWKS verifier with TTL caching and kid-miss refresh, and returns a Hono middleware.
    • OIDCAuthenticator / NoopAuthenticator - the enabled and zero-overhead disabled paths.
    • decorateAgentCardWithAuth() - advertises the OpenID Connect security scheme on the agent card when auth is on.
  • A2AServerConfig.authenticator? mounts the middleware on the JSON-RPC endpoint only. /.well-known/agent-card.json and /health stay public.
  • A2AServerBuilder.withAuthenticator() / A2AServerBuilder.withAuthConfig() - the latter also decorates the card at build() time.
  • Rejected requests: HTTP 401 + JSON-RPC -32001 + WWW-Authenticate: Bearer. Successful verification attaches AuthContext to c.get('auth').
  • Built on jose@^6. Verified against a real Keycloak via a gated integration test (RUN_KEYCLOAK_INTEGRATION=1).

Pages to touch

  • typescript-adk.md - add an "Authentication" section under the "What ships today" table covering the config env vars, the builder wiring, the request lifecycle (claims via c.get('auth')), card advertisement, and the rejection contract.
  • authentication.md - cross-link the TypeScript ADK section. The Go gateway page currently uses AUTH_OIDC_ISSUER / AUTH_OIDC_CLIENT_ID / AUTH_OIDC_CLIENT_SECRET; the TypeScript ADK uses AUTH_ISSUER_URL / AUTH_CLIENT_ID / AUTH_CLIENT_SECRET. Document both variants explicitly so readers don't confuse them.

Code samples to add

  • Minimal opt-in via AUTH_ENABLE=true plus issuer URL.
  • A2AServerBuilder.withAuthConfig() example showing card advertisement.
  • Custom NoopAuthenticator opt-out path.
  • Snippet showing how to read claims off c.get('auth') inside a handler.

Acceptance Criteria

  • typescript-adk.md has an "Authentication" section covering config env vars, builder wiring, request lifecycle, card decoration, and the 401 / JSON-RPC -32001 rejection contract.
  • authentication.md cross-links the TypeScript ADK auth section and clarifies the env-var name difference between the Go gateway and the TypeScript ADK.
  • At least one runnable code sample per surface listed under "Code samples to add."
  • Page metadata (description) is updated so the new content is discoverable in search.

Activity

  1. edenreich commented on May 27, 2026

    @edenreich
    Contributor

    @claude /maintainer Can you document it?

  2. added
    documentation
    on May 27, 2026
  3. added theissue type on May 27, 2026
  4. claude commented on May 27, 2026

    @claude
    ContributorAuthor

    Claude finished @edenreich's task in 6m 48s —— View job • claude/issue-79-20260527-2120 • Create PR ➔


    Documentation task: OIDC/OAuth2 in TypeScript ADK

    • Read existing typescript-adk.md and authentication.md for structure/voice
    • Cross-reference the TypeScript ADK source (src/auth/config.ts, authenticator.ts, oidc.ts, card-decoration.ts, server-builder/server) for env var names, builder API, request lifecycle, rejection reasons
    • Add "Authentication" h2 to typescript-adk.md (config, builder wiring, lifecycle, card decoration, 401/-32001 contract) + add row to "What ships today" table + bump page description
    • Add code samples: minimal opt-in, withAuthConfig, reading claims via c.get('auth'), NoopAuthenticator opt-out, decorateAgentCardWithAuth with custom scheme name
    • Cross-link from authentication.md (Go gateway page) and clarify Go vs TypeScript env-var name differences via a side-by-side mapping table; bump page description
    • Add a parity bullet under "Parity with the Go ADK"
    • npm run lint:md clean
    • npm run format:check clean (ran npm run format to autofix one prettier wrap)
    • npm run build succeeds (no Vue compiler complaints from the ${...} / <> patterns in the new copy)
    • Pushed to claude/issue-79-20260527-2120 (commit 2afa720)

    Summary of changes

    typescript-adk.md

    • New ## Authentication h2 (placed between ## Agent builder and ## Parity with the Go ADK) covering: intro + jose@^6 reference, env-var config table, minimal opt-in code sample, withAuthenticator() / withAuthConfig() builder wiring with combined-call sample, public vs. protected endpoint table, c.get('auth') claims-reading sample with AuthContext shape, full HTTP 401 + JSON-RPC -32001 + WWW-Authenticate: Bearer rejection envelope plus reason code matrix, agent-card decoration with decorateAgentCardWithAuth() (including schemeName override sample), and NoopAuthenticator opt-out sample.
    • New row in the "What ships today" table for createAuthenticator / OIDCAuthenticator.
    • Page description frontmatter now mentions OIDC / OAuth2 / AUTH_ENABLE / AUTH_ISSUER_URL / JSON-RPC -32001 so the new content is discoverable in search.
    • New parity bullet linking the TS auth surface to server/middlewares/auth.go, calling out the env-var name divergence explicitly.

    authentication.md (Go gateway page)

    • Clarified that the page documents the Go gateway, and that TypeScript ADK consumers should see typescript-adk#authentication.

    • New "Env-var naming: Go gateway vs. TypeScript ADK" subsection with a side-by-side mapping table making the AUTH_OIDC_* vs. AUTH_* divergence explicit, plus a note on what's behaviour-identical (JWKS verification, 401 + WWW-Authenticate: Bearer) vs. ADK-specific (JSON-RPC -32001, public /.well-known/agent-card.json).

    • New bullet under "Next Steps" pointing back at the TypeScript ADK auth section.

    • Page description frontmatter expanded to include both env-var families.

    • branch: claude/issue-79-20260527-2120

  5. added a commit that references this issue on May 27, 2026
    2afa720
  6. moved this to Done in 2026on Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions