• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / fx-private-relay / b646eece-29a3-44b1-ba40-4c10c615098a

18 Jun 2024 04:55PM CUT coverage: 84.701% (-0.02%) from 84.716%
b646eece-29a3-44b1-ba40-4c10c615098a

Pull #4796

circleci

groovecoder
for MPP-2822: update gaEvent hook to ping to both GA endpoints
Pull Request #4796: MPP-2822: add gtag to Layout and update gaEvent hook to ping both GA endpoints

3720 of 4857 branches covered (76.59%)

Branch coverage included in aggregate %.

19 of 26 new or added lines in 4 files covered. (73.08%)

25 existing lines in 1 file now uncovered.

15131 of 17399 relevant lines covered (86.96%)

10.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.38
/privaterelay/settings.py
1
"""
2
Django settings for privaterelay project.
3

4
Generated by 'django-admin startproject' using Django 2.2.2.
5

6
For more information on this file, see
7
https://docs.djangoproject.com/en/2.2/topics/settings/
8

9
For the full list of settings and their values, see
10
https://docs.djangoproject.com/en/2.2/ref/settings/
11
"""
12

13
from __future__ import annotations
1✔
14

15
import base64
1✔
16
import ipaddress
1✔
17
import os
1✔
18
import sys
1✔
19
from hashlib import sha256
1✔
20
from pathlib import Path
1✔
21
from typing import TYPE_CHECKING, Any, cast, get_args
1✔
22

23
from django.conf.global_settings import LANGUAGES as DEFAULT_LANGUAGES
1✔
24

25
import dj_database_url
1✔
26
import django_stubs_ext
1✔
27
import markus
1✔
28
import sentry_sdk
1✔
29
from decouple import Choices, Csv, config
1✔
30
from sentry_sdk.integrations.django import DjangoIntegration
1✔
31
from sentry_sdk.integrations.logging import ignore_logger
1✔
32

33
from .types import RELAY_CHANNEL_NAME
1✔
34

35
if TYPE_CHECKING:
36
    import wsgiref.headers
37

38
try:
1✔
39
    # Silk is a live profiling and inspection tool for the Django framework
40
    # https://github.com/jazzband/django-silk
41
    import silk  # noqa: F401
1✔
42

43
    HAS_SILK = True
×
44
except ImportError:
1✔
45
    HAS_SILK = False
1✔
46

47
try:
1✔
48
    import google.cloud.sqlcommenter  # noqa: F401
1✔
49

50
    HAS_SQLCOMMENTER = True
1✔
51
except ImportError:
×
52
    HAS_SQLCOMMENTER = False
×
53

54
try:
1✔
55
    from privaterelay.glean.server_events import GLEAN_EVENT_MOZLOG_TYPE
1✔
56
except ImportError:
×
57
    # File may not be generated yet. Will be checked at initialization
58
    GLEAN_EVENT_MOZLOG_TYPE = "glean-server-event"
×
59

60
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
61
BASE_DIR: str = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1✔
62
TMP_DIR = os.path.join(BASE_DIR, "tmp")
1✔
63
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
1✔
64

65
# Quick-start development settings - unsuitable for production
66
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
67

68
# defaulting to blank to be production-broken by default
69
SECRET_KEY = config("SECRET_KEY", None)
1✔
70
SECRET_KEY_FALLBACKS = config("SECRET_KEY_FALLBACKS", "", cast=Csv())
1✔
71
SITE_ORIGIN: str | None = config("SITE_ORIGIN", None)
1✔
72

73
ORIGIN_CHANNEL_MAP: dict[str, RELAY_CHANNEL_NAME] = {
1✔
74
    "http://127.0.0.1:8000": "local",
75
    "https://dev.fxprivaterelay.nonprod.cloudops.mozgcp.net": "dev",
76
    "https://stage.fxprivaterelay.nonprod.cloudops.mozgcp.net": "stage",
77
    "https://relay.firefox.com": "prod",
78
}
79
RELAY_CHANNEL: RELAY_CHANNEL_NAME = cast(
1✔
80
    RELAY_CHANNEL_NAME,
81
    config(
82
        "RELAY_CHANNEL",
83
        default=ORIGIN_CHANNEL_MAP.get(SITE_ORIGIN or "", "local"),
84
        cast=Choices(get_args(RELAY_CHANNEL_NAME), cast=str),
85
    ),
86
)
87

88
DEBUG = config("DEBUG", False, cast=bool)
1✔
89
if DEBUG:
1!
90
    INTERNAL_IPS = config("DJANGO_INTERNAL_IPS", default="", cast=Csv())
1✔
91
IN_PYTEST: bool = "pytest" in sys.modules
1✔
92
USE_SILK = DEBUG and HAS_SILK and not IN_PYTEST
1✔
93

94
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
95
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
1✔
96
SECURE_SSL_HOST = config("DJANGO_SECURE_SSL_HOST", None)
1✔
97
SECURE_SSL_REDIRECT = config("DJANGO_SECURE_SSL_REDIRECT", False, cast=bool)
1✔
98
SECURE_REDIRECT_EXEMPT = [
1✔
99
    r"^__version__",
100
    r"^__heartbeat__",
101
    r"^__lbheartbeat__",
102
]
103
SECURE_HSTS_INCLUDE_SUBDOMAINS = config(
1✔
104
    "DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", False, cast=bool
105
)
106
SECURE_HSTS_PRELOAD = config("DJANGO_SECURE_HSTS_PRELOAD", False, cast=bool)
1✔
107
SECURE_HSTS_SECONDS = config("DJANGO_SECURE_HSTS_SECONDS", None)
1✔
108
SECURE_BROWSER_XSS_FILTER = config("DJANGO_SECURE_BROWSER_XSS_FILTER", True)
1✔
109
SESSION_COOKIE_SECURE = config("DJANGO_SESSION_COOKIE_SECURE", False, cast=bool)
1✔
110
CSRF_COOKIE_SECURE = config("DJANGO_CSRF_COOKIE_SECURE", False, cast=bool)
1✔
111

112
#
113
# Setup CSP
114
#
115

116
BASKET_ORIGIN = config("BASKET_ORIGIN", "https://basket.mozilla.org")
1✔
117

