diff --git a/backend/app/dependencies.py b/backend/app/dependencies.py index 001fbab..34d3fff 100644 --- a/backend/app/dependencies.py +++ b/backend/app/dependencies.py @@ -1,7 +1,9 @@ """ FastAPI dependencies for authentication and user-scoped data access. """ -from fastapi import Depends, HTTPException, status +from typing import Optional + +from fastapi import Depends, HTTPException, Query, Request, status from fastapi.security import OAuth2PasswordBearer from jose import JWTError from sqlalchemy import select @@ -45,6 +47,54 @@ async def get_current_user( return user +async def get_current_user_media( + request: Request, + token: Optional[str] = Query(None, alias="token"), + db: AsyncSession = Depends(get_db), +) -> User: + """Authenticate via Authorization header OR ?token= query parameter. + + Used for media endpoints (thumbnails, originals, proxies) where the + URL is set as an or