CallerMiddleware checks X-Auth-Request-User first, then falls back to X-Forwarded-User. If a future auth proxy sets both headers (e.g. oauth2-proxy in some configs does), behaviour is undefined and untested.
File:internal/auth/caller.go:10-18
Suggestions:
Add a comment documenting which header takes precedence and why
Add a unit test covering the both-present scenario
Consider logging a warning when both are present and differ
`CallerMiddleware` checks `X-Auth-Request-User` first, then falls back to `X-Forwarded-User`. If a future auth proxy sets both headers (e.g. oauth2-proxy in some configs does), behaviour is undefined and untested.
**File:** `internal/auth/caller.go:10-18`
**Suggestions:**
- Add a comment documenting which header takes precedence and why
- Add a unit test covering the both-present scenario
- Consider logging a warning when both are present and differ
Documents the precedence in a doc comment: X-Auth-Request-User (the verified OIDC identity oauth2-proxy sets) is authoritative; X-Forwarded-User is only a fallback when the former is absent.
Takes a *slog.Logger and logs a warning when both headers are present and disagree — X-Auth-Request-User still wins, but the proxy misconfiguration is now visible instead of silently resolved.
Done in gitea-mcp v0.5.0.
`CallerMiddleware` (`internal/auth/caller.go`) now:
- **Documents the precedence** in a doc comment: `X-Auth-Request-User` (the verified OIDC identity oauth2-proxy sets) is authoritative; `X-Forwarded-User` is only a fallback when the former is absent.
- Takes a `*slog.Logger` and **logs a warning when both headers are present and disagree** — X-Auth-Request-User still wins, but the proxy misconfiguration is now visible instead of silently resolved.
Table-driven `TestCallerHeaderPrecedence` (both/single/none) + `TestCallerConflictingHeadersLogsWarning`. `task check` green.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
CallerMiddlewarechecksX-Auth-Request-Userfirst, then falls back toX-Forwarded-User. If a future auth proxy sets both headers (e.g. oauth2-proxy in some configs does), behaviour is undefined and untested.File:
internal/auth/caller.go:10-18Suggestions:
Done in gitea-mcp v0.5.0.
CallerMiddleware(internal/auth/caller.go) now:X-Auth-Request-User(the verified OIDC identity oauth2-proxy sets) is authoritative;X-Forwarded-Useris only a fallback when the former is absent.*slog.Loggerand logs a warning when both headers are present and disagree — X-Auth-Request-User still wins, but the proxy misconfiguration is now visible instead of silently resolved.Table-driven
TestCallerHeaderPrecedence(both/single/none) +TestCallerConflictingHeadersLogsWarning.task checkgreen.