Add GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REDIRECT_URI env vars and configure external access endpoints for OAuth callback and logout.
242 lines
6.3 KiB
Python
242 lines
6.3 KiB
Python
"""
|
|
generated with djinit
|
|
Common settings shared between development and production environment
|
|
"""
|
|
|
|
from datetime import timedelta
|
|
from pathlib import Path
|
|
|
|
import environ
|
|
|
|
env_path = Path(__file__).resolve().parent.parent.parent / ".env"
|
|
env = environ.Env()
|
|
environ.Env.read_env(env_path)
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
|
|
|
|
|
|
# Application definition
|
|
THIRD_PARTY_APPS = [
|
|
"rest_framework",
|
|
"rest_framework_simplejwt",
|
|
"corsheaders",
|
|
"drf_spectacular",
|
|
"django_tailwind_cli",
|
|
"django_htmx",
|
|
"import_export",
|
|
"django_filters",
|
|
]
|
|
|
|
USER_DEFINED_APPS = [
|
|
"src.epics.apps.EpicsConfig",
|
|
"src.notes.apps.NotesConfig",
|
|
"src.projects.apps.ProjectsConfig",
|
|
"src.accounts.apps.AccountsConfig",
|
|
"src.external.apps.ExternalConfig",
|
|
"src.notifications.apps.NotificationsConfig",
|
|
"src.tickets.apps.TicketsConfig",
|
|
]
|
|
|
|
BUILT_IN_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
]
|
|
|
|
INSTALLED_APPS = BUILT_IN_APPS + THIRD_PARTY_APPS + USER_DEFINED_APPS
|
|
INSTALLED_APPS.insert(0, "jazzmin")
|
|
|
|
MIDDLEWARE = [
|
|
"corsheaders.middleware.CorsMiddleware",
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
|
"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",
|
|
"django_htmx.middleware.HtmxMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "config.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [BASE_DIR / "templates"],
|
|
"APP_DIRS": True,
|
|
"OPTIONS": {
|
|
"context_processors": [
|
|
"django.template.context_processors.request",
|
|
"django.contrib.auth.context_processors.auth",
|
|
"django.contrib.messages.context_processors.messages",
|
|
"src.config.context_processors.site_stats",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "config.wsgi.application"
|
|
|
|
|
|
AUTH_USER_MODEL = "accounts.User"
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/5.2/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",
|
|
},
|
|
]
|
|
|
|
LOGIN_URL = "/login/"
|
|
LOGIN_REDIRECT_URL = "/dashboard/"
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/5.2/topics/i18n/
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
TIME_ZONE = "Asia/Kathmandu"
|
|
USE_I18N = True
|
|
USE_TZ = True
|
|
|
|
# Static files and media files
|
|
STATIC_URL = "/static/"
|
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
|
|
|
MEDIA_URL = "/media/"
|
|
MEDIA_ROOT = BASE_DIR / "media"
|
|
|
|
STORAGES = {
|
|
"default": {
|
|
"BACKEND": "django.core.files.storage.FileSystemStorage",
|
|
},
|
|
"staticfiles": {
|
|
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
|
|
},
|
|
}
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
# REST Framework Settings
|
|
REST_FRAMEWORK = {
|
|
"DEFAULT_AUTHENTICATION_CLASSES": (
|
|
"rest_framework_simplejwt.authentication.JWTAuthentication",
|
|
"rest_framework.authentication.SessionAuthentication",
|
|
),
|
|
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
|
|
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
|
|
"PAGE_SIZE": 50,
|
|
"DEFAULT_FILTER_BACKENDS": (
|
|
"django_filters.rest_framework.DjangoFilterBackend",
|
|
"rest_framework.filters.SearchFilter",
|
|
"rest_framework.filters.OrderingFilter",
|
|
),
|
|
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
|
}
|
|
|
|
# SimpleJWT
|
|
SIMPLE_JWT = {
|
|
"ACCESS_TOKEN_LIFETIME": timedelta(hours=1),
|
|
"REFRESH_TOKEN_LIFETIME": timedelta(days=30),
|
|
"ROTATE_REFRESH_TOKENS": True,
|
|
"AUTH_HEADER_TYPES": ("Bearer",),
|
|
}
|
|
|
|
|
|
# Google OAuth
|
|
GOOGLE_CLIENT_ID = env("GOOGLE_CLIENT_ID", default="")
|
|
GOOGLE_CLIENT_SECRET = env("GOOGLE_CLIENT_SECRET", default="")
|
|
GOOGLE_REDIRECT_URI = env(
|
|
"GOOGLE_REDIRECT_URI", default="http://localhost:8000/api/auth/google/callback/"
|
|
)
|
|
|
|
# Spectacular
|
|
SPECTACULAR_SETTINGS = {
|
|
"TITLE": "Project Management API",
|
|
"DESCRIPTION": "Django port of Project Management",
|
|
"VERSION": "1.0.0",
|
|
}
|
|
|
|
|
|
# CORS Settings
|
|
CORS_ALLOW_METHODS = [
|
|
"DELETE",
|
|
"GET",
|
|
"OPTIONS",
|
|
"PATCH",
|
|
"POST",
|
|
"PUT",
|
|
]
|
|
|
|
CORS_ALLOW_HEADERS = [
|
|
"accept",
|
|
"accept-encoding",
|
|
"authorization",
|
|
"content-type",
|
|
"dnt",
|
|
"origin",
|
|
"user-agent",
|
|
"x-csrftoken",
|
|
"x-requested-with",
|
|
]
|
|
|
|
CORS_PREFLIGHT_MAX_AGE = 86400 # 24 hours
|
|
# Security Settings
|
|
SECURE_BROWSER_XSS_FILTER = True
|
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
X_FRAME_OPTIONS = "DENY"
|
|
|
|
# for tailwind
|
|
STATICFILES_DIRS = [BASE_DIR / "static/"]
|
|
TAILWIND_CLI_VERSION = "2.7.8"
|
|
TAILWIND_CLI_USE_DAISY_UI = True
|
|
TAILWIND_CLI_CONFIG = {
|
|
"theme": {
|
|
"extend": {
|
|
"colors": {
|
|
"primary": "#DC2626",
|
|
"secondary": "#EF4444",
|
|
"accent": "#FCFECC",
|
|
}
|
|
}
|
|
},
|
|
"daisyui": {
|
|
"themes": [
|
|
{
|
|
"light": {
|
|
"primary": "#DC2626",
|
|
"secondary": "#EF4444",
|
|
"accent": "#FCFECC",
|
|
"neutral": "#1a1a2e",
|
|
"base-100": "#ffffff",
|
|
"base-200": "#f8fafc",
|
|
"base-300": "#e2e8f0",
|
|
"info": "#0E4D80",
|
|
"success": "#16a34a",
|
|
"warning": "#f59e0b",
|
|
"error": "#DC2626",
|
|
}
|
|
}
|
|
]
|
|
},
|
|
}
|