118
# maps FxA / Mozilla account profile hosts to respective hosts for CSP
119
FXA_BASE_ORIGIN: str = config("FXA_BASE_ORIGIN", "https://accounts.firefox.com")
1✔
120
if FXA_BASE_ORIGIN == "https://accounts.firefox.com":
1!
121
    _AVATAR_IMG_SRC = [
×
122
        "firefoxusercontent.com",
123
        "https://profile.accounts.firefox.com",
124
    ]
125
    _ACCOUNT_CONNECT_SRC = [FXA_BASE_ORIGIN]
×
126
else:
127
    if not FXA_BASE_ORIGIN == "https://accounts.stage.mozaws.net":
1!
128
        raise ValueError(
×
129
            "FXA_BASE_ORIGIN must be either https://accounts.firefox.com or https://accounts.stage.mozaws.net"
130
        )
131
    _AVATAR_IMG_SRC = [
1✔
132
        "mozillausercontent.com",
133
        "https://profile.stage.mozaws.net",
134
    ]
135
    _ACCOUNT_CONNECT_SRC = [
1✔
136
        FXA_BASE_ORIGIN,
137
        # fxaFlowTracker.ts will try this if runtimeData is slow
138
        "https://accounts.firefox.com",
139
    ]
140

141
API_DOCS_ENABLED = config("API_DOCS_ENABLED", False, cast=bool) or DEBUG
1✔
142
_CSP_SCRIPT_INLINE = API_DOCS_ENABLED or USE_SILK
1✔
143

144
# When running locally, styles might get refreshed while the server is running, so their
145
# hashes would get oudated. Hence, we just allow all of them.
146
_CSP_STYLE_INLINE = API_DOCS_ENABLED or RELAY_CHANNEL == "local"
1✔
147

148
if API_DOCS_ENABLED:
1!
149
    _API_DOCS_CSP_IMG_SRC = ["data:", "https://cdn.redoc.ly"]
1✔
150
    _API_DOCS_CSP_STYLE_SRC = ["https://fonts.googleapis.com"]
1✔
151
    _API_DOCS_CSP_FONT_SRC = ["https://fonts.gstatic.com"]
1✔
152
    _API_DOCS_CSP_WORKER_SRC = ["blob:"]
1✔
153
else:
154
    _API_DOCS_CSP_IMG_SRC = []
×
155
    _API_DOCS_CSP_STYLE_SRC = []
×
156
    _API_DOCS_CSP_FONT_SRC = []
×
157
    _API_DOCS_CSP_WORKER_SRC = []
×
158

159
# Next.js dynamically inserts the relevant styles when switching pages,
160
# by injecting them as inline styles. We need to explicitly allow those styles
161
# in our Content Security Policy.
162
_CSP_STYLE_HASHES: list[str] = []
1✔
163
if _CSP_STYLE_INLINE:
1!
164
    # 'unsafe-inline' is not compatible with hash sources
165
    _CSP_STYLE_HASHES = []
1✔
166
else:
167
    # When running in production, we want to disallow inline styles that are
168
    # not set by us, so we use an explicit allowlist with the hashes of the
169
    # styles generated by Next.js.
170
    _next_css_path = Path(STATIC_ROOT) / "_next" / "static" / "css"
×
171
    for path in _next_css_path.glob("*.css"):
×
172
        # Use sha256 hashes, to keep in sync with Chrome.
173
        # When CSP rules fail in Chrome, it provides the sha256 hash that would
174
        # have matched, useful for debugging.
175
        content = open(path, "rb").read()
×
176
        the_hash = base64.b64encode(sha256(content).digest()).decode()
×
177
        _CSP_STYLE_HASHES.append(f"'sha256-{the_hash}'")
×
178
    _CSP_STYLE_HASHES.sort()
×
179

180
    # Add the hash for an empty string (sha256-47DEQp...)
181
    # next,js injects an empty style element and then adds the content.
182
    # This hash avoids a spurious CSP error.
183
    empty_hash = base64.b64encode(sha256().digest()).decode()
×
184
    _CSP_STYLE_HASHES.append(f"'sha256-{empty_hash}'")
×
185

186
CSP_DEFAULT_SRC = ["'self'"]
1✔
187
CSP_CONNECT_SRC = [
1✔
188
    "'self'",
189
    "https://www.google-analytics.com/",
190
    "https://location.services.mozilla.com",
191
    "https://api.stripe.com",
192
    BASKET_ORIGIN,
193
] + _ACCOUNT_CONNECT_SRC
194
CSP_FONT_SRC = ["'self'"] + _API_DOCS_CSP_FONT_SRC + ["https://relay.firefox.com/"]
1✔
195
CSP_IMG_SRC = ["'self'"] + _AVATAR_IMG_SRC + _API_DOCS_CSP_IMG_SRC
1✔
196
CSP_SCRIPT_SRC = (
1✔
197
    ["'self'"]
198
    + (["'unsafe-inline'"] if _CSP_SCRIPT_INLINE else [])
199
    + [
200
        "https://www.google-analytics.com/",
201
        "https://js.stripe.com/",
202
    ]
203
)
204
CSP_WORKER_SRC = _API_DOCS_CSP_WORKER_SRC or None
1✔
205
CSP_OBJECT_SRC = ["'none'"]
1✔
206
CSP_FRAME_SRC = ["https://js.stripe.com", "https://hooks.stripe.com"]
1✔
207
CSP_STYLE_SRC = (
1✔
208
    ["'self'"]
209
    + (["'unsafe-inline'"] if _CSP_STYLE_INLINE else [])
210
    + _API_DOCS_CSP_STYLE_SRC
211
    + _CSP_STYLE_HASHES
212
)
213
CSP_REPORT_URI = config("CSP_REPORT_URI", "")
1✔
214

215
REFERRER_POLICY = "strict-origin-when-cross-origin"
1✔
216

217
ALLOWED_HOSTS: list[str] = []
1✔
218
DJANGO_ALLOWED_HOSTS = config("DJANGO_ALLOWED_HOST", "", cast=Csv())
1✔
219
if DJANGO_ALLOWED_HOSTS:
1!
UNCOV
220
    ALLOWED_HOSTS += DJANGO_ALLOWED_HOSTS
×
221
DJANGO_ALLOWED_SUBNET = config("DJANGO_ALLOWED_SUBNET", None)
1✔
222
if DJANGO_ALLOWED_SUBNET:
1!
UNCOV
223
    ALLOWED_HOSTS += [str(ip) for ip in ipaddress.IPv4Network(DJANGO_ALLOWED_SUBNET)]
