@@ -29,9 +29,7 @@ async def demo_search(auth: AuthContext = Depends(public_auth)):
2929from fastapi .security .http import HTTPAuthorizationCredentials
3030
3131
32- # ---------------------------------------------------------------------------
3332# Auth Context - unified return type for all auth methods
34- # ---------------------------------------------------------------------------
3533
3634@dataclass
3735class AuthContext :
@@ -52,17 +50,13 @@ def identifier(self) -> str:
5250 return self .user_id or self .api_key_name or "anonymous"
5351
5452
55- # ---------------------------------------------------------------------------
5653# Bearer token scheme (auto_error=False allows optional auth)
57- # ---------------------------------------------------------------------------
5854
5955_bearer = HTTPBearer (auto_error = False )
6056_bearer_required = HTTPBearer (auto_error = True )
6157
6258
63- # ---------------------------------------------------------------------------
6459# Core validation functions
65- # ---------------------------------------------------------------------------
6660
6761def _validate_jwt (token : str ) -> Optional [AuthContext ]:
6862 """Validate Supabase JWT token"""
@@ -143,9 +137,7 @@ def _authenticate(token: str) -> AuthContext:
143137 )
144138
145139
146- # ---------------------------------------------------------------------------
147140# FastAPI Dependencies - use these in your routes
148- # ---------------------------------------------------------------------------
149141
150142async def require_auth (
151143 credentials : HTTPAuthorizationCredentials = Depends (_bearer_required )
@@ -177,9 +169,7 @@ async def public_auth(
177169 return AuthContext (is_public = True )
178170
179171
180- # ---------------------------------------------------------------------------
181172# Legacy functions - kept for backwards compatibility
182- # ---------------------------------------------------------------------------
183173
184174async def get_current_user (
185175 credentials : HTTPAuthorizationCredentials = Depends (_bearer_required )
0 commit comments