messy logout fixing
This commit is contained in:
@@ -96,12 +96,34 @@ CSRF_COOKIE_SECURE = USE_SECURE_COOKIES
|
||||
# CRITICAL: Session isolation to prevent contamination
|
||||
SESSION_COOKIE_NAME = 'igny8_sessionid' # Custom name to avoid conflicts
|
||||
SESSION_COOKIE_HTTPONLY = True # Prevent JavaScript access
|
||||
SESSION_COOKIE_SAMESITE = 'Strict' # Prevent cross-site cookie sharing
|
||||
SESSION_COOKIE_AGE = 86400 # 24 hours
|
||||
SESSION_SAVE_EVERY_REQUEST = False # Don't update session on every request (reduces DB load)
|
||||
SESSION_COOKIE_SAMESITE = 'Lax' # Changed from Strict - allows external redirects
|
||||
SESSION_COOKIE_AGE = 1209600 # 14 days (2 weeks)
|
||||
SESSION_SAVE_EVERY_REQUEST = True # Enable sliding window - extends session on activity
|
||||
SESSION_COOKIE_PATH = '/' # Explicit path
|
||||
# Don't set SESSION_COOKIE_DOMAIN - let it default to current domain for strict isolation
|
||||
|
||||
# CRITICAL: Use Redis for session storage (not database)
|
||||
# Provides better performance and automatic expiry
|
||||
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
|
||||
SESSION_CACHE_ALIAS = 'default'
|
||||
|
||||
# Configure Redis cache for sessions
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_redis.cache.RedisCache',
|
||||
'LOCATION': f"redis://{os.getenv('REDIS_HOST', 'redis')}:{os.getenv('REDIS_PORT', '6379')}/1",
|
||||
'OPTIONS': {
|
||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||
'SOCKET_CONNECT_TIMEOUT': 5,
|
||||
'SOCKET_TIMEOUT': 5,
|
||||
'CONNECTION_POOL_KWARGS': {
|
||||
'max_connections': 50,
|
||||
'retry_on_timeout': True
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# CRITICAL: Custom authentication backend to disable user caching
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
'igny8_core.auth.backends.NoCacheModelBackend', # Custom backend without caching
|
||||
@@ -520,7 +542,7 @@ CORS_EXPOSE_HEADERS = [
|
||||
# JWT Configuration
|
||||
JWT_SECRET_KEY = os.getenv('JWT_SECRET_KEY', SECRET_KEY)
|
||||
JWT_ALGORITHM = 'HS256'
|
||||
JWT_ACCESS_TOKEN_EXPIRY = timedelta(minutes=15)
|
||||
JWT_ACCESS_TOKEN_EXPIRY = timedelta(hours=1) # Increased from 15min to 1 hour
|
||||
JWT_REFRESH_TOKEN_EXPIRY = timedelta(days=30) # Extended to 30 days for persistent login
|
||||
|
||||
# Celery Configuration
|
||||
|
||||
Reference in New Issue
Block a user