×
224

225

226
# Get our backing resource configs to check if we should install the app
227
ADMIN_ENABLED = config("ADMIN_ENABLED", False, cast=bool)
1✔
228

229

230
AWS_REGION: str | None = config("AWS_REGION", None)
1✔
231
AWS_ACCESS_KEY_ID = config("AWS_ACCESS_KEY_ID", None)
1✔
232
AWS_SECRET_ACCESS_KEY = config("AWS_SECRET_ACCESS_KEY", None)
1✔
233
AWS_SNS_TOPIC = set(config("AWS_SNS_TOPIC", "", cast=Csv()))
1✔
234
AWS_SNS_KEY_CACHE = config("AWS_SNS_KEY_CACHE", "default")
1✔
235
AWS_SES_CONFIGSET: str | None = config("AWS_SES_CONFIGSET", None)
1✔
236
AWS_SQS_EMAIL_QUEUE_URL = config("AWS_SQS_EMAIL_QUEUE_URL", None)
1✔
237
AWS_SQS_EMAIL_DLQ_URL = config("AWS_SQS_EMAIL_DLQ_URL", None)
1✔
238

239
# Dead-Letter Queue (DLQ) for SNS push subscription
240
AWS_SQS_QUEUE_URL = config("AWS_SQS_QUEUE_URL", None)
1✔
241

242
RELAY_FROM_ADDRESS: str | None = config("RELAY_FROM_ADDRESS", None)
1✔
243
GOOGLE_ANALYTICS_ID = config("GOOGLE_ANALYTICS_ID", None)
1✔
244
GA4_MEASUREMENT_ID = config("GA4_MEASUREMENT_ID", None)
1✔
245
GOOGLE_APPLICATION_CREDENTIALS: str = config("GOOGLE_APPLICATION_CREDENTIALS", "")
1✔
246
GOOGLE_CLOUD_PROFILER_CREDENTIALS_B64: str = config(
1✔
247
    "GOOGLE_CLOUD_PROFILER_CREDENTIALS_B64", ""
248
)
249
INCLUDE_VPN_BANNER = config("INCLUDE_VPN_BANNER", False, cast=bool)
1✔
250
RECRUITMENT_BANNER_LINK = config("RECRUITMENT_BANNER_LINK", None)
1✔
251
RECRUITMENT_BANNER_TEXT = config("RECRUITMENT_BANNER_TEXT", None)
1✔
252
RECRUITMENT_EMAIL_BANNER_TEXT = config("RECRUITMENT_EMAIL_BANNER_TEXT", None)
1✔
253
RECRUITMENT_EMAIL_BANNER_LINK = config("RECRUITMENT_EMAIL_BANNER_LINK", None)
1✔
254

255
PHONES_ENABLED: bool = config("PHONES_ENABLED", False, cast=bool)
1✔
256
PHONES_NO_CLIENT_CALLS_IN_TEST = False  # Override in tests that do not test clients
1✔
257
TWILIO_ACCOUNT_SID: str | None = config("TWILIO_ACCOUNT_SID", None)
1✔
258
TWILIO_AUTH_TOKEN: str | None = config("TWILIO_AUTH_TOKEN", None)
1✔
259
TWILIO_MAIN_NUMBER: str | None = config("TWILIO_MAIN_NUMBER", None)
1✔
260
TWILIO_SMS_APPLICATION_SID: str | None = config("TWILIO_SMS_APPLICATION_SID", None)
1✔
261
TWILIO_MESSAGING_SERVICE_SID: list[str] = config(
1✔
262
    "TWILIO_MESSAGING_SERVICE_SID", "", cast=Csv()
263
)
264
TWILIO_TEST_ACCOUNT_SID: str | None = config("TWILIO_TEST_ACCOUNT_SID", None)
1✔
265
TWILIO_TEST_AUTH_TOKEN: str | None = config("TWILIO_TEST_AUTH_TOKEN", None)
1✔
266
TWILIO_ALLOWED_COUNTRY_CODES = {
1✔
267
    code.upper() for code in config("TWILIO_ALLOWED_COUNTRY_CODES", "US,CA", cast=Csv())
268
}
269
MAX_MINUTES_TO_VERIFY_REAL_PHONE: int = config(
1✔
270
    "MAX_MINUTES_TO_VERIFY_REAL_PHONE", 5, cast=int
271
)
272
MAX_TEXTS_PER_BILLING_CYCLE: int = config("MAX_TEXTS_PER_BILLING_CYCLE", 75, cast=int)
1✔
273
MAX_MINUTES_PER_BILLING_CYCLE: int = config(
1✔
274
    "MAX_MINUTES_PER_BILLING_CYCLE", 50, cast=int
275
)
276
DAYS_PER_BILLING_CYCLE = config("DAYS_PER_BILLING_CYCLE", 30, cast=int)
1✔
277
MAX_DAYS_IN_MONTH = 31
1✔
278
IQ_ENABLED = config("IQ_ENABLED", False, cast=bool)
1✔
279
IQ_FOR_VERIFICATION: bool = config("IQ_FOR_VERIFICATION", False, cast=bool)
1✔
280
IQ_FOR_NEW_NUMBERS = config("IQ_FOR_NEW_NUMBERS", False, cast=bool)
1✔
281
IQ_MAIN_NUMBER: str = config("IQ_MAIN_NUMBER", "")
1✔
282
IQ_OUTBOUND_API_KEY: str = config("IQ_OUTBOUND_API_KEY", "")
1✔
283
IQ_INBOUND_API_KEY = config("IQ_INBOUND_API_KEY", "")
1✔
284
IQ_MESSAGE_API_ORIGIN = config(
1✔
285
    "IQ_MESSAGE_API_ORIGIN", "https://messagebroker.inteliquent.com"
286
)
287
IQ_MESSAGE_PATH = "/msgbroker/rest/publishMessages"
1✔
288
IQ_PUBLISH_MESSAGE_URL: str = f"{IQ_MESSAGE_API_ORIGIN}{IQ_MESSAGE_PATH}"
1✔
289

