andrewkroh / google-oidc-auth-middleware

Google OAuth Middleware plugin for Traefik proxy
https://plugins.traefik.io/plugins/65d5360746079255c9ffd1e2/google-oidc-auth
Apache License 2.0
6 stars 1 forks source link

X-Forwarded-User header not set on proxied request #7

Closed andrewkroh closed 7 months ago

andrewkroh commented 7 months ago

The response sent to the client is receiving the X-Forwarded-User header, but it should be passed to the downstream service so that it can know the user.

https://github.com/andrewkroh/google-oidc-auth-middleware/blob/11cd35bece7812ed12ec2eac38be7d39727c0fd0/oidc.go#L178

diff --git a/oidc.go b/oidc.go
index fb8fe6f..3fd8e2c 100644
--- a/oidc.go
+++ b/oidc.go
@@ -175,7 +175,7 @@ func (h *cookieAuthzHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
        if isAuthorized(ac.Email, ac.Domain, h.allowEmails, h.allowDomains) {
                h.debug.Printf("Received authorized request from user=%s of domain=%s at addr=%s for path=%s",
                        ac.Email, ac.Domain, r.RemoteAddr, r.URL.Path)
-               w.Header().Set("X-Forwarded-User", ac.Email)
+               r.Header.Set("X-Forwarded-User", ac.Email)
                h.next.ServeHTTP(w, r)
                return
        } else {