Skip to content

Commit 9489dab

Browse files
committed
fix: case-insensitive admin email matching
ADMIN_EMAILS stored lowercase, auth.email compared lowercase. Prevents rejection when Supabase returns 'Dev@Example.com' but env var has 'dev@example.com'.
1 parent 5ac2caf commit 9489dab

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

backend/routes/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
_VALID_TIERS = {t.value for t in UserTier}
1919

2020
ADMIN_EMAILS = set(
21-
e.strip()
21+
e.strip().lower()
2222
for e in os.getenv("ADMIN_EMAILS", "").split(",")
2323
if e.strip()
2424
)
2525

2626

2727
def require_admin(auth: AuthContext = Depends(require_auth)) -> AuthContext:
2828
"""Dependency that ensures the caller is an admin."""
29-
if not auth.email or auth.email not in ADMIN_EMAILS:
29+
if not auth.email or auth.email.lower() not in ADMIN_EMAILS:
3030
raise HTTPException(status_code=403, detail="Admin access required")
3131
return auth
3232

0 commit comments

Comments
 (0)