[PR #8056] [MERGED] feat(server): skip the Marinara login behind a trusted forward-auth proxy (#7912) #8080

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/8056
Author: @Gunterlie
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @Gunterlie

Base: feat/7912-remote-login ← Head: feat/trusted-auth-proxy-7912


📝 Commits (5)

  • ed9d67c feat(server): trust a forward-auth proxy by socket address (#7912)
  • 55d755a docs: explain login proxies (TRUSTED_AUTH_PROXY) for remote access (#7912)
  • d885dd3 chore(server): update the proxy lockout note for TRUSTED_AUTH_PROXY (#7912)
  • 28b1248 fix(server): tighten TRUSTED_AUTH_PROXY ranges and Docker gateway guidance (#7912)
  • 8edce21 fix(server): list a TRUSTED_AUTH_PROXY range in the owner's passwordless summary (#7912)

📊 Changes

13 files changed (+237 additions, -33 deletions)

View changed files

📝 .env.example (+4 -0)
📝 docs/CONFIGURATION.md (+1 -0)
📝 docs/REMOTE_ACCESS.md (+51 -0)
📝 packages/client/src/components/diagnostics/use-access-warning-banner.tsx (+2 -0)
📝 packages/client/src/components/panels/settings/AccessStatusSettings.tsx (+1 -0)
📝 packages/client/src/localization/locales/en.json (+2 -1)
📝 packages/server/src/config/runtime-config.ts (+5 -0)
📝 packages/server/src/middleware/access-policy.ts (+33 -24)
📝 packages/server/src/middleware/basic-auth.ts (+3 -2)
📝 packages/server/src/middleware/ip-allowlist.ts (+74 -4)
📝 packages/server/src/routes/access-status.routes.ts (+8 -1)
📝 scripts/regressions/access-policy.regression.ts (+39 -0)
📝 scripts/regressions/access-status.regression.ts (+14 -1)

📄 Description

Part of #7912. PR 2 of 4 into the #7912 integration branch feat/7912-remote-login. All four PRs merge there; one PR takes the result to staging. Assigned to @SpicyMarinara.

Why

Many owners already run a forward-auth proxy on their home network (tinyauth, Authelia, Authentik, oauth2-proxy). That proxy asks every visitor to log in. Today Marinara then asks for a second login. With this PR the owner can name the proxy, and visitors who come through it log in only once.

What changed

  • New setting TRUSTED_AUTH_PROXY (comma-separated IPs/CIDRs). A request whose socket peer address matches skips the Marinara login. Forwarding headers never decide the match. Unset means no change in behaviour.
  • Safe parsing. Invalid entries are ignored with a warning. A range must stay inside private address space (RFC 1918, CGNAT, ULA, link-local, loopback); other ranges, such as 0.0.0.0/0, ::/0, ::ffff:0:0/96 or a public IPv6 /32, are refused with an error. A public proxy is listed by its single address. Every range logs a warning, because every device in it skips the login. Accepted entries are logged once as an [auth-bypass] warning.
  • Docker gateway warning. In Docker, an entry that matches the Docker gateway logs a warning: Docker Desktop and OrbStack show LAN clients of a published port at that address too. It warns and does not refuse, because a proxy on the Docker host with the port published on 127.0.0.1 legitimately arrives from the gateway, and the server cannot see how the port is published. The docs tell owners to publish 127.0.0.1:7860:7860 in that case.
  • Policy order (access-policy.ts). A trusted auth proxy is an explicit operator choice like BYPASS_AUTH_TAILSCALE / BYPASS_AUTH_DOCKER, so its requests also pass IP_ALLOWLIST: the proxy decides who gets in. They never count as local, so loopback-only and admin-secret rules for privileged APIs do not change. New reason trusted-auth-proxy.
  • Automatic Docker trust stands down while TRUSTED_AUTH_PROXY is set, the same as when a login or an allowlist is set. Without this, other peers on the Docker network could skip the proxy.
  • Host validation and CSRF do not change. The proxy's public name still goes in TRUSTED_HOSTS and CSRF_TRUSTED_ORIGINS.
  • Owner access status (#7911). /api/access/status returns trustedAuthProxy. Settings → Advanced → Access shows a "Trusted login proxy" row (English key added; other locales fall back). The "open without a password" list shows proxy when 127.0.0.1 is a trusted proxy, and privateNetwork when an entry is a range. The English fix hint for proxy names both settings.
  • Wrong-password count. Not changed. Requests from a trusted proxy skip the login, so no login attempts arrive from it to count. The PR 1 ponytail: note now says this.
  • Docs. New "Login proxies (forward auth)" section in docs/REMOTE_ACCESS.md with Caddy examples for tinyauth, Authelia and Authentik (Authentik in a route block so its outpost path does not loop), and warnings that the proxy must protect every path and that Marinara must not be reachable around it. A same-host proxy must dial 127.0.0.1:7860, not localhost, because ::1 does not match a 127.0.0.1 entry (docs instead of extra matching code). The tinyauth endpoint /api/auth/caddy was checked against tinyauth source (internal/controller/proxy_controller.go, route /auth/:proxy, caddy case). The Authelia and Authentik values follow their Caddy guides; check them against the current docs. New row in docs/CONFIGURATION.md. .env.example has only a pointer to the guide.

Tests

  • scripts/regressions/access-policy.regression.ts: a proxy peer skips the login and the allowlist but is not local; an IPv4-mapped peer (::ffff:192.168.1.5) matches; a forwarded header that names the proxy is not trusted; 0.0.0.0/0, ::/0, ::ffff:0:0/96, a public IPv6 /32, a public IPv4 /24 and invalid entries open nothing; a single public address is allowed; a same-computer proxy (127.0.0.1) is trusted but not local; a configured proxy withholds automatic Docker trust.
  • scripts/regressions/access-status.regression.ts: the owner status reports trustedAuthProxy; a same-host trusted proxy is listed as proxy; a proxy range is listed as privateNetwork; a single proxy address opens no network.

Manual verification

  • Put Marinara behind Caddy + tinyauth (or Authelia/Authentik) on another LAN host, set TRUSTED_AUTH_PROXY to that host's address, and make sure that a browser that passed the proxy login opens Marinara without a second login.
  • From a different LAN device, connect to Marinara directly and make sure that it still gets the Marinara login or lockdown page.
  • Set TRUSTED_AUTH_PROXY=0.0.0.0/0 and make sure that the server log shows the refusal and that remote devices still need the login.
  • Open Settings → Advanced → Access as the owner and make sure that "Trusted login proxy" shows "Set".

Follow-ups

  • The docs/ change needs a docs-i18n update when the integration branch goes to staging (together with the PR 4 docs).

🔄 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/8056 **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/trusted-auth-proxy-7912` --- ### 📝 Commits (5) - [`ed9d67c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ed9d67ce5c3a228be5f681764cb087bd7c0a17b6) feat(server): trust a forward-auth proxy by socket address (#7912) - [`55d755a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/55d755a6b652e98ce7a92eef3b7150203cd4c8cf) docs: explain login proxies (TRUSTED_AUTH_PROXY) for remote access (#7912) - [`d885dd3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d885dd302542e6fdff589c9762086833bfd24211) chore(server): update the proxy lockout note for TRUSTED_AUTH_PROXY (#7912) - [`28b1248`](https://github.com/Pasta-Devs/Marinara-Engine/commit/28b1248b68e2690e2a0755d5a717a94ca3946a0f) fix(server): tighten TRUSTED_AUTH_PROXY ranges and Docker gateway guidance (#7912) - [`8edce21`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8edce21287b9e86d853a7800938a889cda24b843) fix(server): list a TRUSTED_AUTH_PROXY range in the owner's passwordless summary (#7912) ### 📊 Changes **13 files changed** (+237 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+4 -0) 📝 `docs/CONFIGURATION.md` (+1 -0) 📝 `docs/REMOTE_ACCESS.md` (+51 -0) 📝 `packages/client/src/components/diagnostics/use-access-warning-banner.tsx` (+2 -0) 📝 `packages/client/src/components/panels/settings/AccessStatusSettings.tsx` (+1 -0) 📝 `packages/client/src/localization/locales/en.json` (+2 -1) 📝 `packages/server/src/config/runtime-config.ts` (+5 -0) 📝 `packages/server/src/middleware/access-policy.ts` (+33 -24) 📝 `packages/server/src/middleware/basic-auth.ts` (+3 -2) 📝 `packages/server/src/middleware/ip-allowlist.ts` (+74 -4) 📝 `packages/server/src/routes/access-status.routes.ts` (+8 -1) 📝 `scripts/regressions/access-policy.regression.ts` (+39 -0) 📝 `scripts/regressions/access-status.regression.ts` (+14 -1) </details> ### 📄 Description Part of #7912. PR 2 of 4 into the #7912 integration branch `feat/7912-remote-login`. All four PRs merge there; one PR takes the result to `staging`. Assigned to @SpicyMarinara. ## Why Many owners already run a forward-auth proxy on their home network (tinyauth, Authelia, Authentik, oauth2-proxy). That proxy asks every visitor to log in. Today Marinara then asks for a second login. With this PR the owner can name the proxy, and visitors who come through it log in only once. ## What changed - **New setting `TRUSTED_AUTH_PROXY`** (comma-separated IPs/CIDRs). A request whose socket peer address matches skips the Marinara login. Forwarding headers never decide the match. Unset means no change in behaviour. - **Safe parsing.** Invalid entries are ignored with a warning. A range must stay inside private address space (RFC 1918, CGNAT, ULA, link-local, loopback); other ranges, such as `0.0.0.0/0`, `::/0`, `::ffff:0:0/96` or a public IPv6 `/32`, are refused with an error. A public proxy is listed by its single address. Every range logs a warning, because every device in it skips the login. Accepted entries are logged once as an `[auth-bypass]` warning. - **Docker gateway warning.** In Docker, an entry that matches the Docker gateway logs a warning: Docker Desktop and OrbStack show LAN clients of a published port at that address too. It warns and does not refuse, because a proxy on the Docker host with the port published on `127.0.0.1` legitimately arrives from the gateway, and the server cannot see how the port is published. The docs tell owners to publish `127.0.0.1:7860:7860` in that case. - **Policy order** (`access-policy.ts`). A trusted auth proxy is an explicit operator choice like `BYPASS_AUTH_TAILSCALE` / `BYPASS_AUTH_DOCKER`, so its requests also pass `IP_ALLOWLIST`: the proxy decides who gets in. They never count as local, so loopback-only and admin-secret rules for privileged APIs do not change. New reason `trusted-auth-proxy`. - **Automatic Docker trust stands down** while `TRUSTED_AUTH_PROXY` is set, the same as when a login or an allowlist is set. Without this, other peers on the Docker network could skip the proxy. - **Host validation and CSRF do not change.** The proxy's public name still goes in `TRUSTED_HOSTS` and `CSRF_TRUSTED_ORIGINS`. - **Owner access status** (#7911). `/api/access/status` returns `trustedAuthProxy`. Settings → Advanced → Access shows a "Trusted login proxy" row (English key added; other locales fall back). The "open without a password" list shows `proxy` when `127.0.0.1` is a trusted proxy, and `privateNetwork` when an entry is a range. The English fix hint for `proxy` names both settings. - **Wrong-password count.** Not changed. Requests from a trusted proxy skip the login, so no login attempts arrive from it to count. The PR 1 `ponytail:` note now says this. - **Docs.** New "Login proxies (forward auth)" section in `docs/REMOTE_ACCESS.md` with Caddy examples for tinyauth, Authelia and Authentik (Authentik in a `route` block so its outpost path does not loop), and warnings that the proxy must protect every path and that Marinara must not be reachable around it. A same-host proxy must dial `127.0.0.1:7860`, not `localhost`, because `::1` does not match a `127.0.0.1` entry (docs instead of extra matching code). The tinyauth endpoint `/api/auth/caddy` was checked against tinyauth source (`internal/controller/proxy_controller.go`, route `/auth/:proxy`, `caddy` case). The Authelia and Authentik values follow their Caddy guides; check them against the current docs. New row in `docs/CONFIGURATION.md`. `.env.example` has only a pointer to the guide. ## Tests - `scripts/regressions/access-policy.regression.ts`: a proxy peer skips the login and the allowlist but is not local; an IPv4-mapped peer (`::ffff:192.168.1.5`) matches; a forwarded header that names the proxy is not trusted; `0.0.0.0/0`, `::/0`, `::ffff:0:0/96`, a public IPv6 `/32`, a public IPv4 `/24` and invalid entries open nothing; a single public address is allowed; a same-computer proxy (`127.0.0.1`) is trusted but not local; a configured proxy withholds automatic Docker trust. - `scripts/regressions/access-status.regression.ts`: the owner status reports `trustedAuthProxy`; a same-host trusted proxy is listed as `proxy`; a proxy range is listed as `privateNetwork`; a single proxy address opens no network. ## Manual verification - [ ] Put Marinara behind Caddy + tinyauth (or Authelia/Authentik) on another LAN host, set `TRUSTED_AUTH_PROXY` to that host's address, and make sure that a browser that passed the proxy login opens Marinara without a second login. - [ ] From a different LAN device, connect to Marinara directly and make sure that it still gets the Marinara login or lockdown page. - [ ] Set `TRUSTED_AUTH_PROXY=0.0.0.0/0` and make sure that the server log shows the refusal and that remote devices still need the login. - [ ] Open Settings → Advanced → Access as the owner and make sure that "Trusted login proxy" shows "Set". ## Follow-ups - The `docs/` change needs a `docs-i18n` update when the integration branch goes to `staging` (together with the PR 4 docs). --- <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#8080
No description provided.