P3.1: Add /auth/token endpoint (password grant proxy) #5

Closed
opened 2026-09-08 03:54:36 +00:00 by rock · 0 comments
Owner

Summary

Gateway exposes POST /auth/token that accepts username+password, exchanges with Authentik via grant_type=password, returns JWT + refresh token.

Why

Users should not need to know about OIDC flows or manually craft token requests against Authentik. Gateway is the single entry point.

Acceptance Criteria

  • POST /auth/token accepts {"username":"...","password":"...","scope":"..."}
  • Proxies to Authentik token endpoint with grant_type=password
  • Returns {"access_token":"...","refresh_token":"...","expires_in":...,"token_type":"Bearer"}
  • Returns Authentik error verbatim on bad credentials (401)
  • No JWT validation on this endpoint (it issues tokens, does not consume them)
  • Config: auth.tokenUrl, auth.clientId, auth.clientSecret in ConfigMap/Secret
  • Unit tests with mock Authentik responses
  • Integration test against real Authentik (manual, documented)

Implementation

  • New file: internal/proxy/auth_endpoints.go
  • Wire in proxy.go ServeHTTP before JWT check block
  • Config additions in internal/config/config.go

Depends on

  • P3.2 (Authentik provider must support password grant)

Review checklist

  • No credentials logged (password, client_secret, tokens)
  • Rate limiting considered (Authentik has built-in, but gateway should not amplify)
  • Error responses use RFC 9457 problem detail format consistently
## Summary Gateway exposes `POST /auth/token` that accepts username+password, exchanges with Authentik via `grant_type=password`, returns JWT + refresh token. ## Why Users should not need to know about OIDC flows or manually craft token requests against Authentik. Gateway is the single entry point. ## Acceptance Criteria - [ ] `POST /auth/token` accepts `{"username":"...","password":"...","scope":"..."}` - [ ] Proxies to Authentik token endpoint with `grant_type=password` - [ ] Returns `{"access_token":"...","refresh_token":"...","expires_in":...,"token_type":"Bearer"}` - [ ] Returns Authentik error verbatim on bad credentials (401) - [ ] No JWT validation on this endpoint (it issues tokens, does not consume them) - [ ] Config: `auth.tokenUrl`, `auth.clientId`, `auth.clientSecret` in ConfigMap/Secret - [ ] Unit tests with mock Authentik responses - [ ] Integration test against real Authentik (manual, documented) ## Implementation - New file: `internal/proxy/auth_endpoints.go` - Wire in `proxy.go` ServeHTTP before JWT check block - Config additions in `internal/config/config.go` ## Depends on - P3.2 (Authentik provider must support password grant) ## Review checklist - [ ] No credentials logged (password, client_secret, tokens) - [ ] Rate limiting considered (Authentik has built-in, but gateway should not amplify) - [ ] Error responses use RFC 9457 problem detail format consistently
rock added this to the Phase 3: OAuth2 Token Exchange & Identity Propagation milestone 2026-09-08 03:54:36 +00:00
rock added the status/todoarea/autharea/gatewaypriority/hightype/feature labels 2026-09-08 03:54:36 +00:00
rock self-assigned this 2026-09-08 03:54:36 +00:00
rock added this to the (deleted) project 2026-09-08 04:37:12 +00:00
rock closed this issue 2026-09-08 04:44:58 +00:00
Sign in to join this conversation.