P3.4: Inject X-Forwarded-User identity headers after JWT validation #9

Open
opened 2026-09-08 04:42:00 +00:00 by rock · 0 comments
Owner

Summary

After JWT validation, gateway injects identity headers so downstream gets audit trail without parsing JWTs.

Code repo: rock/homelab-frontendinternal/proxy/proxy.go

Headers

X-Forwarded-User: rock              # sub claim
X-Forwarded-Roles: llm:inference    # roles/permissions claim
X-Acting-Service: portfolio-agent   # azp claim (service accounts only)
X-Auth-Verified: true               # gateway validated JWT

Acceptance Criteria

  • Headers injected after successful JWT validation
  • Incoming X-Forwarded-User / X-Auth-Verified STRIPPED from client request (anti-spoofing)
  • Unauthenticated requests do NOT get these headers
  • Unit tests: injection, stripping, edge cases

Security contract

Downstream MUST only accept traffic from gateway (NetworkPolicy enforced).
Downstream trusts X-Auth-Verified: true header — if absent, request is unauthenticated.

Review checklist

  • Anti-spoofing: incoming headers stripped before injection
  • Wildcard "*" passed as literal, not expanded
  • Empty claims handled (no empty header values)
## Summary After JWT validation, gateway injects identity headers so downstream gets audit trail without parsing JWTs. **Code repo:** `rock/homelab-frontend` — `internal/proxy/proxy.go` ## Headers ``` X-Forwarded-User: rock # sub claim X-Forwarded-Roles: llm:inference # roles/permissions claim X-Acting-Service: portfolio-agent # azp claim (service accounts only) X-Auth-Verified: true # gateway validated JWT ``` ## Acceptance Criteria - [ ] Headers injected after successful JWT validation - [ ] Incoming `X-Forwarded-User` / `X-Auth-Verified` STRIPPED from client request (anti-spoofing) - [ ] Unauthenticated requests do NOT get these headers - [ ] Unit tests: injection, stripping, edge cases ## Security contract Downstream MUST only accept traffic from gateway (NetworkPolicy enforced). Downstream trusts `X-Auth-Verified: true` header — if absent, request is unauthenticated. ## Review checklist - [ ] Anti-spoofing: incoming headers stripped before injection - [ ] Wildcard "*" passed as literal, not expanded - [ ] Empty claims handled (no empty header values)
rock added this to the Phase 3: OAuth2 Token Exchange & Identity Propagation milestone 2026-09-08 04:42:00 +00:00
rock added the area/autharea/gatewaytype/featurestatus/todopriority/high labels 2026-09-08 04:42:01 +00:00
rock self-assigned this 2026-09-08 04:42:02 +00:00
rock added this to the API-GW OAuth project 2026-09-08 04:43:55 +00:00
rock moved this to Todo in API-GW OAuth on 2026-09-08 04:44:40 +00:00
Sign in to join this conversation.