AuthProxy: Forward user headers even on non auth required paths
Change-Id: I3c4235639409c492b3cacd9330f140453c614fe9
diff --git a/core/auth/proxy/main.go b/core/auth/proxy/main.go
index adf789c..a147049 100644
--- a/core/auth/proxy/main.go
+++ b/core/auth/proxy/main.go
@@ -94,6 +94,11 @@
}
func handle(w http.ResponseWriter, r *http.Request) {
+ user, err := queryWhoAmI(r.Cookies())
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
reqAuth := true
for _, p := range strings.Split(*noAuthPathPrefixes, ",") {
t := strings.TrimSpace(p)
@@ -102,15 +107,7 @@
break
}
}
- var user *user
if reqAuth {
- var err error
- user, err = queryWhoAmI(r.Cookies())
- fmt.Printf("--- %+v\n", user)
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
if user == nil {
if r.Method != http.MethodGet {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
@@ -145,7 +142,6 @@
}
}
}
- fmt.Printf("%+v\n", user)
rc := r.Clone(context.Background())
if user != nil {
rc.Header.Add("X-Forwarded-User", user.Identity.Traits.Username)