[PR #8061] [MERGED] feat: remote login settings, signed-in devices and pairing codes (#7912) #8082

Closed
opened 2026-10-24 04:10:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8061
Author: @Gunterlie
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @Gunterlie

Base: feat/7912-remote-login ← Head: feat/remote-login-ui-7912


📝 Commits (8)

  • 576398c chore: start remote login settings, sessions and pairing codes (#7912)
  • d4c9837 feat(server): pairing codes, refused-device list and sign-out-others (#7912)
  • cba4607 feat(client): remote login, signed-in devices and Add a device in Settings (#7912)
  • 97bd2cd fix(server): let the sign-in form post on plain HTTP; hide stale no-login refusals (#7912)
  • 3cf88c7 test: expect loginUser in the access status (#7912)
  • 60a17bc style: prettier (#7912)
  • 2c150dc fix(client): steady accent for errors, one-sentence copy (#7912)
  • f87b2b7 fix(server): end pairing codes with their sessions and merge allowlist refusals (#7912)

📊 Changes

15 files changed (+731 additions, -16 deletions)

View changed files

📝 packages/client/src/components/diagnostics/use-access-warning-banner.tsx (+1 -0)
➕ packages/client/src/components/diagnostics/use-refused-device-banners.tsx (+40 -0)
📝 packages/client/src/components/layout/AppBannerHost.tsx (+7 -1)
📝 packages/client/src/components/panels/settings/AccessStatusSettings.tsx (+7 -1)
➕ packages/client/src/components/panels/settings/RemoteLoginSettings.tsx (+262 -0)
➕ packages/client/src/hooks/use-remote-login.ts (+48 -0)
📝 packages/client/src/localization/locales/en.json (+38 -0)
📝 packages/server/src/config/login-credential.ts (+9 -1)
📝 packages/server/src/middleware/basic-auth.ts (+109 -7)
📝 packages/server/src/middleware/csrf-protection.ts (+12 -2)
📝 packages/server/src/middleware/ip-allowlist.ts (+2 -0)
➕ packages/server/src/middleware/refused-devices.ts (+44 -0)
📝 packages/server/src/routes/access-status.routes.ts (+30 -4)
📝 scripts/regressions/access-status.regression.ts (+1 -0)
📝 scripts/regressions/remote-login.regression.ts (+121 -0)

📄 Description

PR 3 of 4 into the #7912 integration branch (feat/7912-remote-login). Assigned to @SpicyMarinara.

Why

PR 1 and PR 2 gave Marinara a stored app login, a /login page and server-side sessions, but the owner could manage them only through the API. You could not set the password in Settings, see which devices are signed in, or sign in a new device without typing the password on it. An iPhone home-screen app keeps its own cookie jar, so it asks for a fresh sign-in even when Safari is already signed in. And when a device was refused, the owner saw nothing in the app.

While testing on a real browser I also found that the /login form from PR 2 did not work over plain HTTP on a LAN address: the browser sends no Sec-Fetch-Site there, and the page's no-referrer policy turns the form's Origin into null, so the CSRF hook refused every sign-in (403). This PR fixes that too, because pairing codes use the same form.

What changed

Settings → Advanced → Access (the existing section, so no new settings-registry entry)

  • Remote login: set the login (username + password of at least 10 characters), change the password (username prefilled), or remove it (with a confirmation). The form says that a password change signs out every other device. When .env sets the login, the section says so and shows no write controls, so there is no 409 surprise.
  • Signed-in devices: each device with its label, last activity and a "This device" marker; sign out one device, or all other devices (with a confirmation).
  • Add a device: shows an 8-character code (for example HAEC-J2UZ), valid once for 5 minutes. A signed-in device that is not the owner's computer also sees this block (the rest of the section stays owner-only).

Server

  • POST /api/access/pairing-codes: allowed for a signed-in browser session or a privileged caller (the host, or the admin secret); a plain Basic Authorization script gets 403. 409 when no login exists.
  • Codes use 23456789ABCDEFGHJKMNPQRSTUVWXYZ (no 0/O/1/I/L). Only an HMAC with a per-process key stays in memory, so a restart ends every code. Each code is bound to the current login, so a password change ends open codes. Codes are compared in constant time and work once. At most 10 open codes. Signing out a device ends the codes it made; "sign out all other devices" ends every open code.
  • POST /login accepts code instead of user/password (case, spaces and the dash do not matter) and starts a normal session. Wrong codes count toward the existing wrong-password lockout, and the lockout is checked before the code. A working code clears this browser's own wrong-guess count, like a working password.
  • The sign-in page has a second form, "Sign in with a code".
  • DELETE /api/access/sessions now keeps the caller's own session ("sign out all other devices"). From the host, which has no session, it still signs out everyone.
  • /api/access/status adds loginUser so the form can keep the username.
  • Refused devices: the IP allowlist (403) and the no-login lockdown record the refused device in a short in-memory list (one entry per device and reason, kept 30 minutes after the last try, at most 20). Allowlist refusals with the same device label share one entry, so new addresses do not bring back a dismissed banner. GET /api/access/refusals is loopback-only and returns device label, reason and time, without addresses. Once a login exists, "no login yet" entries are left out.
  • CSRF fix for /login: the login page sets <meta name="referrer" content="same-origin">, and /login also accepts an Origin equal to the server's own origin. Cross-site posts are still refused.
  • Secure cookie only on HTTPS (item 5): checked. isHttpsRequest trusts X-Forwarded-Proto only from a local proxy, so I left it unchanged.

Banner (host only)

  • useRefusedDeviceBanners adds one AppBanner candidate per refused device to the shared AppBannerHost: "A device tried to connect. Marinara turned away Safari on iPhone because remote access has no login yet." with Open access settings. It is a dismissable warning, and its id is stable while the same device keeps trying, so a dismissal holds. Other devices get 403 once and stop polling. The banner shows no IP addresses.

Not in this PR (out of scope)

Passkeys, rolling sessions, multi-user accounts, QR-only pairing, env presets, host approval prompts. Docs for the app login, sessions and pairing codes in docs/REMOTE_ACCESS.md: these are not in PR 1–3; they should come with PR 4 (with a [docs-i18n] follow-up).

Validation (local)

  • remote-login.regression.ts (extended: sign-out-others, pairing create/redeem/single-use/expiry/lockout/password-change, codes ended by logout and by sign-out-others, a good code clears the wrong-guess count, refused-device list incl. merged allowlist entries, plain-HTTP /login origin): pass
  • Related regressions: access-status (updated for loginUser), access-policy, basic-auth-throttle-security, loopback-proxy-auth-security, docker-proxy-auth, docker-gateway-auth-security, android-local-auth, issue-sweep-sep5, encoded-api-path-security, multiplayer-control-security: pass
  • server tsc --noEmit, client tsc -b, pnpm localization:check, pnpm check: pass (one existing lint warning in HomeProfessorMariChat.tsx, not touched here)
  • Real Chromium on a devbox instance: banner, Settings (no login / login / code / devices / .env login / signed-in phone) at 390, 768 and 1440 px; /login with a code at 390, 768 and 1440 px; code sign-in → 303 + session, /api/chats 200 for the paired phone, reused code 401.
  • Local CodeRabbit: first run 2 findings, both fixed (error text now uses the steady theme accent instead of --destructive; new copy shortened to one sentence each). Rerun after the gate-review fixes: 0 findings.

Manual verification

  • Manually verify setting, changing and removing the login in Settings → Advanced → Access on the host.
  • Manually verify that an .env login shows the read-only note and no write controls.
  • Manually verify the signed-in devices list, signing out one device, and signing out all other devices.
  • Manually verify "Add a device" on the host and on a signed-in phone, then sign in with the code on a second phone, including an iPhone home-screen app.
  • Manually verify that a used or expired code is refused on /login.
  • Manually verify password and code sign-in on /login over plain HTTP on a LAN address and over HTTPS.
  • Manually verify the refused-device banner on the host after a refused phone visit, its dismissal, and that it does not come back for the same device right away.
  • Manually verify the Settings section and /login at 390 px in light mode and in the SillyTavern theme.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8061 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `feat/7912-remote-login` ← **Head:** `feat/remote-login-ui-7912` --- ### 📝 Commits (8) - [`576398c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/576398c13b6618ebfa23e2aad89ba7b0519a74f9) chore: start remote login settings, sessions and pairing codes (#7912) - [`d4c9837`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d4c9837fc3cc902dde521dd84f0bb821b31487f8) feat(server): pairing codes, refused-device list and sign-out-others (#7912) - [`cba4607`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cba4607903fcae6b7356001f4dcb94f10000e552) feat(client): remote login, signed-in devices and Add a device in Settings (#7912) - [`97bd2cd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/97bd2cd32b0dd72a9bf989b1f5ecccef3608b4a7) fix(server): let the sign-in form post on plain HTTP; hide stale no-login refusals (#7912) - [`3cf88c7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3cf88c7b38c5afe3ca51cdf3ba0d538e4c688a07) test: expect loginUser in the access status (#7912) - [`60a17bc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/60a17bc8019d966cce9379783078601bdb8ecfec) style: prettier (#7912) - [`2c150dc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2c150dc793f22c09a6337bf136d03d79ae3d9b71) fix(client): steady accent for errors, one-sentence copy (#7912) - [`f87b2b7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f87b2b7487714c19b79adc31ac834fc59790189f) fix(server): end pairing codes with their sessions and merge allowlist refusals (#7912) ### 📊 Changes **15 files changed** (+731 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/diagnostics/use-access-warning-banner.tsx` (+1 -0) ➕ `packages/client/src/components/diagnostics/use-refused-device-banners.tsx` (+40 -0) 📝 `packages/client/src/components/layout/AppBannerHost.tsx` (+7 -1) 📝 `packages/client/src/components/panels/settings/AccessStatusSettings.tsx` (+7 -1) ➕ `packages/client/src/components/panels/settings/RemoteLoginSettings.tsx` (+262 -0) ➕ `packages/client/src/hooks/use-remote-login.ts` (+48 -0) 📝 `packages/client/src/localization/locales/en.json` (+38 -0) 📝 `packages/server/src/config/login-credential.ts` (+9 -1) 📝 `packages/server/src/middleware/basic-auth.ts` (+109 -7) 📝 `packages/server/src/middleware/csrf-protection.ts` (+12 -2) 📝 `packages/server/src/middleware/ip-allowlist.ts` (+2 -0) ➕ `packages/server/src/middleware/refused-devices.ts` (+44 -0) 📝 `packages/server/src/routes/access-status.routes.ts` (+30 -4) 📝 `scripts/regressions/access-status.regression.ts` (+1 -0) 📝 `scripts/regressions/remote-login.regression.ts` (+121 -0) </details> ### 📄 Description PR 3 of 4 into the #7912 integration branch (`feat/7912-remote-login`). Assigned to @SpicyMarinara. ## Why PR 1 and PR 2 gave Marinara a stored app login, a `/login` page and server-side sessions, but the owner could manage them only through the API. You could not set the password in Settings, see which devices are signed in, or sign in a new device without typing the password on it. An iPhone home-screen app keeps its own cookie jar, so it asks for a fresh sign-in even when Safari is already signed in. And when a device was refused, the owner saw nothing in the app. While testing on a real browser I also found that the `/login` form from PR 2 did not work over plain HTTP on a LAN address: the browser sends no `Sec-Fetch-Site` there, and the page's `no-referrer` policy turns the form's `Origin` into `null`, so the CSRF hook refused every sign-in (403). This PR fixes that too, because pairing codes use the same form. ## What changed **Settings → Advanced → Access** (the existing section, so no new settings-registry entry) - **Remote login:** set the login (username + password of at least 10 characters), change the password (username prefilled), or remove it (with a confirmation). The form says that a password change signs out every other device. When `.env` sets the login, the section says so and shows no write controls, so there is no 409 surprise. - **Signed-in devices:** each device with its label, last activity and a "This device" marker; sign out one device, or all other devices (with a confirmation). - **Add a device:** shows an 8-character code (for example `HAEC-J2UZ`), valid once for 5 minutes. A signed-in device that is not the owner's computer also sees this block (the rest of the section stays owner-only). **Server** - `POST /api/access/pairing-codes`: allowed for a signed-in browser session or a privileged caller (the host, or the admin secret); a plain Basic Authorization script gets 403. 409 when no login exists. - Codes use `23456789ABCDEFGHJKMNPQRSTUVWXYZ` (no 0/O/1/I/L). Only an HMAC with a per-process key stays in memory, so a restart ends every code. Each code is bound to the current login, so a password change ends open codes. Codes are compared in constant time and work once. At most 10 open codes. Signing out a device ends the codes it made; "sign out all other devices" ends every open code. - `POST /login` accepts `code` instead of `user`/`password` (case, spaces and the dash do not matter) and starts a normal session. Wrong codes count toward the existing wrong-password lockout, and the lockout is checked before the code. A working code clears this browser's own wrong-guess count, like a working password. - The sign-in page has a second form, "Sign in with a code". - `DELETE /api/access/sessions` now keeps the caller's own session ("sign out all other devices"). From the host, which has no session, it still signs out everyone. - `/api/access/status` adds `loginUser` so the form can keep the username. - **Refused devices:** the IP allowlist (403) and the no-login lockdown record the refused device in a short in-memory list (one entry per device and reason, kept 30 minutes after the last try, at most 20). Allowlist refusals with the same device label share one entry, so new addresses do not bring back a dismissed banner. `GET /api/access/refusals` is loopback-only and returns device label, reason and time, without addresses. Once a login exists, "no login yet" entries are left out. - **CSRF fix for `/login`:** the login page sets `<meta name="referrer" content="same-origin">`, and `/login` also accepts an `Origin` equal to the server's own origin. Cross-site posts are still refused. - Secure cookie only on HTTPS (item 5): checked. `isHttpsRequest` trusts `X-Forwarded-Proto` only from a local proxy, so I left it unchanged. **Banner (host only)** - `useRefusedDeviceBanners` adds one `AppBanner` candidate per refused device to the shared `AppBannerHost`: "A device tried to connect. Marinara turned away Safari on iPhone because remote access has no login yet." with **Open access settings**. It is a dismissable warning, and its id is stable while the same device keeps trying, so a dismissal holds. Other devices get 403 once and stop polling. The banner shows no IP addresses. ## Not in this PR (out of scope) Passkeys, rolling sessions, multi-user accounts, QR-only pairing, env presets, host approval prompts. Docs for the app login, sessions and pairing codes in `docs/REMOTE_ACCESS.md`: these are not in PR 1–3; they should come with PR 4 (with a `[docs-i18n]` follow-up). ## Validation (local) - `remote-login.regression.ts` (extended: sign-out-others, pairing create/redeem/single-use/expiry/lockout/password-change, codes ended by logout and by sign-out-others, a good code clears the wrong-guess count, refused-device list incl. merged allowlist entries, plain-HTTP `/login` origin): pass - Related regressions: access-status (updated for `loginUser`), access-policy, basic-auth-throttle-security, loopback-proxy-auth-security, docker-proxy-auth, docker-gateway-auth-security, android-local-auth, issue-sweep-sep5, encoded-api-path-security, multiplayer-control-security: pass - server `tsc --noEmit`, client `tsc -b`, `pnpm localization:check`, `pnpm check`: pass (one existing lint warning in `HomeProfessorMariChat.tsx`, not touched here) - Real Chromium on a devbox instance: banner, Settings (no login / login / code / devices / `.env` login / signed-in phone) at 390, 768 and 1440 px; `/login` with a code at 390, 768 and 1440 px; code sign-in → 303 + session, `/api/chats` 200 for the paired phone, reused code 401. - Local CodeRabbit: first run 2 findings, both fixed (error text now uses the steady theme accent instead of `--destructive`; new copy shortened to one sentence each). Rerun after the gate-review fixes: 0 findings. ## Manual verification - [ ] Manually verify setting, changing and removing the login in Settings → Advanced → Access on the host. - [ ] Manually verify that an `.env` login shows the read-only note and no write controls. - [ ] Manually verify the signed-in devices list, signing out one device, and signing out all other devices. - [ ] Manually verify "Add a device" on the host and on a signed-in phone, then sign in with the code on a second phone, including an iPhone home-screen app. - [ ] Manually verify that a used or expired code is refused on `/login`. - [ ] Manually verify password and code sign-in on `/login` over plain HTTP on a LAN address and over HTTPS. - [ ] Manually verify the refused-device banner on the host after a refused phone visit, its dismissal, and that it does not come back for the same device right away. - [ ] Manually verify the Settings section and `/login` at 390 px in light mode and in the SillyTavern theme. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:10:13 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8082
No description provided.