The web UI is protected by HTTP Basic auth with a single username and password from the config ([ui] username/password). That works, but:
there's no way to log out; the browser keeps sending the credentials until it's closed;
the browser's own password prompt can't be styled, works poorly with password managers and gives no feedback;
nothing limits repeated guesses;
the password sits in plain text in the config file or environment;
Basic auth from a reverse proxy clashes with jellymove's own, since a request carries only one Authorization header.
Proposal
Replace Basic auth for the UI with a login page and accounts kept in the agent's SQLite database.
Accounts
New migration with a users table: username, password hash, created/last-login times. Append to MIGRATIONS, don't edit existing entries.
Hash with Argon2id (the argon2 crate) and a per-user salt. Never store or log plain passwords.
Manage accounts from the CLI, which needs shell access to the machine: jellymove user add <name>, jellymove user passwd <name>, jellymove user remove <name>, jellymove user list. Read passwords from a prompt or stdin, never from arguments.
No web sign-up and no "first visitor creates the admin" page: on a public VPS, whoever got there first would own it.
Upgrade path: if [ui] username/password is set and no users exist, create that user on start-up and log a warning to remove the password from the config.
Sessions
POST /api/login checks the password and sets a session cookie: random token, HttpOnly, SameSite=Strict, Secure when served over HTTPS, Path matching where the UI is served. Store only a hash of the token in SQLite, with an expiry (e.g. 30 days, renewed on use).
POST /api/logout deletes the session. A "Log out" button in the header.
Changing or removing a user's password ends their sessions.
/api/* returns 401 without a valid session and the UI shows the login page. Don't send WWW-Authenticate, so the browser doesn't pop up its own prompt.
Keep the X-Jellymove CSRF header check on state-changing requests.
Guessing
Limit failed logins per IP and per username (e.g. 5 per 15 minutes), with the same "wrong username or password" message either way.
Take the client IP from X-Forwarded-For only when a trusted_proxies setting says so, otherwise anyone can pretend to be anyone.
Unchanged
/peer/v1/* keeps using the peer token and never needs a login.
With no users and no [ui] password, the UI stays open as today, and the Status tab warns that it has no login.
Done when
Logging in, logging out and session expiry work, and an e2e test covers: no session → 401, wrong password → 401, right password → cookie → API works, logout → 401, password change ends sessions, peer routes unaffected.
The rate limit has a test.
A database from v0.2.x upgrades, and a [ui] password becomes the first user.
README and config.example.toml describe the jellymove user commands and the upgrade, and CLAUDE.md/ARCHITECTURE.md describe the auth model.
Notes
Related to #7: the cookie Path must follow the path the UI is served under.
Not in scope: roles/permissions, single sign-on (OIDC), two-factor auth.
## Problem
The web UI is protected by HTTP Basic auth with a single username and password from the config (`[ui] username/password`). That works, but:
- there's no way to log out; the browser keeps sending the credentials until it's closed;
- the browser's own password prompt can't be styled, works poorly with password managers and gives no feedback;
- nothing limits repeated guesses;
- the password sits in plain text in the config file or environment;
- Basic auth from a reverse proxy clashes with jellymove's own, since a request carries only one `Authorization` header.
## Proposal
Replace Basic auth for the UI with a login page and accounts kept in the agent's SQLite database.
**Accounts**
- New migration with a `users` table: username, password hash, created/last-login times. Append to `MIGRATIONS`, don't edit existing entries.
- Hash with Argon2id (the `argon2` crate) and a per-user salt. Never store or log plain passwords.
- Manage accounts from the CLI, which needs shell access to the machine: `jellymove user add <name>`, `jellymove user passwd <name>`, `jellymove user remove <name>`, `jellymove user list`. Read passwords from a prompt or stdin, never from arguments.
- No web sign-up and no "first visitor creates the admin" page: on a public VPS, whoever got there first would own it.
- Upgrade path: if `[ui] username/password` is set and no users exist, create that user on start-up and log a warning to remove the password from the config.
**Sessions**
- `POST /api/login` checks the password and sets a session cookie: random token, `HttpOnly`, `SameSite=Strict`, `Secure` when served over HTTPS, `Path` matching where the UI is served. Store only a hash of the token in SQLite, with an expiry (e.g. 30 days, renewed on use).
- `POST /api/logout` deletes the session. A "Log out" button in the header.
- Changing or removing a user's password ends their sessions.
- `/api/*` returns 401 without a valid session and the UI shows the login page. Don't send `WWW-Authenticate`, so the browser doesn't pop up its own prompt.
- Keep the `X-Jellymove` CSRF header check on state-changing requests.
**Guessing**
- Limit failed logins per IP and per username (e.g. 5 per 15 minutes), with the same "wrong username or password" message either way.
- Take the client IP from `X-Forwarded-For` only when a `trusted_proxies` setting says so, otherwise anyone can pretend to be anyone.
**Unchanged**
- `/peer/v1/*` keeps using the peer token and never needs a login.
- With no users and no `[ui]` password, the UI stays open as today, and the Status tab warns that it has no login.
## Done when
- Logging in, logging out and session expiry work, and an e2e test covers: no session → 401, wrong password → 401, right password → cookie → API works, logout → 401, password change ends sessions, peer routes unaffected.
- The rate limit has a test.
- A database from v0.2.x upgrades, and a `[ui]` password becomes the first user.
- README and `config.example.toml` describe the `jellymove user` commands and the upgrade, and CLAUDE.md/ARCHITECTURE.md describe the auth model.
## Notes
- Related to #7: the cookie `Path` must follow the path the UI is served under.
- Not in scope: roles/permissions, single sign-on (OIDC), two-factor auth.
ClaudeBot
added this to the v0.3.0 milestone 2026-11-09 11:40:33 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
The web UI is protected by HTTP Basic auth with a single username and password from the config (
[ui] username/password). That works, but:Authorizationheader.Proposal
Replace Basic auth for the UI with a login page and accounts kept in the agent's SQLite database.
Accounts
userstable: username, password hash, created/last-login times. Append toMIGRATIONS, don't edit existing entries.argon2crate) and a per-user salt. Never store or log plain passwords.jellymove user add <name>,jellymove user passwd <name>,jellymove user remove <name>,jellymove user list. Read passwords from a prompt or stdin, never from arguments.[ui] username/passwordis set and no users exist, create that user on start-up and log a warning to remove the password from the config.Sessions
POST /api/loginchecks the password and sets a session cookie: random token,HttpOnly,SameSite=Strict,Securewhen served over HTTPS,Pathmatching where the UI is served. Store only a hash of the token in SQLite, with an expiry (e.g. 30 days, renewed on use).POST /api/logoutdeletes the session. A "Log out" button in the header./api/*returns 401 without a valid session and the UI shows the login page. Don't sendWWW-Authenticate, so the browser doesn't pop up its own prompt.X-JellymoveCSRF header check on state-changing requests.Guessing
X-Forwarded-Foronly when atrusted_proxiessetting says so, otherwise anyone can pretend to be anyone.Unchanged
/peer/v1/*keeps using the peer token and never needs a login.[ui]password, the UI stays open as today, and the Status tab warns that it has no login.Done when
[ui]password becomes the first user.config.example.tomldescribe thejellymove usercommands and the upgrade, and CLAUDE.md/ARCHITECTURE.md describe the auth model.Notes
Pathmust follow the path the UI is served under.