Roadmap #6: Password-manager-friendly login form #106
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The web UI currently uses HTTP Basic Auth, which modern password managers handle inconsistently and which does not support a proper logout flow. A standard HTML login form backed by a signed session cookie would be far more compatible with password managers and would give users an explicit log-out action.
Plan of attack
Replaced the
HTTPBasicAuthdependency with a stateless HMAC-SHA256 signed cookie. The secret key is derived from the configured password (SHA-256(password.encode())), so rotating the password automatically invalidates all existing sessions.Key files:
src/cang/web/auth.py— complete rewrite; exportslogin_router(GET/POST /login, GET /logout),require_authdependency, andNotAuthenticatedException; cookie name:cang_session, value:auth.<hmac-hex>src/cang/web/app.py— registerslogin_routerwithout auth dependency; adds@app.exception_handler(NotAuthenticatedException)→ 303 to/login?next=<path>; addsauth_enabledJinja2 globalsrc/cang/web/templates/login.html— new login form withautocomplete="username"andautocomplete="current-password"for password manager compatibilitysrc/cang/web/templates/base.html— conditional Log out link whenauth_enabled_safe_nextvalidates thenextparam must start with/and not//