Repository navigation
feat(web): token login page with persisted sessions - #30
Merged
Merged
Conversation
Replace the raw-token cookie with a sign-in flow for servers started with
NEX_SERVER_AUTH_TOKEN.
- Server: /api/auth/{session,login,logout}; random session ids, stored hashed
in <configDir>/web-sessions.json (0600, atomic writes) and discarded when
the token changes; per-address login rate limit; ?token= still works for
programmatic /ws clients and first visits.
- Web: /login page (token only), redirect to /login?next=... when there is no
valid session, return to the original page after login, and back to /login
if the session is lost while the app is open.
- Spec: docs/specs/web-token-login.md. CI now runs the server and web unit tests.
This was referenced Oct 8, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Servers started with
NEX_SERVER_AUTH_TOKENnow show a sign-in page instead of a half-working app when the browser has no valid session. Spec:docs/specs/web-token-login.md./login): one field, the access token. No/invalid session sends the browser to/login?next=<original page>; after login it returns there.nextonly accepts same-origin relative paths.nex_sessioncookie (HttpOnly, SameSite=Lax, Secure behind https, 30 days). Session ids are stored as SHA-256 hashes in<configDir>/web-sessions.json(0600, atomic write). Changing the token invalidates all stored sessions. A corrupt file fails closed.?token=still works for programmatic/ws//apiclients, and/?token=…still signs in a browser (then the token is removed from the address bar)./login. Plain disconnects are not treated as logout; checks retry with backoff while the server restarts.Behaviour change
The old
nex_lite_tokencookie (which held the raw token) is no longer accepted. Existing browsers see the login page once. Provisioning (install.sh, plist, docker-compose) is unchanged.Testing
pnpm typecheck: pass;pnpm lint: 0 errors (80 existing warnings);pnpm architecture:check --changed: 0 new violations/loginwhile signed in, open-redirectnextignored, deep link preserved,?token=first visit and address-bar cleanup, logout, restart with same token keeps the user in, token rotation while open returns to login, 6th bad attempt rate-limited