latest
This commit is contained in:
@@ -18,13 +18,14 @@ class SupabaseBearer(HTTPBearer):
|
||||
|
||||
try:
|
||||
token = credentials.credentials
|
||||
payload = verify_supabase_token(token)
|
||||
# Decode using the string-based verifier to avoid async dependency conflicts
|
||||
payload = verify_supabase_jwt_str(token)
|
||||
return payload
|
||||
except Exception as e:
|
||||
logger.error(f"Token verification failed: {str(e)}")
|
||||
raise HTTPException(status_code=403, detail="Invalid token or expired token.")
|
||||
|
||||
def verify_supabase_token(token: str) -> dict:
|
||||
def verify_supabase_jwt_str(token: str) -> dict:
|
||||
"""Verify a Supabase JWT token and return its payload."""
|
||||
try:
|
||||
jwt_secret = os.getenv("JWT_SECRET")
|
||||
@@ -63,7 +64,7 @@ def decodeSupabaseJWT(token: str) -> dict:
|
||||
# Initialize the security instance
|
||||
security = HTTPBearer()
|
||||
|
||||
async def verify_supabase_token(credentials: HTTPAuthorizationCredentials = Depends(security)):
|
||||
async def verify_supabase_token_dep(credentials: HTTPAuthorizationCredentials = Depends(security)):
|
||||
try:
|
||||
token = credentials.credentials
|
||||
# Verify token using your Supabase JWT secret
|
||||
|
||||
Reference in New Issue
Block a user