290
DJANGO_STATSD_ENABLED = config("DJANGO_STATSD_ENABLED", False, cast=bool)
1✔
291
STATSD_DEBUG = config("STATSD_DEBUG", False, cast=bool)
1✔
292
STATSD_ENABLED: bool = DJANGO_STATSD_ENABLED or STATSD_DEBUG
1✔
293
STATSD_HOST = config("DJANGO_STATSD_HOST", "127.0.0.1")
1✔
294
STATSD_PORT = config("DJANGO_STATSD_PORT", "8125")
1✔
295
STATSD_PREFIX = config("DJANGO_STATSD_PREFIX", "fx.private.relay")
1✔
296

297
SERVE_ADDON = config("SERVE_ADDON", None)
1✔
298

299
# Application definition
300
INSTALLED_APPS = [
1✔
301
    "whitenoise.runserver_nostatic",
302
    "django.contrib.staticfiles",
303
    "django.contrib.auth",
304
    "django.contrib.contenttypes",
305
    "django.contrib.sessions",
306
    "django.contrib.messages",
307
    "django.contrib.sites",
308
    "django_filters",
309
    "django_ftl.apps.DjangoFtlConfig",
310
    "dockerflow.django",
311
    "allauth",
312
    "allauth.account",
313
    "allauth.socialaccount",
314
    "allauth.socialaccount.providers.fxa",
315
    "rest_framework",
316
    "rest_framework.authtoken",
317
    "corsheaders",
318
    "waffle",
319
    "privaterelay.apps.PrivateRelayConfig",
320
    "api.apps.ApiConfig",
321
]
322

323
if API_DOCS_ENABLED:
1!
324
    INSTALLED_APPS += [
1✔
325
        "drf_spectacular",
326
        "drf_spectacular_sidecar",
327
    ]
328

329
if DEBUG:
1!
330
    INSTALLED_APPS += [
1✔
331
        "debug_toolbar",
332
    ]
333

334
if USE_SILK:
1!
UNCOV
335
    INSTALLED_APPS.append("silk")
×
336

337
if ADMIN_ENABLED:
1!
UNCOV
338
    INSTALLED_APPS += [
×
339
        "django.contrib.admin",
340
    ]
341

342
if AWS_SES_CONFIGSET and AWS_SNS_TOPIC:
1!
343
    INSTALLED_APPS += [
1✔
344
        "emails.apps.EmailsConfig",
345
    ]
346

347
if PHONES_ENABLED:
1!
348
    INSTALLED_APPS += [
1✔
349
        "phones.apps.PhonesConfig",
350
    ]
351

352

353
MIDDLEWARE = ["privaterelay.middleware.ResponseMetrics"]
1✔
354

355
if USE_SILK:
1!
UNCOV
356
    MIDDLEWARE.append("silk.middleware.SilkyMiddleware")
×
357
if DEBUG:
1!
358
    MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")
1✔
359

360
MIDDLEWARE += [
1✔
361
    "django.middleware.security.SecurityMiddleware",
362
    "csp.middleware.CSPMiddleware",
363
    "privaterelay.middleware.RedirectRootIfLoggedIn",
364
    "privaterelay.middleware.RelayStaticFilesMiddleware",
365
    "django.contrib.sessions.middleware.SessionMiddleware",
366
    "corsheaders.middleware.CorsMiddleware",
367
    "django.middleware.common.CommonMiddleware",
368
    "django.middleware.csrf.CsrfViewMiddleware",
369
    "django.contrib.auth.middleware.AuthenticationMiddleware",
370
    "django.contrib.messages.middleware.MessageMiddleware",
371
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
372
    "django.middleware.locale.LocaleMiddleware",
373
    "allauth.account.middleware.AccountMiddleware",
374
    "django_ftl.middleware.activate_from_request_language_code",
375
    "django_referrer_policy.middleware.ReferrerPolicyMiddleware",
376
    "dockerflow.django.middleware.DockerflowMiddleware",
377
    "waffle.middleware.WaffleMiddleware",
378
    "privaterelay.middleware.AddDetectedCountryToRequestAndResponseHeaders",
379
    "privaterelay.middleware.StoreFirstVisit",
380
]
381

382
if HAS_SQLCOMMENTER:
1!
383
    MIDDLEWARE.append("google.cloud.sqlcommenter.django.middleware.SqlCommenter")
1✔
384

385
ROOT_URLCONF = "privaterelay.urls"
1✔
386

387
TEMPLATES = [
1✔
388
    {
389
        "BACKEND": "django.template.backends.django.DjangoTemplates",
390
        "DIRS": [
391
            os.path.join(BASE_DIR, "privaterelay", "templates"),
392
        ],
393
        "APP_DIRS": True,
394
        "OPTIONS": {
395
            "context_processors": [
396
                "django.template.context_processors.debug",
397
                "django.template.context_processors.request",
398
                "django.contrib.auth.context_processors.auth",
399
                "django.contrib.messages.context_processors.messages",
400
            ],
401
        },
402
    },
403
]
404

405
RELAY_FIREFOX_DOMAIN: str = config("RELAY_FIREFOX_DOMAIN", "relay.firefox.com")
1✔
406
MOZMAIL_DOMAIN: str = config("MOZMAIL_DOMAIN", "mozmail.com")
1✔
407
MAX_NUM_FREE_ALIASES: int = config("MAX_NUM_FREE_ALIASES", 5, cast=int)
1✔
408
PERIODICAL_PREMIUM_PROD_ID: str = config("PERIODICAL_PREMIUM_PROD_ID", "")
1✔
409
PREMIUM_PLAN_ID_US_MONTHLY: str = config(
1✔
410
    "PREMIUM_PLAN_ID_US_MONTHLY", "price_1LXUcnJNcmPzuWtRpbNOajYS"
411
)
412
PREMIUM_PLAN_ID_US_YEARLY: str = config(
1✔
413
    "PREMIUM_PLAN_ID_US_YEARLY", "price_1LXUdlJNcmPzuWtRKTYg7mpZ"
414
)
415
PHONE_PROD_ID = config("PHONE_PROD_ID", "")
1✔
416
PHONE_PLAN_ID_US_MONTHLY: str = config(
1✔
417
    "PHONE_PLAN_ID_US_MONTHLY", "price_1Li0w8JNcmPzuWtR2rGU80P3"
418
)
419
PHONE_PLAN_ID_US_YEARLY: str = config(
1✔
420
    "PHONE_PLAN_ID_US_YEARLY", "price_1Li15WJNcmPzuWtRIh0F4VwP"
421
)
422
BUNDLE_PROD_ID = config("BUNDLE_PROD_ID", "")
1✔
423
BUNDLE_PLAN_ID_US: str = config("BUNDLE_PLAN_ID_US", "price_1LwoSDJNcmPzuWtR6wPJZeoh")
1✔
424

