mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #446] [MERGED] feat(security): friendly HTML page when remote browsers hit the auth lockdown #4621
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#4621
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/446
Author: @LukaTheHero
Created: 5/5/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @LukaTheHero
Base:
main← Head:feat/lockdown-friendly-page📝 Commits (2)
73272adfeat(security): serve a friendly HTML page when the lockdown blocks a browser26c8083docs(remote-access): bundle chai's Remote Access guide and deep-link from the lockdown page📊 Changes
5 files changed (+415 additions, -11 deletions)
View changed files
📝
docs/CONFIGURATION.md(+2 -0)📝
docs/FAQ.md(+1 -1)➕
docs/REMOTE_ACCESS.md(+156 -0)📝
packages/server/src/middleware/basic-auth.ts(+198 -10)📝
packages/server/test/security-middleware.test.ts(+58 -0)📄 Description
Why
A lot of Docker / Tailscale / phone-on-LAN users are getting confused by the no-auth lockdown that ships with the safe-by-default Basic Auth behavior. When they open the server in a browser without setting
BASIC_AUTH_USER/BASIC_AUTH_PASS/IP_ALLOWLIST, they get a raw JSON 403 that just says "Forbidden" — no instructions, no link, no obvious next step. Discord has been seeing this report repeatedly.This PR keeps the security posture identical (still 403, still fails closed) but replaces the JSON body with a styled, self-contained HTML page only when the request looks like a browser navigation (Accept: text/html, non-/api/ path). Programmatic clients (curl, fetch, /api/*) still get the original JSON, so nothing scripted breaks.
What the page shows
.envlines to addIP_ALLOWLIST=<their-ip>pre-filledALLOW_UNAUTHENTICATED_PRIVATE_NETWORK=truedocs/REMOTE_ACCESS.md, plus link cards at the bottom for the full walkthrough, FAQ, and TroubleshootingBundled with chai's docs PR (#447)
To avoid the day-one broken-link risk chai called out in #447, this PR also picks up chai's
docs/REMOTE_ACCESS.mdwalkthrough plus theCONFIGURATION.md/FAQ.mdcross-reference lines. Either #446 or #447 can land first; the other becomes a no-op merge. Once both have landed, #447 can be closed without merging since its content is included here.Implementation notes
sendLockdown(request, reply)now branches onwantsHtml(request).wantsHtmlreturns false for/api/*and only true ifAcceptincludestext/html.escapeHtml()helper so we can't be tricked into XSS via a header-spoofed remote address.<style>) so it works without any client build artifacts and won't 404 on a misconfigured static server.LOCKDOWN_JSON_MESSAGE.Tests
Added two unit tests in
packages/server/test/security-middleware.test.ts:Content-Type: text/html, the doctype, theBASIC_AUTH_USERtoken, andIP_ALLOWLIST=<their-ip>./api/headersstill gets the original JSON 403.The pre-existing "non-loopback fails closed" test still passes unchanged. All 18 security-middleware tests pass.
Manual verification (not yet done — please confirm before merging)
BASIC_AUTH_USER/BASIC_AUTH_PASS/IP_ALLOWLISThttp://<server-ip>:7860/in a browser<pre>blocks scroll horizontally instead of overflowingcurl -i http://<server-ip>:7860/api/headersand confirm the JSON 403 still comes back withContent-Type: application/jsonBASIC_AUTH_USER/BASIC_AUTH_PASS, restart, and confirm the lockdown page is gone (browser gets the normal 401 challenge instead)ALLOW_UNAUTHENTICATED_PRIVATE_NETWORK=true, restart, and confirm the LAN browser loads the app normallySummary by CodeRabbit
New Features
Tests
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.