ddd15cae0f
Steps 3–7 of the migration plan: - models.py: Pydantic request/response types - deps.py: shared state, JWT-based auth helpers, rate limiting - server.py: FastAPI app with CORS + gzip - routers/auth.py: login, logout, /api/me, reset-password, register - routers/invites.py: GET/POST /api/invites - routers/admin.py: user listing, suspend/unsuspend, delete, access flags, reset-password-code - cli.py: `bincio-auth init` (creates DB + admin + JWT secret) and `bincio-auth serve` Cookie carries a signed JWT (HS256); consumers validate locally with shared secret.
24 lines
706 B
Python
24 lines
706 B
Python
"""bincio-auth FastAPI application."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.middleware.gzip import GZipMiddleware
|
|
|
|
from bincio.auth.routers import admin, auth, invites
|
|
|
|
app = FastAPI(title="bincio-auth")
|
|
|
|
app.add_middleware(GZipMiddleware, minimum_size=1024)
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origin_regex=r"https?://localhost(:\d+)?|https://[a-z0-9-]+\.bincio\.org",
|
|
allow_credentials=True,
|
|
allow_methods=["GET", "POST", "DELETE", "PATCH"],
|
|
allow_headers=["Content-Type", "Authorization"],
|
|
)
|
|
|
|
for _router in [auth.router, invites.router, admin.router]:
|
|
app.include_router(_router)
|