feat: implement sliding session - extend TTL on each authenticated request
This commit is contained in:
+4
-1
@@ -10,7 +10,7 @@ from fastapi import Depends, HTTPException, Request, status
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.config import get_settings
|
||||
from app.core.auth import get_redis, get_session_data
|
||||
from app.core.auth import get_redis, get_session_data, refresh_session_ttl
|
||||
from app.core.db import get_db, set_tenant_context
|
||||
|
||||
|
||||
@@ -44,6 +44,9 @@ async def get_current_user(
|
||||
detail={"detail": "Session expired or invalid", "code": "session_invalid"},
|
||||
)
|
||||
|
||||
# Sliding session: extend TTL on each authenticated request
|
||||
await refresh_session_ttl(redis, session_id)
|
||||
|
||||
if not session_data.get("is_active", True):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
|
||||
Reference in New Issue
Block a user