fixup! CSRF and Cookie Domain fixes

This commit is contained in:
2025-08-29 11:07:02 +01:00
parent 5241cfe792
commit 873105108e
3 changed files with 34 additions and 8 deletions
+9 -2
View File
@@ -245,7 +245,8 @@ type SessionManager struct {
forceHTTPS bool
cookieDomain string
chunkManager *ChunkManager
cleanupDone bool // Track if we've attempted cookie cleanup
cleanupMutex sync.RWMutex // Protects cleanup operations
cleanupDone bool // Track if we've attempted cookie cleanup
}
// NewSessionManager creates a new session manager with the specified configuration.
@@ -628,7 +629,11 @@ func (sm *SessionManager) CleanupOldCookies(w http.ResponseWriter, r *http.Reque
// If we have a configured domain and this is the first request after config change,
// attempt to delete the cookie with various domain variations to ensure cleanup
if currentDomain != "" && !sm.cleanupDone {
sm.cleanupMutex.RLock()
shouldCleanup := currentDomain != "" && !sm.cleanupDone
sm.cleanupMutex.RUnlock()
if shouldCleanup {
for _, domain := range domainsToClean {
// Skip the current configured domain
if domain == currentDomain || domain == "."+currentDomain || "."+domain == currentDomain {
@@ -655,7 +660,9 @@ func (sm *SessionManager) CleanupOldCookies(w http.ResponseWriter, r *http.Reque
// Mark cleanup as done for this session manager instance
if !sm.cleanupDone && len(processedCookies) > 0 {
sm.cleanupMutex.Lock()
sm.cleanupDone = true
sm.cleanupMutex.Unlock()
}
}