The dashboard had one shared password and no concept of a user. This adds real accounts: a username field on the login page, per-user credentials, and the signed-in user recorded on the session, which is the groundwork for per-user permissions later. Credentials are salted pbkdf2 hashes in settings.json's `users` map. Three deliberate choices there: - settings.json rather than an env var, because a pbkdf2 hash contains '$' and docker compose interpolates that when it reads .env. It's also already the bind-mounted file that survives `up -d --build`. - pbkdf2 rather than Werkzeug's default scrypt, which needs a hashlib built against OpenSSL — the macOS system Python has no hashlib.scrypt and would raise at hash time. - load_users() re-reads the file per check, so adding a user or changing a password is live in every gunicorn worker with no restart. The old _runtime_password was per-worker and only ever half-applied. Multi-user activates only once an account exists. Until then the original LOGIN_PASSWORD path is used unchanged and the username field is hidden, so deploying this can't lock the existing install out. manage_users.py prompts for passwords via getpass — never echoed, never a CLI argument — and only ever writes hashes; it refuses to remove the last account, which would silently drop the dashboard back to the shared password. Two fixes carried along: login no longer requires the LOGIN_PASSWORD env var specifically, so a settings.json-only password works instead of locking you out; and the legacy comparison now uses hmac.compare_digest, which the old docstring claimed but '==' didn't provide. Also gitignores settings.json and data/ — they hold API keys and now password hashes, were excluded from the deploy rsync but not from git. Verified: legacy fallback still signs in with no accounts configured; a 9-case credential matrix (right/wrong user x right/wrong password, plus the retired shared password); per-user change-password scoped to the signed-in account and live without restart; and the add/passwd/remove guards. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
52 lines
2 KiB
HTML
52 lines
2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Sign in — Media Centre</title>
|
|
<link rel="icon" href="{{ url_for('static', filename='favicon.svg') }}">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/login.css') }}">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="wrap">
|
|
|
|
<div class="brand">
|
|
<svg width="30" height="30" viewBox="0 0 100 100" aria-hidden="true">
|
|
<rect width="100" height="100" rx="22" fill="var(--accent)"/>
|
|
<path d="M40 32 L72 50 L40 68 Z" fill="var(--bg)"/>
|
|
</svg>
|
|
<h1>Media Centre</h1>
|
|
</div>
|
|
|
|
<div class="card">
|
|
{% if error %}
|
|
<div class="error-msg" role="alert">{{ error }}</div>
|
|
{% endif %}
|
|
|
|
<form method="POST" action="{{ url_for('login', next=request.args.get('next', '')) }}">
|
|
{# The username field only appears once accounts exist in
|
|
settings.json. A single-password install never sees a box it
|
|
would have to leave blank. #}
|
|
{% if multi_user %}
|
|
<label for="username">Username</label>
|
|
<input type="text" id="username" name="username"
|
|
placeholder="Enter username" autofocus autocomplete="username"
|
|
autocapitalize="none" autocorrect="off" spellcheck="false">
|
|
{% endif %}
|
|
<label for="password"{% if multi_user %} class="stacked"{% endif %}>Password</label>
|
|
<input type="password" id="password" name="password"
|
|
placeholder="Enter password"{% if not multi_user %} autofocus{% endif %}
|
|
autocomplete="current-password">
|
|
<button type="submit">Sign in</button>
|
|
</form>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|