This repository has been archived on 2026-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
RepApp/rc_hip/rc_hip/settings.py

209 lines
5.8 KiB
Python
Raw Normal View History

2023-04-16 11:01:31 +00:00
"""
Django settings for rc_hip project.
2023-04-24 16:02:43 +00:00
Generated by "django-admin startproject" using Django 4.2.
2023-04-16 11:01:31 +00:00
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
2023-04-17 18:57:55 +00:00
import mimetypes
import os
2023-04-16 11:01:31 +00:00
from pathlib import Path
2023-04-17 18:57:55 +00:00
mimetypes.add_type("text/css", ".css", True)
2023-04-24 16:02:43 +00:00
# Build paths inside the project like this: BASE_DIR / "subdir".
2023-04-16 11:01:31 +00:00
BASE_DIR = Path(__file__).resolve().parent.parent
2023-04-17 18:57:55 +00:00
STATIC_ROOT = os.path.join(BASE_DIR, "static")
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
2023-04-16 11:01:31 +00:00
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
2023-04-24 16:02:43 +00:00
# SECRET_KEY = "django-insecure-ura&_-(r(&&b$0s!a=07c@k6c!8=8m7$5(4#w8m@79-e%rn6s*"
SECRET_KEY = os.getenv(
"DJANGO_SECRET_KEY", "django-insecure-ura&_-(r(&&b$0s!a=07c@k6c!8=8m7$5(4#w8m@79-e%rn6s*")
2023-04-16 11:01:31 +00:00
2023-04-24 16:02:43 +00:00
# SECURITY WARNING: don"t run with debug turned on in production!
DEBUG = os.getenv("DJANGO_DEBUG", "true").lower() in ("true", "1", "t")
2023-04-16 11:01:31 +00:00
2023-04-17 19:48:32 +00:00
ALLOWED_HOSTS = [
2023-04-24 16:02:43 +00:00
"127.0.0.1",
"localhost",
"repapp.rc-hip.de",
"anmeldung.repaircafe-hilpoltstein.de",
2023-04-17 19:48:32 +00:00
]
2023-04-16 11:01:31 +00:00
# Application definition
INSTALLED_APPS = [
2023-04-24 16:02:43 +00:00
"repapp.apps.RepappConfig",
"django.contrib.admin",
"django.contrib.auth",
"mozilla_django_oidc",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"crispy_forms",
2023-04-27 13:31:05 +00:00
"crispy_bootstrap5",
2023-04-24 16:02:43 +00:00
"import_export",
2023-05-29 14:58:36 +00:00
"ckeditor",
"ckeditor_uploader",
2023-04-16 11:01:31 +00:00
]
2023-04-27 13:31:05 +00:00
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
CRISPY_TEMPLATE_PACK = "bootstrap5"
2023-05-29 14:58:36 +00:00
CKEDITOR_UPLOAD_PATH = "uploads/"
2023-04-19 19:28:59 +00:00
2023-04-16 11:01:31 +00:00
MIDDLEWARE = [
2023-04-24 16:02:43 +00:00
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
2023-04-16 11:01:31 +00:00
]
2023-04-24 16:02:43 +00:00
ROOT_URLCONF = "rc_hip.urls"
2023-04-16 11:01:31 +00:00
TEMPLATES = [
{
2023-04-24 16:02:43 +00:00
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
2023-04-16 11:01:31 +00:00
],
},
},
]
2023-04-24 16:02:43 +00:00
WSGI_APPLICATION = "rc_hip.wsgi.application"
2023-04-16 11:01:31 +00:00
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
2023-04-24 16:02:43 +00:00
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "data" / "db.sqlite3",
2023-04-16 11:01:31 +00:00
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
2023-04-24 16:02:43 +00:00
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
2023-04-16 11:01:31 +00:00
},
{
2023-04-24 16:02:43 +00:00
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
2023-04-16 11:01:31 +00:00
},
{
2023-04-24 16:02:43 +00:00
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
2023-04-16 11:01:31 +00:00
},
{
2023-04-24 16:02:43 +00:00
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
2023-04-16 11:01:31 +00:00
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
2023-04-24 16:02:43 +00:00
LANGUAGE_CODE = "de"
2023-04-16 11:01:31 +00:00
2023-04-24 16:02:43 +00:00
TIME_ZONE = "Europe/Berlin"
2023-04-16 11:01:31 +00:00
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
2023-04-24 16:02:43 +00:00
STATIC_URL = "static/"
MEDIA_URL = "media/"
2023-04-16 11:01:31 +00:00
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
2023-04-24 16:02:43 +00:00
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
2023-04-17 18:57:55 +00:00
CSRF_TRUSTED_ORIGINS = [
2023-04-24 16:02:43 +00:00
"http://127.0.0.1:8020",
"http://localhost:8020",
"http://127.0.0.1:8000",
"http://localhost:8000",
"https://repapp.rc-hip.de",
"https://anmeldung.repaircafe-hilpoltstein.de",
2023-04-17 18:57:55 +00:00
]
2023-04-24 16:02:43 +00:00
EMAIL_HOST = os.getenv("DJANGO_EMAIL_HOST", "")
EMAIL_PORT = (int)(os.getenv("DJANGO_EMAIL_PORT", "25"))
EMAIL_HOST_USER = os.getenv("DJANGO_EMAIL_HOST_USER", None)
EMAIL_HOST_PASSWORD = os.getenv("DJANGO_EMAIL_HOST_PASSWORD", None)
2023-04-24 16:02:43 +00:00
EMAIL_USE_TLS = os.getenv("DJANGO_EMAIL_USE_TLS", "true") in ("true", "1", "t")
AUTH_USER_MODEL = "repapp.CustomUser"
2023-04-23 10:55:10 +00:00
AUTHENTICATION_BACKENDS = [
2023-04-24 16:02:43 +00:00
"repapp.backends.EmailBackend",
2023-04-23 15:40:19 +00:00
"django.contrib.auth.backends.ModelBackend",
2023-04-24 16:02:43 +00:00
"repapp.backends.KeycloakOIDCAB",
"repapp.backends.OneTimeLoginBackend",
2023-04-23 15:40:19 +00:00
]
2023-04-23 11:56:52 +00:00
2023-05-29 14:58:36 +00:00
LOGIN_REDIRECT_URL = "/guest/"
2023-04-23 15:40:19 +00:00
OIDC_RP_CLIENT_ID = "repapp"
OIDC_RP_CLIENT_SECRET = os.getenv("DJANGO_OIDC_RP_CLIENT_SECRET", None)
OIDC_RP_SIGN_ALGO = "RS256"
OIDC_OP_JWKS_ENDPOINT = "https://sso.makes-hacks-hip.de/realms/Makes-Hacks-Hip/protocol/openid-connect/certs"
OIDC_OP_AUTHORIZATION_ENDPOINT = "https://sso.makes-hacks-hip.de/realms/Makes-Hacks-Hip/protocol/openid-connect/auth"
OIDC_OP_TOKEN_ENDPOINT = "https://sso.makes-hacks-hip.de/realms/Makes-Hacks-Hip/protocol/openid-connect/token"
OIDC_OP_USER_ENDPOINT = "https://sso.makes-hacks-hip.de/realms/Makes-Hacks-Hip/protocol/openid-connect/userinfo"
if DEBUG:
LOGIN_REDIRECT_URL = "http://127.0.0.1:8000/member"
2023-04-23 15:40:19 +00:00
LOGOUT_REDIRECT_URL = "http://127.0.0.1:8000/"
else:
LOGIN_REDIRECT_URL = "https://anmeldung.repaircafe-hilpoltstein.de/member"
2023-04-25 12:32:45 +00:00
LOGOUT_REDIRECT_URL = "https://anmeldung.repaircafe-hilpoltstein.de/"
2023-04-25 18:47:53 +00:00
LOG_LEVEL = "INFO"
if DEBUG:
LOG_LEVEL = "DEBUG"
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
},
"root": {
"handlers": ["console"],
"level": LOG_LEVEL,
},
}