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]>
This commit is contained in:
derekcandClaude Opus 5.5 committed 2026-11-23 00:24:19 -08:00
1 parent c54d2b251f
commit 6272322f31
28 files changed
+1523 -461

No files matched your search

+6 -23
View File
@@ -3,14 +3,14 @@ from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from sqlalchemy import select
from slowapi import _rate_limit_exceeded_handler
from slowapi.errors import RateLimitExceeded
from app.config import settings
from app.database import init_db, AsyncSessionLocal
from app import scheduler
from app.database import init_db
from app.limiter import limiter
from app.routers import auth, users, entries, public, admin
from app.routers import auth, users, entries, public, admin, backups
logging.basicConfig(
level=logging.INFO,
@@ -19,31 +19,13 @@ logging.basicConfig(
logger = logging.getLogger("bourbonacci")
async def _seed_admin() -> None:
from app.models.user import User
from app.utils.security import hash_password
async with AsyncSessionLocal() as db:
result = await db.execute(select(User).where(User.email == settings.admin_username))
user = result.scalar_one_or_none()
if user is None:
db.add(User(
email=settings.admin_username,
password_hash=hash_password(settings.admin_password),
display_name="Admin",
is_admin=True,
))
elif not user.is_admin:
user.is_admin = True
await db.commit()
@asynccontextmanager
async def lifespan(app: FastAPI):
await init_db()
await _seed_admin()
await scheduler.start()
logger.info("Bourbonacci started")
yield
scheduler.shutdown()
logger.info("Bourbonacci shutting down")
@@ -64,6 +46,7 @@ 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")