mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-14 04:07:46 +00:00
Add authenticated user email to the header X-Forwarded-User
This commit is contained in:
@@ -282,6 +282,22 @@ func (t *TraefikOidc) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
idToken, ok := session.Values["id_token"].(string)
|
||||||
|
if !ok || idToken == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
claims, err := extractClaims(idToken)
|
||||||
|
if err != nil {
|
||||||
|
t.logger.Errorf("Failed to extract claims: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add authenticated user email to the header X-Forwarded-User
|
||||||
|
email, _ := claims["email"].(string)
|
||||||
|
req.Header.Set("X-Forwarded-User", email)
|
||||||
|
|
||||||
t.next.ServeHTTP(rw, req)
|
t.next.ServeHTTP(rw, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user