feat: implement auth, projects, and frontend foundation
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
from pydantic import Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
def build_database_url(
|
||||
*,
|
||||
user: str,
|
||||
password: str,
|
||||
host: str,
|
||||
port: int,
|
||||
database: str,
|
||||
) -> str:
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{database}"
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
app_env: str = "development"
|
||||
database_url_override: str | None = Field(default=None, alias="DATABASE_URL")
|
||||
postgres_user: str = "headquarter"
|
||||
postgres_password: str = "headquarter"
|
||||
postgres_host: str = "postgres"
|
||||
postgres_port: int = 5432
|
||||
postgres_db: str = "headquarter"
|
||||
|
||||
authentik_client_id: str = "headquarter-web"
|
||||
authentik_client_secret: str = "change-me"
|
||||
authentik_authorize_url: str = "https://authentik.local/application/o/authorize/"
|
||||
authentik_token_url: str = "https://authentik.local/application/o/token/"
|
||||
authentik_jwks_url: str = "https://authentik.local/application/o/headquarter-web/jwks/"
|
||||
authentik_issuer: str = "https://authentik.local/application/o/headquarter-web/"
|
||||
authentik_audience: str = "headquarter-web"
|
||||
|
||||
jwt_secret: str = "change-me-jwt-secret"
|
||||
jwt_algorithm: str = "HS256"
|
||||
access_token_ttl_minutes: int = 15
|
||||
refresh_token_ttl_days: int = 7
|
||||
|
||||
model_config = SettingsConfigDict(env_file=".env", extra="ignore", populate_by_name=True)
|
||||
|
||||
@property
|
||||
def database_url(self) -> str:
|
||||
if self.database_url_override:
|
||||
return self.database_url_override
|
||||
|
||||
return build_database_url(
|
||||
user=self.postgres_user,
|
||||
password=self.postgres_password,
|
||||
host=self.postgres_host,
|
||||
port=self.postgres_port,
|
||||
database=self.postgres_db,
|
||||
)
|
||||
|
||||
@property
|
||||
def cookie_secure(self) -> bool:
|
||||
return self.app_env == "production"
|
||||
|
||||
@property
|
||||
def cookie_samesite(self) -> str:
|
||||
if self.app_env == "production":
|
||||
return "strict"
|
||||
|
||||
return "lax"
|
||||
Reference in New Issue
Block a user