feat: add domain in cookie and cors

This commit is contained in:
2026-05-12 19:25:16 +03:00
parent 8347ff40f4
commit 2d9f44979c
4 changed files with 25 additions and 8 deletions

View File

@@ -55,9 +55,11 @@ class Settings(BaseSettings):
CSRF_COOKIE_HTTPONLY: bool = True
CSRF_COOKIE_SAMESITE: Literal['Lax', 'Strict', 'None'] = 'Lax'
CSRF_COOKIE_PATH: str = '/'
CSRF_COOKIE_DOMAIN: str | None = None
CSRF_COOKIE_DOMAIN: str | None = 'elcsa.ru'
AUTH_COOKIE_SECURE: bool = False
AUTH_COOKIE_DOMAIN: str | None = 'elcsa.ru'
CORS_ALLOW_ORIGIN_REGEX: str = r'https?://([a-z0-9-]+\.)*elcsa\.ru(:\d+)?$'
DOCS_USERNAME: str = 'admin'
DOCS_PASSWORD: str = 'admin'
@@ -103,6 +105,13 @@ class Settings(BaseSettings):
return None
return v
@field_validator('AUTH_COOKIE_DOMAIN', mode='before')
@classmethod
def empty_auth_domain_to_none(cls, v):
if v is None or (isinstance(v, str) and not v.strip()):
return None
return v
@field_validator('REDIS_PASSWORD', mode='before')
@classmethod
def empty_redis_password_to_none(cls, v):