f69efb67ad
- Tauri desktop app (apps/desktop) - Python Django API service (services/api) - Deployment scripts and docs
110 lines
3.3 KiB
Python
110 lines
3.3 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
try:
|
|
from dotenv import load_dotenv
|
|
except ImportError:
|
|
load_dotenv = None
|
|
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
if load_dotenv:
|
|
load_dotenv(BASE_DIR / ".env")
|
|
|
|
|
|
def env_bool(name: str, default: bool = False) -> bool:
|
|
value = os.getenv(name)
|
|
if value is None:
|
|
return default
|
|
return value.lower() in {"1", "true", "yes", "on"}
|
|
|
|
|
|
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", "dev-secret-key")
|
|
DEBUG = env_bool("DJANGO_DEBUG", True)
|
|
ALLOWED_HOSTS = [host.strip() for host in os.getenv("DJANGO_ALLOWED_HOSTS", "127.0.0.1,localhost").split(",")]
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"corsheaders",
|
|
"accounts",
|
|
"vpn",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"corsheaders.middleware.CorsMiddleware",
|
|
"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 = "config.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [],
|
|
"APP_DIRS": True,
|
|
"OPTIONS": {
|
|
"context_processors": [
|
|
"django.template.context_processors.request",
|
|
"django.contrib.auth.context_processors.auth",
|
|
"django.contrib.messages.context_processors.messages",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "config.wsgi.application"
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
"NAME": BASE_DIR / "db.sqlite3",
|
|
}
|
|
}
|
|
|
|
LANGUAGE_CODE = "zh-hans"
|
|
TIME_ZONE = "Asia/Shanghai"
|
|
USE_I18N = True
|
|
USE_TZ = True
|
|
|
|
STATIC_URL = "static/"
|
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
CORS_ALLOWED_ORIGINS = [
|
|
item.strip()
|
|
for item in os.getenv("CORS_ALLOWED_ORIGINS", "http://localhost:5173").split(",")
|
|
if item.strip()
|
|
]
|
|
|
|
FEISHU_APP_ID = os.getenv("FEISHU_APP_ID", "")
|
|
FEISHU_APP_SECRET = os.getenv("FEISHU_APP_SECRET", "")
|
|
FEISHU_REDIRECT_URI = os.getenv("FEISHU_REDIRECT_URI", "")
|
|
FEISHU_EVENT_VERIFICATION_TOKEN = os.getenv("FEISHU_EVENT_VERIFICATION_TOKEN", "")
|
|
TAURI_DEEP_LINK_SCHEME = os.getenv("TAURI_DEEP_LINK_SCHEME", "myvpn")
|
|
|
|
JWT_SECRET = os.getenv("JWT_SECRET", SECRET_KEY)
|
|
JWT_EXPIRES_SECONDS = int(os.getenv("JWT_EXPIRES_SECONDS", "600"))
|
|
OAUTH_STATE_EXPIRES_SECONDS = int(os.getenv("OAUTH_STATE_EXPIRES_SECONDS", "300"))
|
|
LOGIN_CODE_EXPIRES_SECONDS = int(os.getenv("LOGIN_CODE_EXPIRES_SECONDS", "120"))
|
|
|
|
NETMAKER_BASE_URL = os.getenv("NETMAKER_BASE_URL", "")
|
|
NETMAKER_API_TOKEN = os.getenv("NETMAKER_API_TOKEN", "")
|
|
NETMAKER_NETWORK_ID = os.getenv("NETMAKER_NETWORK_ID", "")
|
|
NETMAKER_ENROLLMENT_TAGS = [
|
|
item.strip()
|
|
for item in os.getenv("NETMAKER_ENROLLMENT_TAGS", "homevpn,desktop,vpn").split(",")
|
|
if item.strip()
|
|
]
|
|
NETMAKER_ENROLLMENT_TTL_SECONDS = int(os.getenv("NETMAKER_ENROLLMENT_TTL_SECONDS", "600"))
|