220 lines
6.5 KiB
Python
220 lines
6.5 KiB
Python
"""
|
|
Django settings for izaac project.
|
|
|
|
Generated by 'django-admin startproject' using Django 4.1.4.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/4.1/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/4.1/ref/settings/
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
import os
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
REACT_CLIENT_ID = os.environ.get("REACT_CLIENT_ID")
|
|
|
|
REACT_CLIENT_SECRET = os.environ.get("REACT_CLIENT_SECRET")
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = "django-insecure-ztiqj957k(j*@ms=-^9j+=j7wd+cyo*+9g&hkfh1bji-@#&6(e"
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = True
|
|
|
|
ALLOWED_HOSTS = ['izaac.izaac.pl', 'localhost', '127.0.0.1', 'izaac', 'tinyproxy-svc']
|
|
|
|
CORS_ALLOW_ALL_ORIGINS = True
|
|
|
|
# CORS_ALLOWED_ORIGIN = [
|
|
# "http://localhost:8000",
|
|
# "http://izaac.izaac.pl",
|
|
# "http://izaac-frontend.izaac.pl",
|
|
# "http://izaac-backend.izaac.pl",
|
|
# "http://localhost:5173",
|
|
# ]
|
|
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_AUTHENTICATION_CLASSES': [
|
|
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
|
|
'rest_framework.authentication.SessionAuthentication',
|
|
],
|
|
'DEFAULT_PERMISSION_CLASSES': [
|
|
'rest_framework.permissions.IsAuthenticated',
|
|
]
|
|
}
|
|
|
|
OAUTH2_PROVIDER = {
|
|
# this is the list of available scopes
|
|
'SCOPES': {'read': 'Read scope', 'write': 'Write scope', 'main': 'Access to all'}
|
|
}
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
'django.contrib.sites',
|
|
"corsheaders",
|
|
"rest_framework",
|
|
"rest_framework.authtoken",
|
|
"dj_rest_auth",
|
|
'allauth',
|
|
'allauth.account',
|
|
'allauth.socialaccount',
|
|
'dj_rest_auth.registration',
|
|
"core",
|
|
"jobposting",
|
|
'oauth2_provider',
|
|
]
|
|
|
|
SITE_ID = 1
|
|
|
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Do testów lokalnych
|
|
|
|
ACCOUNT_EMAIL_VERIFICATION = 'none' # Lub 'mandatory' jeśli chcesz wymagać weryfikacji e-mail
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
"allauth.account.middleware.AccountMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "izaac.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"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",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "izaac.wsgi.application"
|
|
|
|
REST_AUTH = {
|
|
'LOGIN_SERIALIZER': 'dj_rest_auth.serializers.LoginSerializer',
|
|
'TOKEN_SERIALIZER': 'dj_rest_auth.serializers.TokenSerializer',
|
|
'JWT_SERIALIZER': 'dj_rest_auth.serializers.JWTSerializer',
|
|
'JWT_SERIALIZER_WITH_EXPIRATION': 'dj_rest_auth.serializers.JWTSerializerWithExpiration',
|
|
'JWT_TOKEN_CLAIMS_SERIALIZER': 'rest_framework_simplejwt.serializers.TokenObtainPairSerializer',
|
|
'USER_DETAILS_SERIALIZER': 'dj_rest_auth.serializers.UserDetailsSerializer',
|
|
'PASSWORD_RESET_SERIALIZER': 'dj_rest_auth.serializers.PasswordResetSerializer',
|
|
'PASSWORD_RESET_CONFIRM_SERIALIZER': 'dj_rest_auth.serializers.PasswordResetConfirmSerializer',
|
|
'PASSWORD_CHANGE_SERIALIZER': 'dj_rest_auth.serializers.PasswordChangeSerializer',
|
|
|
|
'REGISTER_SERIALIZER': 'dj_rest_auth.registration.serializers.RegisterSerializer',
|
|
|
|
'REGISTER_PERMISSION_CLASSES': ('rest_framework.permissions.AllowAny',),
|
|
|
|
'TOKEN_MODEL': 'rest_framework.authtoken.models.Token',
|
|
'TOKEN_CREATOR': 'dj_rest_auth.utils.default_create_token',
|
|
|
|
'PASSWORD_RESET_USE_SITES_DOMAIN': False,
|
|
'OLD_PASSWORD_FIELD_ENABLED': False,
|
|
'LOGOUT_ON_PASSWORD_CHANGE': False,
|
|
'SESSION_LOGIN': True,
|
|
'USE_JWT': False,
|
|
|
|
'JWT_AUTH_COOKIE': None,
|
|
'JWT_AUTH_REFRESH_COOKIE': None,
|
|
'JWT_AUTH_REFRESH_COOKIE_PATH': '/',
|
|
'JWT_AUTH_SECURE': False,
|
|
'JWT_AUTH_HTTPONLY': True,
|
|
'JWT_AUTH_SAMESITE': 'Lax',
|
|
'JWT_AUTH_RETURN_EXPIRATION': False,
|
|
'JWT_AUTH_COOKIE_USE_CSRF': False,
|
|
'JWT_AUTH_COOKIE_ENFORCE_CSRF_ON_UNAUTHENTICATED': False,
|
|
}
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': 'izaac',
|
|
'USER': 'izaac',
|
|
'PASSWORD': 'iz@@cPWD@$5',
|
|
'HOST': 'postgres-service',
|
|
'PORT': '10452',
|
|
}
|
|
}
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/4.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",
|
|
},
|
|
]
|
|
AUTH_USER_MODEL = "core.MyUser"
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/4.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/4.1/howto/static-files/
|
|
|
|
STATIC_URL = "static/"
|
|
|
|
STATICFILES_DIRS = [
|
|
os.path.join(BASE_DIR, 'static'), # Do NOT make this the same as STATIC_ROOT
|
|
]
|
|
|
|
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
|
|
|
MEDIA_URL = '/media/'
|
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|