feat: implement sliding session - extend TTL on each authenticated request

This commit is contained in:
Agent Zero
2026-07-18 18:48:21 +02:00
parent b1153e0c54
commit ad41771b10
4 changed files with 25 additions and 2 deletions
+4 -1
View File
@@ -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,