mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-14 04:07:46 +00:00
Verify provided token on every request.
This commit is contained in:
@@ -137,7 +137,18 @@ func (t *TraefikOidc) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
|
|
||||||
authenticated, _ := session.Values["authenticated"].(bool)
|
authenticated, _ := session.Values["authenticated"].(bool)
|
||||||
if authenticated {
|
if authenticated {
|
||||||
// infoLogger.Printf("User is authenticated, proceeding to next handler")
|
idToken, ok := session.Values["id_token"].(string)
|
||||||
|
if !ok || idToken == "" {
|
||||||
|
http.Error(rw, "Invalid session", http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := t.verifyToken(idToken); err != nil {
|
||||||
|
http.Error(rw, "Invalid token", http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proceed with the request
|
||||||
t.next.ServeHTTP(rw, req)
|
t.next.ServeHTTP(rw, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user