feat(auth): public read-only HUD, admin-only API keys and mutations
Adds single-admin authentication to the dashboard. Anonymous visitors get a
read-only site (map + news); the one admin unlocks everything else.
- app/auth.py: deny-by-default ASGI middleware on /api/* with an explicit
public read allowlist; /login page; /api/auth/{login,logout,me}; PBKDF2
password hashing; HMAC-signed HttpOnly SameSite=Lax session cookie (7d,
Secure behind X-Forwarded-Proto: https); 5-fail/15-min per-IP login limit;
Origin/Referer host check on state-changing admin requests.
- Fails closed: missing ADMIN_PASSWORD_HASH or ADMIN_SESSION_SECRET -> admin
routes 403 'admin auth not configured', public site unaffected.
- app/main.py: mounts the middleware + router (6 lines, no per-route decorators).
- app/static/index.html: hides Ingest/API Keys/Settings, the summarizer panel
and geofence write controls until /api/auth/me says admin; adds a discreet
SIGN IN link to /login. CSS gates fail closed without JS.
- tests/test_auth.py: 42 tests (anonymous 401s, login/logout, tampered and
expired cookies, fail-closed, rate limit, CSRF, HUD markup).
- Existing API tests now send an admin session cookie for admin routes.
Public allowlist extends the spec's list with the remaining read-only GETs the
HUD calls (/api/stats, /api/conflicts, /api/place, /api/satellites,
/api/infrastructure, /api/map/gpsjam, /api/map/times, /api/fire-incidents,
/api/fire-perimeters, /api/weather-alerts, /api/storms, /api/geofences/{id}/at)
so an anonymous HUD is not half-broken.
This commit is contained in:
parent
38eb4fe4d6
commit
c0a2454fdd
11 changed files with 1283 additions and 14 deletions
10
.env.example
10
.env.example
|
|
@ -69,6 +69,16 @@ VESSELAPI_IN_INGEST=0
|
|||
# (GET/POST/DELETE /api/keys/{name}) — see app/keystore.py. The FIRMS ingestor
|
||||
# currently reads FIRMS_MAP_KEY from .env (above); wiring the Keys-UI store as
|
||||
# its lookup/fallback is a planned follow-up.
|
||||
#
|
||||
# Key management is ADMIN-ONLY (single admin, no user table). Visitors get a
|
||||
# read-only map + news. Configure the three vars below or admin endpoints
|
||||
# answer 403 {"detail": "admin auth not configured"} (fail closed — the public
|
||||
# site keeps working). In the cluster they come from Secret `osint-admin`.
|
||||
# Generate the hash: python app/auth.py hash 'your password'
|
||||
# Generate the secret: python -c 'import secrets; print(secrets.token_urlsafe(48))'
|
||||
ADMIN_USER=
|
||||
ADMIN_PASSWORD_HASH=
|
||||
ADMIN_SESSION_SECRET=
|
||||
|
||||
# ── News pipeline (scraper + summarizer, profile `ingest`) ────────────────
|
||||
# Scraper crawls urls.txt continuously (default 10s between crawls).
|
||||
|
|
|
|||
Loading…
Reference in a new issue