feat(admin): add is_admin() access guard

Implement access control function for admin panel. Returns True only if
ADMIN_EMAIL env var is set, user is authenticated, and email matches
case-insensitively.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Colin Maudry
2026-07-03 09:41:57 +02:00
parent c4851ff0ae
commit 2f2cd151fb
2 changed files with 54 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import os
from flask_login import current_user
def is_admin() -> bool:
admin_email = os.getenv("ADMIN_EMAIL")
return bool(
admin_email
and current_user.is_authenticated
and current_user.email.lower() == admin_email.lower()
)