mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-11-03 07:44:13 +00:00
perf(logout): parse the ID token once for the invalidation check
With backchannel or frontchannel logout on, every authenticated request parsed the ID token twice to read sid, sub and iat. One shared parse now returns the same values. A test pins equality with the two separate calls for valid, partial and malformed tokens. The gain is one parseJWT call fewer per request. I did not measure it under yaegi.
This commit is contained in:
+2
-4
@@ -1054,8 +1054,7 @@ func (t *TraefikOidc) processAuthorizedRequestRS(rw http.ResponseWriter, req *ht
|
||||
idToken := rs.idToken
|
||||
if t.enableBackchannelLogout || t.enableFrontchannelLogout {
|
||||
if idToken != "" {
|
||||
sid, sub, _ := t.extractSessionInfo(idToken)
|
||||
createdAt := t.sessionCreatedAtForInvalidation(idToken, session)
|
||||
sid, sub, createdAt := t.invalidationInputs(idToken, session)
|
||||
if t.isSessionInvalidated(sid, sub, createdAt) {
|
||||
t.logger.Infof("Session for user %s has been invalidated via IdP-initiated logout", userIdentifier)
|
||||
if err := session.Clear(req, rw); err != nil {
|
||||
@@ -1147,8 +1146,7 @@ func (t *TraefikOidc) processAuthorizedRequest(rw http.ResponseWriter, req *http
|
||||
if t.enableBackchannelLogout || t.enableFrontchannelLogout {
|
||||
idToken := session.GetIDToken()
|
||||
if idToken != "" {
|
||||
sid, sub, _ := t.extractSessionInfo(idToken)
|
||||
createdAt := t.sessionCreatedAtForInvalidation(idToken, session)
|
||||
sid, sub, createdAt := t.invalidationInputs(idToken, session)
|
||||
if t.isSessionInvalidated(sid, sub, createdAt) {
|
||||
t.logger.Infof("Session for user %s has been invalidated via IdP-initiated logout", userIdentifier)
|
||||
// Clear the session and redirect to login
|
||||
|
||||
Reference in New Issue
Block a user