- Establish application-level browser session management backed by InMemorySessionStore - Issue HttpOnly=True, SameSite=lax session cookies with configurable Secure flag - Enforce Session Fixation Barrier by rotating session IDs and invalidating pre-auth sessions upon authentication - Provide session resolution, HMAC-SHA256 tamper rejection, expiration pruning, and explicit logout revocation with Max-Age=0 - Mount /birthday/api/auth endpoints (login, callback, logout, me) - Add comprehensive unit and HTTP integration test coverage
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
from pathlib import Path
|
|
from typing import Literal
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
SERVICE_NAME: str = "bdinvite"
|
|
SERVICE_DOMAIN: str = "demos.roadtotech.me"
|
|
BASE_PATH: str = "/birthday"
|
|
APP_PORT: int = 8000
|
|
DATABASE_URL: str = "sqlite:///./data/bdinvite.db"
|
|
DATA_DIR: str = "./data"
|
|
OIDC_ISSUER: str = "http://localhost:8088/default"
|
|
OIDC_CLIENT_ID: str = "bdinvite-client"
|
|
OIDC_CLIENT_SECRET: str = "bdinvite-secret"
|
|
OIDC_REDIRECT_URI: str = "http://localhost:8000/birthday/api/auth/callback"
|
|
OIDC_GROUPS_CLAIM: str = "groups"
|
|
SESSION_COOKIE_NAME: str = "bdinvite_session"
|
|
SESSION_COOKIE_SECURE: bool = False
|
|
SESSION_COOKIE_SAMESITE: Literal["lax", "strict", "none"] = "lax"
|
|
SESSION_COOKIE_HTTPONLY: bool = True
|
|
SESSION_MAX_AGE_SECONDS: int = 86400
|
|
SESSION_SECRET_KEY: str = "bdinvite-session-secret-key-change-in-prod"
|
|
|
|
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
|
|
|
@property
|
|
def data_path(self) -> Path:
|
|
return Path(self.DATA_DIR).resolve()
|
|
|
|
@property
|
|
def map_preview_file(self) -> Path:
|
|
return self.data_path / "map_preview.png"
|
|
|
|
|
|
settings = Settings()
|
|
|