From a02223d059d2da58a46891504d5cb8dfe8d1a1fa Mon Sep 17 00:00:00 2001 From: msramalho <19508417+msramalho@users.noreply.github.com> Date: Mon, 6 Mar 2023 15:06:17 +0000 Subject: [PATCH] lower case emails all the way --- src/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index 566c2d5..6ec78bf 100644 --- a/src/main.py +++ b/src/main.py @@ -22,7 +22,7 @@ load_dotenv() # Configuration GOOGLE_CHROME_APP_ID = os.environ.get("GOOGLE_CHROME_APP_ID") assert len(GOOGLE_CHROME_APP_ID)>10, "GOOGLE_CHROME_APP_ID env variable not set" -ALLOWED_EMAILS = set(os.environ.get("ALLOWED_EMAILS", "").split(",")) +ALLOWED_EMAILS = set([e.strip().lower() for e in os.environ.get("ALLOWED_EMAILS", "").split(",")]) assert len(GOOGLE_CHROME_APP_ID)>=1, "at least one ALLOWED_EMAILS is required from the env variable" ALLOWED_ORIGINS = os.environ.get("ALLOWED_ORIGINS", "chrome-extension://ondkcheoicfckabcnkdgbepofpjmjcmb,chrome-extension://ojcimmjndnlmmlgnjaeojoebaceokpdp").split(",") VERSION = "0.1.8" @@ -150,7 +150,7 @@ def authenticate_user(access_token): return False, f"EXCEPTION occurred" def custom_is_email_allowed(email, any_bellingcat_email=False): - return email in ALLOWED_EMAILS or (any_bellingcat_email and re.match(r'^[\w.]+@bellingcat\.com$', email)) + return email.lower() in ALLOWED_EMAILS or (any_bellingcat_email and re.match(r'^[\w.]+@bellingcat\.com$', email)) def validate_user_get_email(access_token): valid_user, info = authenticate_user(access_token)