425
SUBSCRIPTIONS_WITH_UNLIMITED: list[str] = config(
1✔
426
    "SUBSCRIPTIONS_WITH_UNLIMITED", default="", cast=Csv()
427
)
428
SUBSCRIPTIONS_WITH_PHONE: list[str] = config(
1✔
429
    "SUBSCRIPTIONS_WITH_PHONE", default="", cast=Csv()
430
)
431
SUBSCRIPTIONS_WITH_VPN: list[str] = config(
1✔
432
    "SUBSCRIPTIONS_WITH_VPN", default="", cast=Csv()
433
)
434

435
MAX_ONBOARDING_AVAILABLE = config("MAX_ONBOARDING_AVAILABLE", 0, cast=int)
1✔
436
MAX_ONBOARDING_FREE_AVAILABLE = config("MAX_ONBOARDING_FREE_AVAILABLE", 3, cast=int)
1✔
437

438
MAX_ADDRESS_CREATION_PER_DAY = config("MAX_ADDRESS_CREATION_PER_DAY", 100, cast=int)
1✔
439
MAX_REPLIES_PER_DAY = config("MAX_REPLIES_PER_DAY", 100, cast=int)
1✔
440
MAX_FORWARDED_PER_DAY = config("MAX_FORWARDED_PER_DAY", 1000, cast=int)
1✔
441
MAX_FORWARDED_EMAIL_SIZE_PER_DAY = config(
1✔
442
    "MAX_FORWARDED_EMAIL_SIZE_PER_DAY", 1_000_000_000, cast=int
443
)
444
PREMIUM_FEATURE_PAUSED_DAYS: int = config(
1✔
445
    "ACCOUNT_PREMIUM_FEATURE_PAUSED_DAYS", 1, cast=int
446
)
447

448
SOFT_BOUNCE_ALLOWED_DAYS: int = config("SOFT_BOUNCE_ALLOWED_DAYS", 1, cast=int)
1✔
449
HARD_BOUNCE_ALLOWED_DAYS: int = config("HARD_BOUNCE_ALLOWED_DAYS", 30, cast=int)
1✔
450

451
WSGI_APPLICATION = "privaterelay.wsgi.application"
1✔
452

453
# Database
454
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
455

456
DATABASES = {
1✔
457
    "default": dj_database_url.config(
458
        default="sqlite:///{}".format(os.path.join(BASE_DIR, "db.sqlite3"))
459
    )
460
}
461
# Optionally set a test database name.
462
# This is useful for forcing an on-disk database for SQLite.
463
TEST_DB_NAME = config("TEST_DB_NAME", "")
1✔
464
if TEST_DB_NAME:
1!
UNCOV
465
    DATABASES["default"]["TEST"] = {"NAME": TEST_DB_NAME}
×
466

467
REDIS_URL = config("REDIS_URL", "")
1✔
468
if REDIS_URL:
1!
UNCOV
469
    CACHES = {
×
470
        "default": {
471
            "BACKEND": "django_redis.cache.RedisCache",
472
            "LOCATION": REDIS_URL,
473
            "OPTIONS": {
474
                "CLIENT_CLASS": "django_redis.client.DefaultClient",
475
            },
476
        }
477
    }
UNCOV
478
    SESSION_ENGINE = "django.contrib.sessions.backends.cache"
×
UNCOV
479
    SESSION_CACHE_ALIAS = "default"
×
480
elif RELAY_CHANNEL == "local":
1!
481
    CACHES = {
1✔
482
        "default": {
483
            "BACKEND": "django.core.cache.backends.locmem.LocMemCache",
484
        }
485
    }
486

487
# Password validation
488
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
489
# only needed when admin UI is enabled
490
if ADMIN_ENABLED:
1!
UNCOV
491
    _DJANGO_PWD_VALIDATION = "django.contrib.auth.password_validation"  # noqa: E501, S105 (long line, possible password)
×
UNCOV
492
    AUTH_PASSWORD_VALIDATORS = [
×
493
        {"NAME": _DJANGO_PWD_VALIDATION + ".UserAttributeSimilarityValidator"},
494
        {"NAME": _DJANGO_PWD_VALIDATION + ".MinimumLengthValidator"},
495
        {"NAME": _DJANGO_PWD_VALIDATION + ".CommonPasswordValidator"},
496
        {"NAME": _DJANGO_PWD_VALIDATION + ".NumericPasswordValidator"},
497
    ]
498

499

500
# Internationalization
501
# https://docs.djangoproject.com/en/2.2/topics/i18n/
502

503
LANGUAGE_CODE = "en"
1✔
504

505
# Mozilla l10n directories use lang-locale language codes,
506
# so we need to add those to LANGUAGES so Django's LocaleMiddleware
507
# can find them.
508
LANGUAGES = DEFAULT_LANGUAGES + [
1✔
509
    ("zh-tw", "Chinese"),
510
    ("zh-cn", "Chinese"),
511
    ("es-es", "Spanish"),
512
    ("pt-pt", "Portuguese"),
513
    ("skr", "Saraiki"),
514
]
515

516
TIME_ZONE = "UTC"
1✔
517

518
USE_I18N = True
1✔
519

520

521
USE_TZ = True
1✔
522

523
STATICFILES_DIRS = [
1✔
524
    os.path.join(BASE_DIR, "frontend/out"),
525
]
526
# Static files (the front-end in /frontend/)
527
# https://whitenoise.evans.io/en/stable/django.html#using-whitenoise-with-webpack-browserify-latest-js-thing
528
STATIC_URL = "/"
1✔
529
if DEBUG:
1!
530
    # In production, we run collectstatic to index all static files.
531
    # However, when running locally, we want to automatically pick up
532
    # all files spewed out by `npm run watch` in /frontend/out,
533
    # and we're fine with the performance impact of that.
534
    WHITENOISE_ROOT = os.path.join(BASE_DIR, "frontend/out")
