|
8 | 8 | import asgiref
|
9 | 9 | import django
|
10 | 10 | import environ
|
| 11 | +from csp.constants import NONCE, NONE, SELF, STRICT_DYNAMIC, UNSAFE_INLINE |
11 | 12 | from django.contrib.messages import constants as messages
|
12 | 13 | from django.utils.translation import gettext_lazy as _
|
13 | 14 | from template_partials.apps import wrap_loaders
|
|
101 | 102 | # APPS
|
102 | 103 | # ------------------------------------------------------------------------------
|
103 | 104 | DJANGO_APPS = [
|
104 |
| - "daphne", |
105 | 105 | "django.contrib.auth",
|
106 | 106 | "django.contrib.contenttypes",
|
107 | 107 | "django.contrib.sessions",
|
|
332 | 332 | # https://django-csp.readthedocs.io/en/latest/configuration.html
|
333 | 333 | # https://content-security-policy.com/
|
334 | 334 | # https://csp-evaluator.withgoogle.com/
|
335 |
| -CSP_DEFAULT_SRC = ("'self'",) |
336 |
| -CSP_SCRIPT_SRC = ("'strict-dynamic'", "'unsafe-inline'", "https:") |
337 |
| -CSP_SCRIPT_SRC_ATTR = None |
338 |
| -CSP_SCRIPT_SRC_ELEM = None |
339 |
| -CSP_IMG_SRC = ("'self'", "data:") |
340 |
| -CSP_OBJECT_SRC = ("'none'",) |
341 |
| -CSP_MEDIA_SRC = ("'self'",) |
342 |
| -CSP_FRAME_SRC = ("'none'",) |
343 |
| -CSP_FONT_SRC = ("'self'",) |
344 |
| -CSP_CONNECT_SRC = env.tuple("CSP_CONNECT_SRC", default=("'self'",)) |
345 |
| -CSP_STYLE_SRC = ("'strict-dynamic'", "'unsafe-inline'", "https:") |
346 |
| -CSP_STYLE_SRC_ATTR = None |
347 |
| -CSP_STYLE_SRC_ELEM = None |
348 |
| -CSP_BASE_URI = ("'none'",) |
349 |
| -CSP_FRAME_ANCESTORS = ("'none'",) |
350 |
| -CSP_FORM_ACTION = ("'self'",) |
351 |
| -CSP_MANIFEST_SRC = ("'self'",) |
352 |
| -CSP_WORKER_SRC = ("'self'",) |
353 |
| -CSP_PLUGIN_TYPES = None |
354 |
| -CSP_REQUIRE_SRI_FOR = None |
355 |
| -CSP_INCLUDE_NONCE_IN = ("script-src", "style-src") |
356 |
| -# Those are forced to true in production |
357 |
| -CSP_UPGRADE_INSECURE_REQUESTS = IS_PRODUCTION |
358 |
| -CSP_BLOCK_ALL_MIXED_CONTENT = IS_PRODUCTION |
| 335 | +CONTENT_SECURITY_POLICY = { |
| 336 | + "DIRECTIVES": { |
| 337 | + "default-src": (SELF,), |
| 338 | + "script-src": (STRICT_DYNAMIC, UNSAFE_INLINE, "https:", NONCE), |
| 339 | + "script-src-attr": None, |
| 340 | + "script-src-elem": None, |
| 341 | + "img-src": (SELF, "data:"), |
| 342 | + "object-src": (NONE,), |
| 343 | + "media-src": (SELF,), |
| 344 | + "frame-src": (NONE,), |
| 345 | + "font-src": (SELF,), |
| 346 | + "connect-src": env.tuple("CSP_CONNECT_SRC", default=(SELF,)), |
| 347 | + "style-src": (STRICT_DYNAMIC, UNSAFE_INLINE, "https:", NONCE), |
| 348 | + "style-src-attr": None, |
| 349 | + "style-src-elem": None, |
| 350 | + "base-uri": (NONE,), |
| 351 | + "child-src": (NONE,), |
| 352 | + "frame-ancestors": (NONE,), |
| 353 | + "form-action": (SELF,), |
| 354 | + "manifest-src": (SELF,), |
| 355 | + "worker-src": (SELF,), |
| 356 | + "require-sri-for": (NONE,), |
| 357 | + "upgrade-insecure-requests": IS_PRODUCTION, |
| 358 | + }, |
| 359 | +} |
359 | 360 |
|
360 | 361 |
|
361 | 362 | # CORS
|
|
490 | 491 | # ------------------------------------------------------------------------------
|
491 | 492 | ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True)
|
492 | 493 | # https://django-allauth.readthedocs.io/en/latest/configuration.html
|
493 |
| -ACCOUNT_AUTHENTICATION_METHOD = "email" |
494 |
| -# https://django-allauth.readthedocs.io/en/latest/configuration.html |
495 |
| -ACCOUNT_EMAIL_REQUIRED = True |
| 494 | +ACCOUNT_LOGIN_METHODS = {"email"} |
496 | 495 | # https://django-allauth.readthedocs.io/en/latest/configuration.html
|
497 |
| -ACCOUNT_USERNAME_REQUIRED = False |
| 496 | +ACCOUNT_SIGNUP_FIELDS = ["email*", "password1*", "password2*"] |
498 | 497 | # https://django-allauth.readthedocs.io/en/latest/configuration.html
|
499 | 498 | ACCOUNT_USER_MODEL_USERNAME_FIELD = None
|
500 | 499 | # https://django-allauth.readthedocs.io/en/latest/configuration.html
|
|
515 | 514 | # django-version-checks (https://pypi.org/project/django-version-checks/)
|
516 | 515 | # ------------------------------------------------------------------------------
|
517 | 516 | VERSION_CHECKS = {
|
518 |
| - "python": "==3.12.*", |
| 517 | + "python": "==3.13.*", |
519 | 518 | "postgresql": ">=16",
|
520 | 519 | }
|
521 | 520 |
|
@@ -623,7 +622,7 @@ def before_send_to_sentry(event, hint):
|
623 | 622 | # ------------------------------------------------------------------------------
|
624 | 623 | # See https://django-ninja.dev/reference/settings/
|
625 | 624 | NINJA_PAGINATION_MAX_LIMIT = 500
|
626 |
| -NINJA_PAGINATION_CLASS = "legadilo.utils.pagination.LimitOffsetPagination" |
| 625 | +NINJA_PAGINATION_CLASS = "ninja.pagination.LimitOffsetPagination" |
627 | 626 |
|
628 | 627 |
|
629 | 628 | # Legadilo's specific stuff...
|
|
0 commit comments