Document and script the complete auth flow end-to-end. Serves as both integration test and usage documentation.
# 1. User gets token with password TOKEN=$(curl -s POST https://api.riotpiao.com/auth/token \ -d '{"username":"rock","password":"..."}' | jq -r .access_token) # 2. Decode and verify claims echo $TOKEN | cut -d. -f2 | base64 -d | jq . # Expect: sub=rock, permissions=["*"] # 3. Call LLM API curl https://api.riotpiao.com/v1/chat/completions \ -H "Authorization: Bearer $TOKEN" \ -d '{"model":"reasoning","messages":[{"role":"user","content":"say ok"}]}' # Expect: 200, streaming response # 4. Verify downstream saw identity headers kubectl logs -n llm-serving deploy/reasoning-predictor | grep X-Forwarded-User # (vLLM doesn't log headers, but memory service will)
SA_TOKEN=$(curl -s POST https://authentik.riotpiao.com/application/o/token/ \ -d "grant_type=client_credentials&client_id=portfolio-agent&client_secret=$SECRET&scope=openid roles") curl https://api.riotpiao.com/v1/chat/completions \ -H "Authorization: Bearer $(echo $SA_TOKEN | jq -r .access_token)" \ -d '{"model":"reasoning","messages":[...]}' # Expect: 200, X-Forwarded-User=portfolio-agent, X-Acting-Service absent
# portfolio-agent exchanges rock's token for memory-scoped token EXCHANGED=$(curl -s POST https://api.riotpiao.com/auth/exchange \ -d "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \ -d "subject_token=$USER_TOKEN" \ -d "subject_token_type=urn:ietf:params:oauth:token-type:access_token" \ -d "client_id=portfolio-agent&client_secret=$SECRET" \ -d "scope=memory:read&resource=poimen-memory") # Call memory service with exchanged token curl -H "X-Service: memory" -H "X-Resource: query" \ -H "Authorization: Bearer $(echo $EXCHANGED | jq -r .access_token)" \ https://api.riotpiao.com/ -d '{"query":"..."}' # Expect: X-Forwarded-User=rock, X-Acting-Service=portfolio-agent
docs/auth-flows.md
scripts/test-auth-e2e.sh
No dependencies set.
The note is not visible to the blocked user.
Summary
Document and script the complete auth flow end-to-end. Serves as both integration test and usage documentation.
Test scenarios
Scenario 1: User direct call
Scenario 2: Service-to-service (own identity)
Scenario 3: Token exchange (delegated identity)
Scenario 4: Error cases
Acceptance Criteria
docs/auth-flows.mdscripts/test-auth-e2e.sh(interactive, prompts for password)