feat(auth): document caller header precedence + warn on conflict (#10)
CallerMiddleware silently preferred X-Auth-Request-User over X-Forwarded-User with no explanation and no signal when both were set. Documented the precedence (X-Auth-Request-User is the verified OIDC identity oauth2-proxy sets, so it is authoritative; X-Forwarded-User is a fallback), and it now takes a *slog.Logger and warns when both headers are present and disagree, so a proxy misconfiguration is visible instead of silently resolved. Table-driven tests cover precedence (both/single/none) and the conflict-warning path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,7 @@ const prFixture = `{
|
||||
|
||||
func callerContext(user string) context.Context {
|
||||
var capturedCtx context.Context
|
||||
h := auth.CallerMiddleware(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
|
||||
h := auth.CallerMiddleware(nil, http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
|
||||
capturedCtx = r.Context()
|
||||
}))
|
||||
req := httptest.NewRequest("POST", "/", nil)
|
||||
|
||||
Reference in New Issue
Block a user