mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8058
Loading…
Add table
Add a link
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8016
Author: @Gunterlie
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @Gunterlie
Base:
feat/7912-remote-login← Head:feat/remote-login-7912📝 Commits (8)
15c1128feat(server): stored login, setup code and /login page (#7912)366be8astyle: format remote login changes3196b94feat(server): server-side remote login sessions and review fixes (#7912)201f0b0fix(server): show an error when /login cannot start a sessione06c415fix(server): count wrong passwords per browser behind a local proxy6d12c1ftest(server): wrong passwords on health checks count toward the lockout4901db8fix(server): remote login gate-review fixes (#7912)e3d4d0dfix(server): retry an unreadable login file at the normal interval📊 Changes
15 files changed (+1434 additions, -199 deletions)
View changed files
📝
.env.example(+4 -1)📝
package.json(+1 -0)📝
packages/client/src/components/diagnostics/use-access-warning-banner.tsx(+2 -0)➕
packages/server/src/config/login-credential.ts(+341 -0)📝
packages/server/src/index.ts(+5 -2)📝
packages/server/src/middleware/basic-auth.ts(+446 -153)📝
packages/server/src/middleware/csrf-protection.ts(+6 -0)📝
packages/server/src/middleware/ip-allowlist.ts(+2 -3)📝
packages/server/src/middleware/rate-limit.ts(+10 -0)📝
packages/server/src/routes/access-status.routes.ts(+80 -1)📝
packages/server/src/routes/index.ts(+2 -0)📝
scripts/regressions/access-status.regression.ts(+1 -0)📝
scripts/regressions/basic-auth-throttle-security.regression.ts(+72 -39)➕
scripts/regressions/remote-login.regression.ts(+433 -0)➕
scripts/reset-login.mjs(+29 -0)📄 Description
Part of #7912 (parent #7909); PR 1 of 4 into the #7912 integration branch
feat/7912-remote-login. All four PRs merge there; one PR takes the result tostagingat the end.Why
Owners must be able to protect remote access without editing
.env. Also, the browser's Basic Auth dialog does not work in iPhone apps pinned to the home screen. Setting a login must be the easy path. Local use on this computer (loopback) stays passwordless.What changed (server only)
config/login-credential.tshasgetLoginConfig(). The Basic Auth gate, the access policy and/api/access/statusall use it, so they always agree. When bothBASIC_AUTH_USERandBASIC_AUTH_PASSare set, they win. Otherwise the login saved in the app applies:DATA_DIR/.remote-login.json, mode0600, written atomically. It holds the username and a scrypt hash (node:crypto, no new dependency). The server checks the file at most every 2 s, so deleting it removes the login at once.PUT /api/access/loginandDELETE /api/access/loginuse the same privileged gate as/api/access/status. CSRF protection and a route rate limit apply. Minimum password length is 10. While.envsets the login, writes return409.docker logs) shows a one-time setup code. This code replacesADMIN_SECRETonly to set the first login. It works once and is cleared when any login exists. When the login is removed later (in the app, withpnpm reset-loginor by deleting the file), the server logs a new code within a few seconds, without a restart. Older codes stop working.GET /loginserves a small self-contained form (lockdown page style, no external assets).POST /loginchecks the login and counts wrong passwords toward the existing lockout. A browser page load without a session redirects to/login?next=…; only same-origin paths are accepted fornext. API calls and scripts still get the401Basic challenge, and Basic Authorization still works. The form post is accepted only when the browser marks it as same-origin; other posts get the usual Origin/Referer check.marinara_sessioncookie (HttpOnly, SameSite=Lax, 365 days, Secure on HTTPS). The server stores only a hash of the token with an id, created/last-seen times and a short device label from the User-Agent (no IP) inDATA_DIR/.remote-sessions.json(mode0600, atomic). At most 50 sessions are kept; the oldest goes first. A missing or damaged file means no sessions. A valid session is not affected by the lockout from other visitors' wrong passwords. This works the same for.envand app logins.POST /logoutends its own session on the server.GET /api/access/sessionslists sessions (id, label, created, last seen, current).DELETE /api/access/sessions/:idends one andDELETE /api/access/sessionsends all. Same privileged gate and CSRF as the login routes. No token or hash leaves the server.marinara_signed_incookie is no longer accepted. Browsers that used it sign in once more.GET /logingives each browser a random pre-auth cookie, and wrong passwords count per browser. Visitors without that cookie share one count as before. All visitors through the same address also share a larger cap, so new cookies cannot buy unlimited tries. A signed-in browser is still never locked out.429. A password that a client already got wrong is refused at once, without a new slow check. Parallel tries from one client cannot pass the wrong-password limit./api/access/statusgetsloginSource: "env" | "app" | null. The client type gets the field; the Settings UI comes in PR 3.pnpm reset-logindeletes the app login and all sessions. It readsDATA_DIRfrom the same.envas the server (MARINARA_ENV_FILEfirst). With Docker, usedocker exec <container> rm -f /app/data/.remote-login.json /app/data/.remote-sessions.json..env.examplehas a short note.Docs for the app login, /login, setup code and reset-login follow in PR 4 of #7912.
Tests
scripts/regressions/remote-login.regression.ts: session create/validate/expire/cap, file modes, logout and login changes end sessions on the server, the sessions API (no secrets in the JSON),nexthandling, the same-origin check for the form, a new setup code after a reset, andreset-loginwithMARINARA_ENV_FILE.basic-auth-throttle-securitynow signs in through/loginand checks that an old-format cookie is rejected. This follows the maintainer decision on #7912 (server-side sessions replace the old cookie).basic-auth-throttle-securityalso checks that behind a proxy, one browser's wrong passwords lock only that browser, another browser can still sign in, and the shared cap holds.remote-loginalso checks that a repeated wrong password does not wait for a slow check, that parallel tries stay within the limit, that a login file which cannot be read for a moment keeps the last login, and that onlyPOST /logoutskips the login.access-statuschecks the new field.Manual verification
docker logs. Set a login from the host browser (PUT /api/access/loginwithsetupCode). Make sure that the same browser stays signed in.docker logsshows a new setup code without a restart./login. Close and open the pinned app again. Make sure that it is still signed in..envlogin: a page load shows/login, not the browser dialog.GET /api/access/sessionslists both with readable labels, and that ending one signs only that device out.POST /logoutand make sure that the old cookie value no longer works.curl -u user:passagainst an API route works with an app login and with an.envlogin.pnpm reset-loginremoves the login and all sessions within a few seconds. Local use still works./loginin one browser until it is refused. Make sure that a second device can still sign in./login. Make sure that the cookie isSecure.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.