1✔
535
STORAGES = {
1✔
536
    "default": {
537
        "BACKEND": "django.core.files.storage.FileSystemStorage",
538
    },
539
    "staticfiles": {
540
        "BACKEND": "privaterelay.storage.RelayStaticFilesStorage",
541
    },
542
}
543

544
# Relay does not support user-uploaded files
545
MEDIA_ROOT = None
1✔
546
MEDIA_URL = None
1✔
547

548
WHITENOISE_INDEX_FILE = True
1✔
549

550

551
# See
552
# https://whitenoise.evans.io/en/stable/django.html#WHITENOISE_ADD_HEADERS_FUNCTION
553
# Intended to ensure that the homepage does not get cached in our CDN,
554
# so that the `RedirectRootIfLoggedIn` middleware can kick in for logged-in
555
# users.
556
def set_index_cache_control_headers(
1✔
557
    headers: wsgiref.headers.Headers, path: str, url: str
558
) -> None:
559
    if DEBUG:
1!
560
        home_path = os.path.join(BASE_DIR, "frontend/out", "index.html")
1✔
561
    else:
UNCOV
562
        home_path = os.path.join(STATIC_ROOT, "index.html")
×
563
    if path == home_path:
1✔
564
        headers["Cache-Control"] = "no-cache, public"
1✔
565

566

567
WHITENOISE_ADD_HEADERS_FUNCTION = set_index_cache_control_headers
1✔
568

569
SITE_ID = 1
1✔
570

571
AUTHENTICATION_BACKENDS = (
1✔
572
    "django.contrib.auth.backends.ModelBackend",
573
    "allauth.account.auth_backends.AuthenticationBackend",
574
)
575

576
SOCIALACCOUNT_PROVIDERS = {
1✔
577
    "fxa": {
578
        # Note: to request "profile" scope, must be a trusted Mozilla client
579
        "SCOPE": ["profile", "https://identity.mozilla.com/account/subscriptions"],
580
        "AUTH_PARAMS": {"access_type": "offline"},
581
        "OAUTH_ENDPOINT": config(
582
            "FXA_OAUTH_ENDPOINT", "https://oauth.accounts.firefox.com/v1"
583
        ),
584
        "PROFILE_ENDPOINT": config(
585
            "FXA_PROFILE_ENDPOINT", "https://profile.accounts.firefox.com/v1"
586
        ),
587
        "VERIFIED_EMAIL": True,  # Assume FxA primary email is verified
588
    }
589
}
590

591
SOCIALACCOUNT_EMAIL_VERIFICATION = "none"
1✔
592
SOCIALACCOUNT_AUTO_SIGNUP = True
1✔
593
SOCIALACCOUNT_LOGIN_ON_GET = True
1✔
594
SOCIALACCOUNT_STORE_TOKENS = True
1✔
595

596
ACCOUNT_ADAPTER = "privaterelay.allauth.AccountAdapter"
1✔
597
ACCOUNT_PRESERVE_USERNAME_CASING = False
1✔
598
ACCOUNT_USERNAME_REQUIRED = False
1✔
599

600
FXA_REQUESTS_TIMEOUT_SECONDS = config("FXA_REQUESTS_TIMEOUT_SECONDS", 1, cast=int)
1✔
601
FXA_SETTINGS_URL = config("FXA_SETTINGS_URL", f"{FXA_BASE_ORIGIN}/settings")
1✔
602
FXA_SUBSCRIPTIONS_URL = config(
1✔
603
    "FXA_SUBSCRIPTIONS_URL", f"{FXA_BASE_ORIGIN}/subscriptions"
604
)
605
# check https://mozilla.github.io/ecosystem-platform/api#tag/Subscriptions/operation/getOauthMozillasubscriptionsCustomerBillingandsubscriptions  # noqa: E501 (line too long)
606
FXA_ACCOUNTS_ENDPOINT = config(
1✔
607
    "FXA_ACCOUNTS_ENDPOINT",
608
    "https://api.accounts.firefox.com/v1",
609
)
610
FXA_SUPPORT_URL = config("FXA_SUPPORT_URL", f"{FXA_BASE_ORIGIN}/support/")
1✔
611

612
LOGGING = {
1✔
613
    "version": 1,
614
    "filters": {
615
        "request_id": {
616
            "()": "dockerflow.logging.RequestIdLogFilter",
617
        },
618
    },
619
    "formatters": {
620
        "json": {
621
            "()": "dockerflow.logging.JsonLogFormatter",
622
            "logger_name": "fx-private-relay",
623
        }
624
    },
625
    "handlers": {
626
        "console_out": {
627
            "level": "DEBUG",
628
            "class": "logging.StreamHandler",
629
            "stream": sys.stdout,
630
            "formatter": "json",
631
            "filters": ["request_id"],
632
        },
633
        "console_err": {
634
            "level": "DEBUG",
635
            "class": "logging.StreamHandler",
636
            "formatter": "json",
637
            "filters": ["request_id"],
638
        },
639
    },
640
    "loggers": {
641
        "root": {
642
            "handlers": ["console_err"],
643
            "level": "WARNING",
644
        },
645
        "request.summary": {
646
            "handlers": ["console_out"],
647
            "level": "DEBUG",
648
            # pytest's caplog fixture requires propagate=True
649
            # outside of pytest, use propagate=False to avoid double logs
650
            "propagate": IN_PYTEST,
651
        },
652
        "events": {
653
            "handlers": ["console_err"],
654
            "level": "WARNING",
655
            "propagate": IN_PYTEST,
656
        },
657
        "eventsinfo": {
658
            "handlers": ["console_out"],
659
            "level": "INFO",
660
            "propagate": IN_PYTEST,
661
        },
662
        "abusemetrics": {
663
            "handlers": ["console_out"],
664
            "level": "INFO",
665
            "propagate": IN_PYTEST,
666
        },
667
        "studymetrics": {
668
            "handlers": ["console_out"],
669
            "level": "INFO",
670
            "propagate": IN_PYTEST,
671
        },
672
        "markus": {
673
            "handlers": ["console_out"],
674
            "level": "DEBUG",
675
            "propagate": IN_PYTEST,
676
        },
677
        GLEAN_EVENT_MOZLOG_TYPE: {
678
            "handlers": ["console_out"],
679
            "level": "DEBUG",
680
            "propagate": IN_PYTEST,
681
        },
682
        "dockerflow": {
683
            "handlers": ["console_err"],
684
            "level": "WARNING",
685
            "propagate": IN_PYTEST,
686
        },
687
    },
688
}
689

