Changeset View
Changeset View
Standalone View
Standalone View
swh/web/settings/common.py
# Copyright (C) 2017-2021 The Software Heritage developers | # Copyright (C) 2017-2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
""" | """ | ||||
Django common settings for swh-web. | Django common settings for swh-web. | ||||
""" | """ | ||||
import os | import os | ||||
import sys | import sys | ||||
from typing import Any, Dict | from typing import Any, Dict | ||||
from django.utils import encoding | |||||
from swh.web.auth.utils import OIDC_SWH_WEB_CLIENT_ID | from swh.web.auth.utils import OIDC_SWH_WEB_CLIENT_ID | ||||
from swh.web.config import get_config | from swh.web.config import get_config | ||||
# Fix django-js-reverse 0.9.1 compatibility with django 4.x | |||||
# TODO: Remove that hack once a new django-js-reverse release | |||||
# is available on PyPI | |||||
if not hasattr(encoding, "force_text"): | |||||
setattr(encoding, "force_text", encoding.force_str) | |||||
swh_web_config = get_config() | swh_web_config = get_config() | ||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||||
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) | PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||||
# Quick-start development settings - unsuitable for production | # Quick-start development settings - unsuitable for production | ||||
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ | # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ | ||||
▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | AUTHENTICATION_BACKENDS = [ | ||||
"django.contrib.auth.backends.ModelBackend", | "django.contrib.auth.backends.ModelBackend", | ||||
"swh.auth.django.backends.OIDCAuthorizationCodePKCEBackend", | "swh.auth.django.backends.OIDCAuthorizationCodePKCEBackend", | ||||
] | ] | ||||
SWH_AUTH_SERVER_URL = swh_web_config["keycloak"]["server_url"] | SWH_AUTH_SERVER_URL = swh_web_config["keycloak"]["server_url"] | ||||
SWH_AUTH_REALM_NAME = swh_web_config["keycloak"]["realm_name"] | SWH_AUTH_REALM_NAME = swh_web_config["keycloak"]["realm_name"] | ||||
SWH_AUTH_CLIENT_ID = OIDC_SWH_WEB_CLIENT_ID | SWH_AUTH_CLIENT_ID = OIDC_SWH_WEB_CLIENT_ID | ||||
SWH_AUTH_SESSION_EXPIRED_REDIRECT_VIEW = "logout" | SWH_AUTH_SESSION_EXPIRED_REDIRECT_VIEW = "logout" | ||||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField" |