158 lines
4.7 KiB
Python
158 lines
4.7 KiB
Python
"""
|
|
Django settings for example project.
|
|
|
|
Generated by 'django-admin startproject' using Django 2.0.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/2.0/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/2.0/ref/settings/
|
|
"""
|
|
|
|
import os
|
|
from django.conf.global_settings import PASSWORD_HASHERS as DEFAULT_PASSWORD_HASHERS
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = "#9)q!_i3@pr-^3oda(e^3$x!kq3b4f33#5l@+=+&vuz+p6gb3g"
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = True
|
|
|
|
ALLOWED_HOSTS = ["*"]
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"mfa",
|
|
"sslserver",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"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",
|
|
]
|
|
|
|
ROOT_URLCONF = "example.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [os.path.join(BASE_DIR, "example", "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 = "example.wsgi.application"
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
"NAME": "test_db",
|
|
}
|
|
}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/2.0/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/2.0/topics/i18n/
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
|
|
TIME_ZONE = "UTC"
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/2.0/howto/static-files/
|
|
|
|
STATIC_URL = "/static/"
|
|
# STATIC_ROOT=(os.path.join(BASE_DIR,'static'))
|
|
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
|
|
LOGIN_URL = "/auth/login"
|
|
|
|
EMAIL_FROM = "Test App"
|
|
EMAIL_HOST = "smtp.gmail.com"
|
|
EMAIL_PORT = 587
|
|
EMAIL_HOST_USER = ""
|
|
EMAIL_HOST_PASSWORD = ""
|
|
EMAIL_USE_TLS = True
|
|
|
|
|
|
MFA_UNALLOWED_METHODS = () # Methods that shouldn't be allowed for the user
|
|
MFA_LOGIN_CALLBACK = "example.auth.create_session" # A function that should be called by username to login the user in session
|
|
MFA_RECHECK = True # Allow random rechecking of the user
|
|
MFA_RECHECK_MIN = 10 # Minimum interval in seconds
|
|
MFA_RECHECK_MAX = 30 # Maximum in seconds
|
|
MFA_QUICKLOGIN = True # Allow quick login for returning users by provide only their 2FA
|
|
MFA_HIDE_DISABLE = ("",) # Can the user disable his key (Added in 1.2.0).
|
|
MFA_REDIRECT_AFTER_REGISTRATION = "registered"
|
|
MFA_SUCCESS_REGISTRATION_MSG = "Go to Home"
|
|
MFA_ALWAYS_GO_TO_LAST_METHOD = True
|
|
MFA_ENFORCE_RECOVERY_METHOD = True
|
|
MFA_RENAME_METHODS = {"RECOVERY": "Backup Codes", "FIDO2": "Biometric Authentication"}
|
|
PASSWORD_HASHERS = DEFAULT_PASSWORD_HASHERS # Comment if PASSWORD_HASHER already set
|
|
PASSWORD_HASHERS += ["mfa.recovery.Hash"]
|
|
RECOVERY_ITERATION = 1 # Number of iteration for recovery code, higher is more secure, but uses more resources for generation and check...
|
|
TOKEN_ISSUER_NAME = "PROJECT_NAME" # TOTP Issuer name
|
|
|
|
U2F_APPID = "https://localhost:9000" # URL For U2F
|
|
FIDO_SERVER_ID = (
|
|
"localhost" # Server rp id for FIDO2, it the full domain of your project
|
|
)
|
|
FIDO_SERVER_NAME = "TestApp"
|