Remove all authentication (login, sessions, bcrypt, itsdangerous) since the app runs on a private homelab LAN. Replace with a profile picker landing page and cookie-based profile selection (1-year expiry). - Add Alembic migration to drop password_hash/is_admin columns - Delete auth service, auth routes, login template, and auth tests - Rewrite app/utils/auth.py with NoProfileSelectedError and require_active_profile dependency - Add profile creation flow (GET/POST /profiles/create) - Rewrite home page as profile picker with card layout - Update all route files to use profile dependency instead of admin auth - Remove bcrypt and itsdangerous from requirements - Remove admin_username/admin_password from config - Update all tests for new profile-based access model Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
"""Application configuration loader.
|
|
|
|
Reads environment variables (with .env file support) and provides
|
|
a typed, validated Settings object used throughout the application.
|
|
"""
|
|
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
from pydantic_settings import BaseSettings
|
|
from pydantic_settings import SettingsConfigDict
|
|
|
|
# Load .env file from project root
|
|
_env_path = Path(__file__).resolve().parent.parent / ".env"
|
|
load_dotenv(_env_path)
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Typed application settings loaded from environment variables.
|
|
|
|
Attributes:
|
|
app_env: Runtime environment — 'development' or 'production'.
|
|
app_host: Host address to bind the server to.
|
|
app_port: Port number for the server.
|
|
app_log_level: Minimum log level for structlog output.
|
|
database_url: SQLite connection string.
|
|
"""
|
|
|
|
app_env: str = "development"
|
|
app_host: str = "0.0.0.0"
|
|
app_port: int = 8000
|
|
app_log_level: str = "info"
|
|
database_url: str = "sqlite:///data/sneakyswole.db"
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
|
|
@lru_cache(maxsize=1)
|
|
def get_settings() -> Settings:
|
|
"""Return a cached Settings instance (singleton pattern).
|
|
|
|
Returns:
|
|
The application Settings object.
|
|
"""
|
|
return Settings()
|