furtka/tests
Daniel Maksymilian Syrnicki 470823b347
All checks were successful
Build ISO / build-iso (push) Successful in 17m30s
CI / lint (push) Successful in 27s
CI / test (push) Successful in 43s
CI / validate-json (push) Successful in 31s
CI / markdown-links (push) Successful in 15s
Release / release (push) Successful in 11m38s
feat(auth): login-guard the Furtka UI with a cookie session
One-admin, one-password model — all of /apps, /api/*, /, and
/settings/ now require a signed-in session. Passwords are werkzeug
PBKDF2-hashed in /var/lib/furtka/users.json (mode 0600, atomic write
via the same .tmp+chmod+rename dance installer.write_env uses).
Sessions are secrets.token_urlsafe(32) tokens held in a module-level
SessionStore dict (thread-safe lock included for when we swap to
ThreadingHTTPServer). Cookies are HttpOnly, SameSite=Strict, and
Path=/, with Secure set when X-Forwarded-Proto from Caddy says HTTPS.

Two bootstrap paths:
  * Fresh install — webinstaller step-1 collects Linux user + password,
    the chroot post-install step hashes the password and writes
    users.json on the target partition. First browser visit lands on
    /login with the account already present.
  * Upgrade from 26.10-alpha — no users.json yet, so /login detects
    setup_needed() and renders a first-run setup form. POST creates
    the admin and immediately logs in.

POST /logout revokes the server session and clears the cookie.
Unauthenticated HTML requests 302 to /login; unauthenticated API
requests 401 JSON so fetch() callers see a clean error. A sleep(0.5)
on failed logins is the brute-force speed bump on top of werkzeug's
~600k-iter PBKDF2.

Caddyfile gains /login* and /logout* handle blocks in the shared
furtka_routes snippet so both :80 and the HTTPS hostname block
forward the auth endpoints to localhost:7000. Without this Caddy
would 404 from the static file server.

Test surface:
  * tests/test_auth.py (new, 19 cases): hash roundtrip, users.json
    I/O, session create/lookup/expire/revoke.
  * tests/test_api.py: new admin_session fixture; existing HTTP
    tests updated to send the cookie; new tests cover login setup,
    login success, wrong-password 401, logout revocation, and the
    guard's 302/401 split.
  * tests/test_webinstaller_assets.py: new case that unpacks the
    users.json _write_file_cmd body and verifies the werkzeug hash
    round-trips against the step-1 password.

Bumped version to 26.11-alpha and rolled CHANGELOG. Also folded in
the ruff-format fix that was pending from 26.10-alpha's lint red.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 13:01:17 +02:00
..
test_api.py feat(auth): login-guard the Furtka UI with a cookie session 2026-04-21 13:01:17 +02:00
test_app.py feat(furtka): serve from /opt/furtka/current, retire /srv/furtka/www/ 2026-04-16 13:15:59 +02:00
test_auth.py feat(auth): login-guard the Furtka UI with a cookie session 2026-04-21 13:01:17 +02:00
test_catalog.py feat(catalog): on-box apps catalog synced independently of core version 2026-04-20 14:16:02 +02:00
test_cli.py chore: release 26.9-alpha 2026-04-20 18:51:30 +02:00
test_drives.py feat(webinstaller): plain-English drive picker on step 2 2026-04-16 12:01:57 +02:00
test_https.py feat(https): local HTTPS via Caddy tls internal + opt-in redirect toggle 2026-04-17 12:19:06 +02:00
test_installer.py style(tests): reflow OPTIONAL_PATH_MANIFEST to match ruff format 2026-04-21 11:56:52 +02:00
test_manifest.py feat(manifest): add 'path' setting type with server-side validation 2026-04-21 11:39:15 +02:00
test_reconciler.py fix(furtka): audit follow-ups — placeholder secrets, isolate reconcile, .env perms 2026-04-15 10:17:00 +02:00
test_scanner.py feat(furtka): resource-manager skeleton — manifest, scanner, CLI 2026-04-15 09:59:41 +02:00
test_sources.py feat(catalog): on-box apps catalog synced independently of core version 2026-04-20 14:16:02 +02:00
test_updater.py feat(catalog): on-box apps catalog synced independently of core version 2026-04-20 14:16:02 +02:00
test_webinstaller_assets.py feat(auth): login-guard the Furtka UI with a cookie session 2026-04-21 13:01:17 +02:00