security: harden data auth and deployment
This commit is contained in:
@@ -159,6 +159,9 @@ def _load_current_user_from_token(
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="User is blocked")
|
||||
if _is_expired(user.get("expires_at")):
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="User access has expired")
|
||||
token_version = payload.get("ver")
|
||||
if not isinstance(token_version, int) or token_version != int(user.get("auth_version") or 1):
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Session has been revoked")
|
||||
|
||||
user = normalize_user_auth_provider(user)
|
||||
from .feature_access import permissions
|
||||
@@ -183,6 +186,7 @@ def _load_current_user_from_token(
|
||||
"is_expired": bool(user.get("is_expired", False)),
|
||||
"password_change_supported": bool(user.get("password_change_supported", False)),
|
||||
"password_provider": user.get("password_provider"),
|
||||
"auth_version": int(user.get("auth_version") or 1),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user