690
DRF_RENDERERS = ["rest_framework.renderers.JSONRenderer"]
1✔
691
if DEBUG and not IN_PYTEST:
1!
UNCOV
692
    DRF_RENDERERS += [
×
693
        "rest_framework.renderers.BrowsableAPIRenderer",
694
    ]
695

696
FIRST_EMAIL_RATE_LIMIT = config("FIRST_EMAIL_RATE_LIMIT", "5/minute")
1✔
697
if IN_PYTEST or RELAY_CHANNEL in ["local", "dev"]:
1!
698
    FIRST_EMAIL_RATE_LIMIT = "1000/minute"
1✔
699

700
REST_FRAMEWORK = {
1✔
701
    "DEFAULT_AUTHENTICATION_CLASSES": [
702
        "api.authentication.FxaTokenAuthentication",
703
        "rest_framework.authentication.TokenAuthentication",
704
        "rest_framework.authentication.SessionAuthentication",
705
    ],
706
    "DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated"],
707
    "DEFAULT_RENDERER_CLASSES": DRF_RENDERERS,
708
    "DEFAULT_FILTER_BACKENDS": ["django_filters.rest_framework.DjangoFilterBackend"],
709
    "EXCEPTION_HANDLER": "api.views.relay_exception_handler",
710
}
711
if API_DOCS_ENABLED:
1!
712
    REST_FRAMEWORK["DEFAULT_SCHEMA_CLASS"] = "drf_spectacular.openapi.AutoSchema"
1✔
713

714
SPECTACULAR_SETTINGS = {
1✔
715
    "SWAGGER_UI_DIST": "SIDECAR",
716
    "SWAGGER_UI_FAVICON_HREF": "SIDECAR",
717
    "REDOC_DIST": "SIDECAR",
718
    "TITLE": "Firefox Relay API",
719
    "DESCRIPTION": (
720
        "Keep your email safe from hackers and trackers. This API is built with"
721
        " Django REST Framework and powers the Relay website UI, add-on,"
722
        " Firefox browser, and 3rd-party app integrations."
723
    ),
724
    "VERSION": "1.0",
725
    "SERVE_INCLUDE_SCHEMA": False,
726
    "PREPROCESSING_HOOKS": ["api.schema.preprocess_ignore_deprecated_paths"],
727
    "SORT_OPERATIONS": "api.schema.sort_by_tag",
728
}
729

730
if IN_PYTEST or RELAY_CHANNEL in ["local", "dev"]:
1!
731
    _DEFAULT_PHONE_RATE_LIMIT = "1000/minute"
1✔
732
else:
UNCOV
733
    _DEFAULT_PHONE_RATE_LIMIT = "5/minute"
×
734
PHONE_RATE_LIMIT = config("PHONE_RATE_LIMIT", _DEFAULT_PHONE_RATE_LIMIT)
1✔
735

736
# Turn on logging out on GET in development.
737
# This allows `/mock/logout/` in the front-end to clear the
738
# session cookie. Without this, after switching accounts in dev mode,
739
# then logging out again, API requests continue succeeding even without
740
# an auth token:
741
ACCOUNT_LOGOUT_ON_GET = DEBUG
1✔
742

743
# TODO: introduce an environment variable to control CORS_ALLOWED_ORIGINS
744
# https://mozilla-hub.atlassian.net/browse/MPP-3468
745
CORS_URLS_REGEX = r"^/api/"
1✔
746
CORS_ALLOWED_ORIGINS = [
1✔
747
    "https://vault.bitwarden.com",
748
    "https://vault.bitwarden.eu",
749
]
750
if RELAY_CHANNEL in ["dev", "stage"]:
1!
UNCOV
751
    CORS_ALLOWED_ORIGINS += [
×
752
        "https://vault.qa.bitwarden.pw",
753
        "https://vault.euqa.bitwarden.pw",
754
    ]
755
# Allow origins for each environment to help debug cors headers
756
if RELAY_CHANNEL == "local":
1!
757
    # In local dev, next runs on localhost and makes requests to /accounts/
758
    CORS_ALLOWED_ORIGINS += [
1✔
759
        "http://localhost:3000",
760
        "http://0.0.0.0:3000",
761
        "http://127.0.0.1:8000",
762
    ]
763
    CORS_URLS_REGEX = r"^/(api|accounts)/"
1✔
764
if RELAY_CHANNEL == "dev":
1!
UNCOV
765
    CORS_ALLOWED_ORIGINS += [
×
766
        "https://dev.fxprivaterelay.nonprod.cloudops.mozgcp.net",
767
    ]
768
if RELAY_CHANNEL == "stage":
1!
UNCOV
769
    CORS_ALLOWED_ORIGINS += [
×
770
        "https://stage.fxprivaterelay.nonprod.cloudops.mozgcp.net",
771
    ]
772

773
CSRF_TRUSTED_ORIGINS = []
1✔
774
if RELAY_CHANNEL == "local":
1!
775
    # In local development, the React UI can be served up from a different server
776
    # that needs to be allowed to make requests.
777
    # In production, the frontend is served by Django, is therefore on the same
778
    # origin and thus has access to the same cookies.
779
    CORS_ALLOW_CREDENTIALS = True
1✔
780
    SESSION_COOKIE_SAMESITE = None
1✔
781
    CSRF_TRUSTED_ORIGINS += [
1✔
782
        "http://localhost:3000",
783
        "http://0.0.0.0:3000",
784
    ]
785

786
SENTRY_RELEASE = config("SENTRY_RELEASE", "")
1✔
787
CIRCLE_SHA1 = config("CIRCLE_SHA1", "")
1✔
788
CIRCLE_TAG = config("CIRCLE_TAG", "")
1✔
789
CIRCLE_BRANCH = config("CIRCLE_BRANCH", "")
1✔
790

791
sentry_release: str | None = None
1✔
792
if SENTRY_RELEASE:
1!
UNCOV
793
    sentry_release = SENTRY_RELEASE
×
794
elif CIRCLE_TAG and CIRCLE_TAG != "unknown":
1!
795
    sentry_release = CIRCLE_TAG
