UNI12345 commited on
Commit
db1baa2
·
1 Parent(s): f3c8882

Support Authorization Bearer token fallback for session verification

Browse files
Files changed (1) hide show
  1. app/utils/security.py +6 -0
app/utils/security.py CHANGED
@@ -8,6 +8,12 @@ from app.utils.firebase import verify_session_cookie
8
 
9
  async def get_current_user(request: Request, db: AsyncSession = Depends(get_db)) -> models.User:
10
  session_cookie = request.cookies.get("archvise_session")
 
 
 
 
 
 
11
  if not session_cookie:
12
  raise HTTPException(
13
  status_code=status.HTTP_401_UNAUTHORIZED,
 
8
 
9
  async def get_current_user(request: Request, db: AsyncSession = Depends(get_db)) -> models.User:
10
  session_cookie = request.cookies.get("archvise_session")
11
+ # Fallback to Authorization header if cookie is missing (e.g. cross-domain/proxy environment)
12
+ if not session_cookie:
13
+ auth_header = request.headers.get("Authorization")
14
+ if auth_header and auth_header.startswith("Bearer "):
15
+ session_cookie = auth_header.split(" ")[1]
16
+
17
  if not session_cookie:
18
  raise HTTPException(
19
  status_code=status.HTTP_401_UNAUTHORIZED,