mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Encapsulate domain list in class
Code shouldn’t be accessing this list directly; the class should provide a sensible interface to the data.
This commit is contained in:
@@ -69,39 +69,6 @@ class Config(object):
|
|||||||
STATSD_HOST = "statsd.hostedgraphite.com"
|
STATSD_HOST = "statsd.hostedgraphite.com"
|
||||||
STATSD_PORT = 8125
|
STATSD_PORT = 8125
|
||||||
NOTIFY_ENVIRONMENT = 'development'
|
NOTIFY_ENVIRONMENT = 'development'
|
||||||
|
|
||||||
EMAIL_DOMAIN_REGEXES = [
|
|
||||||
r"gov\.uk",
|
|
||||||
r"mod\.uk",
|
|
||||||
r"mil\.uk",
|
|
||||||
r"ddc-mod\.org",
|
|
||||||
r"slc\.co\.uk",
|
|
||||||
r"gov\.scot",
|
|
||||||
r"parliament\.uk",
|
|
||||||
r"nhs\.uk",
|
|
||||||
r"nhs\.net",
|
|
||||||
r"police\.uk",
|
|
||||||
r"dclgdatamart\.co\.uk",
|
|
||||||
r"ucds\.email",
|
|
||||||
r"naturalengland\.org\.uk",
|
|
||||||
r"hmcts\.net",
|
|
||||||
r"scotent\.co\.uk",
|
|
||||||
r"assembly\.wales",
|
|
||||||
r"cjsm\.net",
|
|
||||||
r"cqc\.org\.uk",
|
|
||||||
r"bl\.uk",
|
|
||||||
r"stfc\.ac\.uk",
|
|
||||||
r"wmfs\.net",
|
|
||||||
r"bbsrc\.ac\.uk",
|
|
||||||
r"acas\.org\.uk",
|
|
||||||
r"gov\.wales",
|
|
||||||
r"biglotteryfund\.org\.uk",
|
|
||||||
r"marinemanagement\.org\.uk",
|
|
||||||
r"britishmuseum\.org",
|
|
||||||
r"derrystrabane\.com",
|
|
||||||
r"highwaysengland\.co\.uk",
|
|
||||||
]
|
|
||||||
|
|
||||||
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-local'
|
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-local'
|
||||||
ROUTE_SECRET_KEY_1 = os.environ.get('ROUTE_SECRET_KEY_1', '')
|
ROUTE_SECRET_KEY_1 = os.environ.get('ROUTE_SECRET_KEY_1', '')
|
||||||
ROUTE_SECRET_KEY_2 = os.environ.get('ROUTE_SECRET_KEY_2', '')
|
ROUTE_SECRET_KEY_2 = os.environ.get('ROUTE_SECRET_KEY_2', '')
|
||||||
|
|||||||
34
app/utils.py
34
app/utils.py
@@ -438,9 +438,41 @@ class NotGovernmentDomain(Exception):
|
|||||||
|
|
||||||
class GovernmentDomain:
|
class GovernmentDomain:
|
||||||
|
|
||||||
|
domains = [
|
||||||
|
r"gov\.uk",
|
||||||
|
r"mod\.uk",
|
||||||
|
r"mil\.uk",
|
||||||
|
r"ddc-mod\.org",
|
||||||
|
r"slc\.co\.uk",
|
||||||
|
r"gov\.scot",
|
||||||
|
r"parliament\.uk",
|
||||||
|
r"nhs\.uk",
|
||||||
|
r"nhs\.net",
|
||||||
|
r"police\.uk",
|
||||||
|
r"dclgdatamart\.co\.uk",
|
||||||
|
r"ucds\.email",
|
||||||
|
r"naturalengland\.org\.uk",
|
||||||
|
r"hmcts\.net",
|
||||||
|
r"scotent\.co\.uk",
|
||||||
|
r"assembly\.wales",
|
||||||
|
r"cjsm\.net",
|
||||||
|
r"cqc\.org\.uk",
|
||||||
|
r"bl\.uk",
|
||||||
|
r"stfc\.ac\.uk",
|
||||||
|
r"wmfs\.net",
|
||||||
|
r"bbsrc\.ac\.uk",
|
||||||
|
r"acas\.org\.uk",
|
||||||
|
r"gov\.wales",
|
||||||
|
r"biglotteryfund\.org\.uk",
|
||||||
|
r"marinemanagement\.org\.uk",
|
||||||
|
r"britishmuseum\.org",
|
||||||
|
r"derrystrabane\.com",
|
||||||
|
r"highwaysengland\.co\.uk",
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, email_address_or_domain):
|
def __init__(self, email_address_or_domain):
|
||||||
|
|
||||||
for domain in current_app.config['EMAIL_DOMAIN_REGEXES']:
|
for domain in self.domains:
|
||||||
if re.search(
|
if re.search(
|
||||||
r"[\.|@]({})$".format(domain),
|
r"[\.|@]({})$".format(domain),
|
||||||
email_address_or_domain.lower()
|
email_address_or_domain.lower()
|
||||||
|
|||||||
Reference in New Issue
Block a user