×
796
elif (
1!
797
    CIRCLE_SHA1
798
    and CIRCLE_SHA1 != "unknown"
799
    and CIRCLE_BRANCH
800
    and CIRCLE_BRANCH != "unknown"
801
):
802
    sentry_release = f"{CIRCLE_BRANCH}:{CIRCLE_SHA1}"
1✔
803

804
SENTRY_DEBUG = config("SENTRY_DEBUG", DEBUG, cast=bool)
1✔
805

806
SENTRY_ENVIRONMENT = config("SENTRY_ENVIRONMENT", RELAY_CHANNEL)
1✔
807
# Use "local" as default rather than "prod", to catch ngrok.io URLs
808
if SENTRY_ENVIRONMENT == "prod" and SITE_ORIGIN != "https://relay.firefox.com":
1!
UNCOV
809
    SENTRY_ENVIRONMENT = "local"
×
810

811
sentry_sdk.init(
1✔
812
    dsn=config("SENTRY_DSN", None),
813
    integrations=[DjangoIntegration(cache_spans=not DEBUG)],
814
    debug=SENTRY_DEBUG,
815
    include_local_variables=DEBUG,
816
    release=sentry_release,
817
    environment=SENTRY_ENVIRONMENT,
818
)
819
# Duplicates events for unhandled exceptions, but without useful tracebacks
820
ignore_logger("request.summary")
1✔
821
# Security scanner attempts, no action required
822
# Can be re-enabled when hostname allow list implemented at the load balancer
823
ignore_logger("django.security.DisallowedHost")
1✔
824
# Fluent errors, mostly when a translation is unavailable for the locale.
825
# It is more effective to process these from logs using BigQuery than to track
826
# as events in Sentry.
827
ignore_logger("django_ftl.message_errors")
1✔
828
# Security scanner attempts on Heroku dev, no action required
829
if RELAY_CHANNEL == "dev":
1!
UNCOV
830
    ignore_logger("django.security.SuspiciousFileOperation")
×
831

832

833
_MARKUS_BACKENDS: list[dict[str, Any]] = []
1✔
834
if DJANGO_STATSD_ENABLED:
1!
UNCOV
835
    _MARKUS_BACKENDS.append(
×
836
        {
837
            "class": "markus.backends.datadog.DatadogMetrics",
838
            "options": {
839
                "statsd_host": STATSD_HOST,
840
                "statsd_port": STATSD_PORT,
841
                "statsd_prefix": STATSD_PREFIX,
842
            },
843
        }
844
    )
845
if STATSD_DEBUG:
1!
UNCOV
846
    _MARKUS_BACKENDS.append(
×
847
        {
848
            "class": "markus.backends.logging.LoggingMetrics",
849
            "options": {
850
                "logger_name": "markus",
851
                "leader": "METRICS",
852
            },
853
        }
854
    )
855
markus.configure(backends=_MARKUS_BACKENDS)
1✔
856

857
if USE_SILK:
1!
UNCOV
858
    SILKY_PYTHON_PROFILER = True
×
UNCOV
859
    SILKY_PYTHON_PROFILER_BINARY = True
×
860
    SILKY_PYTHON_PROFILER_RESULT_PATH = ".silk-profiler"
×
861

862
# Settings for manage.py process_emails_from_sqs
863
PROCESS_EMAIL_BATCH_SIZE = config(
1✔
864
    "PROCESS_EMAIL_BATCH_SIZE", 10, cast=Choices(range(1, 11), cast=int)
865
)
866
PROCESS_EMAIL_DELETE_FAILED_MESSAGES = config(
1✔
867
    "PROCESS_EMAIL_DELETE_FAILED_MESSAGES", False, cast=bool
868
)
869
PROCESS_EMAIL_HEALTHCHECK_PATH = config(
1✔
870
    "PROCESS_EMAIL_HEALTHCHECK_PATH", os.path.join(TMP_DIR, "healthcheck.json")
871
)
872
PROCESS_EMAIL_MAX_SECONDS = config("PROCESS_EMAIL_MAX_SECONDS", 0, cast=int) or None
1✔
873
PROCESS_EMAIL_VERBOSITY = config(
1✔
874
    "PROCESS_EMAIL_VERBOSITY", 1, cast=Choices(range(0, 4), cast=int)
875
)
876
PROCESS_EMAIL_VISIBILITY_SECONDS = config(
1✔
877
    "PROCESS_EMAIL_VISIBILITY_SECONDS", 120, cast=int
878
)
879
PROCESS_EMAIL_WAIT_SECONDS = config("PROCESS_EMAIL_WAIT_SECONDS", 5, cast=int)
1✔
880
PROCESS_EMAIL_HEALTHCHECK_MAX_AGE = config(
1✔
881
    "PROCESS_EMAIL_HEALTHCHECK_MAX_AGE", 120, cast=int
882
)
883
PROCESS_EMAIL_MAX_SECONDS_PER_MESSAGE = config(
1✔
884
    "PROCESS_EMAIL_MAX_SECONDS_PER_MESSAGE",
885
    PROCESS_EMAIL_MAX_SECONDS or 120.0,
886
    cast=float,
887
)
888

889
# Django 3.2 switches default to BigAutoField
890
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
1✔
891

892
# python-dockerflow settings
893
DOCKERFLOW_VERSION_CALLBACK = "privaterelay.utils.get_version_info"
1✔
894
DOCKERFLOW_CHECKS = [
1✔
895
    "dockerflow.django.checks.check_database_connected",
896
    "dockerflow.django.checks.check_migrations_applied",
897
]
898
if REDIS_URL:
1!
UNCOV
899
    DOCKERFLOW_CHECKS.append("dockerflow.django.checks.check_redis_connected")
×
900
DOCKERFLOW_REQUEST_ID_HEADER_NAME = config("DOCKERFLOW_REQUEST_ID_HEADER_NAME", None)
1✔
901
SILENCED_SYSTEM_CHECKS = sorted(
1✔
902
    set(config("DJANGO_SILENCED_SYSTEM_CHECKS", default="", cast=Csv()))
903
    | {
904
        # (models.W040) SQLite does not support indexes with non-key columns.
905
        # RelayAddress index idx_ra_created_by_addon uses this for PostgreSQL.
906
        "models.W040",
907
    }
908
)
909

910
# django-ftl settings
911
AUTO_RELOAD_BUNDLES = False  # Requires pyinotify
1✔
912

913
# Patching for django-types
914
django_stubs_ext.monkeypatch()
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc