Fix the issue when expired token did not forced reauthentication.

This commit is contained in:
2024-10-03 14:00:41 +01:00
parent 4968c5f93a
commit a4a943ae9c
3 changed files with 32 additions and 12 deletions
+13
View File
@@ -11,6 +11,8 @@ import (
"strings"
"sync"
"time"
"github.com/gorilla/sessions"
)
func generateNonce() (string, error) {
@@ -82,6 +84,17 @@ func (t *TraefikOidc) handleLogout(rw http.ResponseWriter, req *http.Request) {
http.Error(rw, "Logged out", http.StatusForbidden)
}
func (t *TraefikOidc) handleExpiredToken(rw http.ResponseWriter, req *http.Request, session *sessions.Session) {
// Clear the existing session
session.Options.MaxAge = -1
session.Values = make(map[interface{}]interface{})
err := session.Save(req, rw)
if err != nil {
t.logger.Errorf("Failed to clear session: %v", err)
}
t.initiateAuthentication(rw, req, session, t.redirectURL)
}
func (t *TraefikOidc) handleCallback(rw http.ResponseWriter, req *http.Request) (bool, string) {
ctx := req.Context()
session, err := t.store.Get(req, cookieName)