Another attempt to fix the issue with expired session.

This commit is contained in:
2024-10-03 14:00:43 +01:00
parent 38433dfff8
commit e97d8e15ff
2 changed files with 7 additions and 10 deletions
+5 -3
View File
@@ -137,15 +137,17 @@ func (t *TraefikOidc) handleExpiredToken(rw http.ResponseWriter, req *http.Reque
func (t *TraefikOidc) handleCallback(rw http.ResponseWriter, req *http.Request) (bool, string) {
session, err := t.store.Get(req, cookieName)
if err != nil {
handleError(rw, "Session error", http.StatusInternalServerError, t.logger)
t.logger.Errorf("Session error: %v", err)
t.initiateAuthentication(rw, req, session, t.redirectURL)
return false, ""
}
callbackState := req.URL.Query().Get("state")
sessionState, ok := session.Values["csrf"].(string)
if !ok || callbackState != sessionState {
handleError(rw, "Invalid state parameter", http.StatusBadRequest, t.logger)
return false, "invalid-state-param"
t.logger.Debug("Invalid state parameter. Session might have expired.")
t.initiateAuthentication(rw, req, session, t.redirectURL)
return false, ""
}
code := req.URL.Query().Get("code")