wg-manager/wg_manager/settings_dist.py

152 lines
4 KiB
Python
Raw Normal View History

2024-10-06 12:56:12 +02:00
"""
Django settings for wg_manager project.
Generated by 'django-admin startproject' using Django 5.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
import environ
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
env = environ.Env(
WG_INTERFACE=(str, "wg0"),
DEBUG=(bool, False),
ALLOWED_HOSTS=(list, ["127.0.0.1"]),
SECRET_KEY=(str, "django-insecure-m+lcgaz=h1fb1)btwuo0i(k%04*@=9uuw)#@j6hle&lfdj-mza"),
feat: containers and celery worker Squashed commit of the following: commit f3c87deb32418b3042a4a976608f7bc6b7686c04 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 23:47:36 2024 +0200 chore: refresh button commit e7c831e0c20a438a0ee9240fe637a81f2f454d81 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 23:37:56 2024 +0200 feat: wrapping up containers commit e571b00c3d1f310dba99b187b4009ed8247bd845 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 21:27:52 2024 +0200 fix: sort out sub commit 4a75d4561b30392908f95d7f052467594de6b049 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 21:24:56 2024 +0200 fix: sort out sub commit 3c1030a2fe1cf7380aa6dfb5827bc3a4a48fbcb7 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:29:29 2024 +0200 chore: optimize image build commit f63d1b185b90bd8db8712089f339e5fe9ddc5af6 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:28:11 2024 +0200 chore: optimize image build commit 0d9a1754384c4012ba486fccc33cc43ca41f1ed4 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:26:16 2024 +0200 chore: optimize image build commit bb510718d2a684fff873418e745ce8bebbd02b7b Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:08:22 2024 +0200 fix: toggle_connection commit b48a12c1f31c524325be17032f8148160035829d Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:02:30 2024 +0200 fix: toggle_connection commit 343c36002b1dd445781611199a0c532a5b111185 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:27:14 2024 +0200 fix: serialization commit 880909912c740e72e4be9642088a708b8e088bd3 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:24:06 2024 +0200 fix: sync command commit fbabd0cfcad23a79477e2fbf9109253ee0702d87 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:13:10 2024 +0200 fix: import Peer commit 444f612452170698c74c0a9e8c0731bfd14f67e0 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:09:28 2024 +0200 chore: use celery commit 2f9699129436432d92b0fb487fd4de3b3d663fd1 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:02:40 2024 +0200 fix: make gunicorn listen on 0.0.0.0 commit 313f23e23ca6acb1bddb0b4b89ebcb951ad36f32 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 18:59:22 2024 +0200 chore: docker stuff compat commit c17153112bc1a000e57ffe2346ec516056714777 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 18:55:39 2024 +0200 feat: celery decoupling
2024-10-13 23:49:48 +02:00
USE_CELERY=(bool, True),
2024-10-06 12:56:12 +02:00
)
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))
WG_INTERFACE = env("WG_INTERFACE")
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env("DEBUG")
ALLOWED_HOSTS = env("ALLOWED_HOSTS")
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"whitenoise.runserver_nostatic",
2024-10-06 12:56:12 +02:00
"django.contrib.staticfiles",
"wg_connection_manager",
2024-10-20 00:12:07 +02:00
"django_otp",
"django_otp.plugins.otp_static",
"django_otp.plugins.otp_totp",
"two_factor",
2024-10-06 12:56:12 +02:00
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
2024-10-06 12:56:12 +02:00
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
2024-10-20 00:12:07 +02:00
"django_otp.middleware.OTPMiddleware",
2024-10-06 12:56:12 +02:00
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = "wg_manager.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "templates"],
"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",
],
},
},
]
WSGI_APPLICATION = "wg_manager.wsgi.application"
# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/
STATIC_URL = "static/"
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
2024-10-20 00:12:07 +02:00
LOGOUT_REDIRECT_URL = "connections_list"
2024-10-20 00:12:07 +02:00
LOGIN_URL = "two_factor:login"
2024-10-20 12:11:51 +02:00
# 15 days
TWO_FACTOR_REMEMBER_COOKIE_AGE = 1296000
2024-10-20 00:12:07 +02:00
# this one is optional
# LOGIN_REDIRECT_URL = 'two_factor:profile'
STATIC_ROOT = BASE_DIR / "static"
feat: containers and celery worker Squashed commit of the following: commit f3c87deb32418b3042a4a976608f7bc6b7686c04 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 23:47:36 2024 +0200 chore: refresh button commit e7c831e0c20a438a0ee9240fe637a81f2f454d81 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 23:37:56 2024 +0200 feat: wrapping up containers commit e571b00c3d1f310dba99b187b4009ed8247bd845 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 21:27:52 2024 +0200 fix: sort out sub commit 4a75d4561b30392908f95d7f052467594de6b049 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 21:24:56 2024 +0200 fix: sort out sub commit 3c1030a2fe1cf7380aa6dfb5827bc3a4a48fbcb7 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:29:29 2024 +0200 chore: optimize image build commit f63d1b185b90bd8db8712089f339e5fe9ddc5af6 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:28:11 2024 +0200 chore: optimize image build commit 0d9a1754384c4012ba486fccc33cc43ca41f1ed4 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:26:16 2024 +0200 chore: optimize image build commit bb510718d2a684fff873418e745ce8bebbd02b7b Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:08:22 2024 +0200 fix: toggle_connection commit b48a12c1f31c524325be17032f8148160035829d Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 20:02:30 2024 +0200 fix: toggle_connection commit 343c36002b1dd445781611199a0c532a5b111185 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:27:14 2024 +0200 fix: serialization commit 880909912c740e72e4be9642088a708b8e088bd3 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:24:06 2024 +0200 fix: sync command commit fbabd0cfcad23a79477e2fbf9109253ee0702d87 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:13:10 2024 +0200 fix: import Peer commit 444f612452170698c74c0a9e8c0731bfd14f67e0 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:09:28 2024 +0200 chore: use celery commit 2f9699129436432d92b0fb487fd4de3b3d663fd1 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 19:02:40 2024 +0200 fix: make gunicorn listen on 0.0.0.0 commit 313f23e23ca6acb1bddb0b4b89ebcb951ad36f32 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 18:59:22 2024 +0200 chore: docker stuff compat commit c17153112bc1a000e57ffe2346ec516056714777 Author: Andrea Zucchelli <zukka77@gmail.com> Date: Sun Oct 13 18:55:39 2024 +0200 feat: celery decoupling
2024-10-13 23:49:48 +02:00
USE_CELERY = env("USE_CELERY")