fixup! fixup! fixup! Simplify all the things.

This commit is contained in:
2025-07-22 10:47:28 +01:00
parent 46745f5b54
commit ce9614bb64
2 changed files with 154 additions and 5 deletions
+10 -5
View File
@@ -269,10 +269,10 @@ func NewSessionManager(encryptionKey string, forceHTTPS bool, logger *Logger) (*
accessTokenChunks: make(map[int]*sessions.Session),
refreshTokenChunks: make(map[int]*sessions.Session),
idTokenChunks: make(map[int]*sessions.Session),
refreshMutex: sync.Mutex{},
sessionMutex: sync.RWMutex{},
dirty: false,
inUse: false,
refreshMutex: sync.Mutex{}, // Initialize the mutex
sessionMutex: sync.RWMutex{}, // Initialize the session mutex
dirty: false, // Initialize dirty flag
inUse: false, // Initialize in-use flag
}
sd.Reset()
return sd
@@ -743,6 +743,12 @@ func (sd *SessionData) Save(r *http.Request, w http.ResponseWriter) error {
saveOrLogError(sessionChunk, fmt.Sprintf("refresh token chunk %d", i))
}
// Save ID token chunks.
for i, sessionChunk := range sd.idTokenChunks {
sessionChunk.Options = options
saveOrLogError(sessionChunk, fmt.Sprintf("ID token chunk %d", i))
}
if firstErr == nil {
sd.dirty = false // Reset dirty flag only if all saves were successful
}
@@ -1824,7 +1830,6 @@ func (sd *SessionData) SetIDToken(token string) {
sd.manager.logger.Errorf("CRITICAL: ID token too large (%d bytes) - possible corruption, rejecting", len(token))
return
}
currentIDToken := sd.getIDTokenUnsafe()
if currentIDToken == token {
// If token is empty, and current is also empty, it's not a change.