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:
1 parent
c54d2b251f
commit
6272322f31
28 files changed
+1523
-461
No files matched your search
@@ -0,0 +1,34 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, Integer, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class AdminSettings(Base):
|
||||
"""Single-row table (id=1) holding admin-only config that's edited live from the admin panel."""
|
||||
|
||||
__tablename__ = "admin_settings"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
ntfy_server_url: Mapped[Optional[str]] = mapped_column(String(255))
|
||||
ntfy_topic: Mapped[Optional[str]] = mapped_column(String(255))
|
||||
ntfy_token: Mapped[Optional[str]] = mapped_column(String(500))
|
||||
|
||||
# Scheduled backups (see routers/backups.py, services/backup.py).
|
||||
backup_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||||
backup_frequency: Mapped[str] = mapped_column(String(10), nullable=False, default="daily")
|
||||
backup_hour: Mapped[int] = mapped_column(Integer, nullable=False, default=3) # 0-23, UTC
|
||||
backup_weekday: Mapped[int] = mapped_column(Integer, nullable=False, default=0) # 0=Mon, used if weekly
|
||||
backup_retention: Mapped[int] = mapped_column(Integer, nullable=False, default=14)
|
||||
# Optional subfolder under the mounted /backups directory.
|
||||
backup_location: Mapped[Optional[str]] = mapped_column(String(255))
|
||||
last_backup_at: Mapped[Optional[datetime]] = mapped_column(DateTime) # UTC
|
||||
last_backup_status: Mapped[Optional[str]] = mapped_column(String(20)) # "success" | "error"
|
||||
last_backup_error: Mapped[Optional[str]] = mapped_column(String(2000))
|
||||
|
||||
# Brute-force protection for the out-of-band admin login.
|
||||
admin_failed_attempts: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
admin_locked_until: Mapped[Optional[datetime]] = mapped_column(DateTime) # UTC
|
||||
Reference in new issue
Block a user