Files
bourbonacci/backend/app/main.py
T
derekcandClaude Opus 5.5 6272322f31 feat(admin): rebuild admin panel as out-of-band login with backups
- Separate admin login (ADMIN_USERNAME/ADMIN_PASSWORD) with its own JWT,
  no longer a seeded user account; lockout after 5 failed attempts
- Admin panel tabs: Users, Notifications, Backups, Reset
- Ntfy settings moved from .env/compose into admin_settings (token encrypted)
- Scheduled and on-demand mariadb-dump backups to NFS volume, with
  restore (entries only or all) and retention pruning
- Reset all entries, guarded by an automatic safety backup
- Remove user impersonation and the admin link in the user nav
- Login page falls back to admin login; nginx sends Cache-Control: no-cache

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 00:24:19 -08:00

55 lines
1.4 KiB
Python

import logging
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from slowapi import _rate_limit_exceeded_handler
from slowapi.errors import RateLimitExceeded
from app.config import settings
from app import scheduler
from app.database import init_db
from app.limiter import limiter
from app.routers import auth, users, entries, public, admin, backups
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s %(message)s",
)
logger = logging.getLogger("bourbonacci")
@asynccontextmanager
async def lifespan(app: FastAPI):
await init_db()
await scheduler.start()
logger.info("Bourbonacci started")
yield
scheduler.shutdown()
logger.info("Bourbonacci shutting down")
app = FastAPI(title="Bourbonacci", lifespan=lifespan)
app.state.limiter = limiter
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
app.add_middleware(
CORSMiddleware,
allow_origins=[o.strip() for o in settings.allowed_origins.split(",")],
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(auth.router)
app.include_router(users.router)
app.include_router(entries.router)
app.include_router(public.router)
app.include_router(admin.router)
app.include_router(backups.router)
@app.get("/health")
async def health():
return {"status": "ok"}