mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-02 18:19:07 +01:00
Align Proxy Auth, Reverse Proxy, and Production Security Help (#5313)
Document landed origin validation on proxy-authenticated, Basic, and proxy-attached API-token browser writes, direct loopback trust rules, header-only session CSRF enforcement, atomic login lockout, in-flight request-body authority revalidation, hosted loopback restriction, and Proxmox VE 9+ omission of VM.GuestAgent.FileRead across canonical docs, shipped Help mirrors, and source-bound tests. Contract-Neutral: Documentation and documentation tests only; no runtime behavior, API schema, or subsystem contract changes. --- Fleet candidate `20261127T193213Z-product-intelligence` from the `product-intelligence` lane. Reviewed tip `4c0e22a3fc824eb02b85b00b64f4e1a44ea3525d` on `main`. [How Pulse handles triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
@@ -36,7 +36,12 @@ Generated Proxmox API setup uses a separate `pulse-monitor` account and token
|
||||
with monitoring ACLs. Review the generated script before running it, especially
|
||||
if your organization maintains its own Proxmox roles. Do not reuse an
|
||||
administrator's interactive account or a token that has unrelated write
|
||||
permissions.
|
||||
permissions. On Proxmox VE 9+, Pulse setup intentionally omits
|
||||
`VM.GuestAgent.FileRead` because Proxmox cannot restrict it to `/proc/meminfo`,
|
||||
and granting it on `/` exposes arbitrary guest files to the API token. Prefer
|
||||
QEMU memory ballooning or a guest-local Pulse agent for Linux cache-aware
|
||||
memory, and see [Proxmox Deployment Choices](AGENT_SECURITY.md#proxmox-deployment-choices)
|
||||
to tighten an older `PulseMonitor` role.
|
||||
|
||||
## What trusting a root agent means
|
||||
|
||||
@@ -151,6 +156,18 @@ and management API.
|
||||
- Restrict the Pulse data directory and backups as secrets. They contain
|
||||
encrypted credentials as well as sessions, API-token state, and the key
|
||||
material needed by the installation.
|
||||
- Browser session writes require the `X-CSRF-Token` header (query parameters
|
||||
and form fields are not accepted), and Pulse issues CSRF cookies only for
|
||||
validated live sessions. Proxy-authenticated, Basic-authenticated and
|
||||
proxy-attached API-token browser writes also enforce exact-origin checks (see
|
||||
[Proxy Authentication](PROXY_AUTH.md#-header-trust-boundary)).
|
||||
- Failed-login lockout is enforced atomically across login, Basic
|
||||
authentication, password changes and configuration transfer. Admitted
|
||||
sessions and API tokens are rechecked as request bodies arrive, and
|
||||
quick-setup credential rotation invalidates prior administrator sessions.
|
||||
- SSO provider changes and RBAC administration require full-access instance
|
||||
authority rather than narrowly scoped or tenant-bound tokens. In hosted
|
||||
multi-organization deployments, credential-less loopback trust is disabled.
|
||||
|
||||
The canonical disclosure, reporting process, and hardening checklist are in
|
||||
the [Security Policy](../SECURITY.md). Data and optional telemetry behavior are
|
||||
|
||||
@@ -73,6 +73,14 @@ Pulse trusts these headers completely — they *are* the identity and the privil
|
||||
|
||||
Neither of these can be enforced from inside Pulse: a forged header and a genuine one are indistinguishable once they arrive.
|
||||
|
||||
### Origin checks on proxy-authenticated writes
|
||||
|
||||
A forward-auth proxy attaches identity headers to every browser request that carries its sign-in cookie, so there is no Pulse session cookie to bind a CSRF token to. Pulse therefore checks the browser origin on every `/api/` write (`POST`, `PUT`, `PATCH`, `DELETE`, including `/api/setup-script-url`) and rejects cross-site browser writes with **403 `CSRF origin validation failed`**, recording a `csrf_failure` audit event.
|
||||
|
||||
A `Sec-Fetch-Site: same-site` write (for example from a sibling subdomain or another port on the same host) is admitted only when its `Origin` header, or its `Referer` header when `Origin` is absent, matches Pulse's exact scheme, host and port. An opaque `null` origin is rejected. Safe reads (`GET`, `HEAD`, `OPTIONS`) and non-browser clients sending no browser origin metadata keep their normal admission.
|
||||
|
||||
Behind an HTTPS-terminating proxy, Pulse trusts `X-Forwarded-Proto: https` for this origin comparison only when the immediate peer is listed in `PULSE_TRUSTED_PROXY_CIDRS`. Keep the public `Host` header intact and configure [trusted proxy CIDRs](REVERSE_PROXY.md#before-configuring-the-proxy). These origin checks are in addition to Pulse's session CSRF token check: if a browser also sends a Pulse session cookie, `X-CSRF-Token` is still required.
|
||||
|
||||
## 📦 Examples
|
||||
|
||||
These are integration requirements for an already configured authenticator,
|
||||
@@ -119,6 +127,7 @@ fall back to all-users-admin access.
|
||||
| Issue | Check |
|
||||
| :--- | :--- |
|
||||
| **401 Unauthorized** | Verify `X-Proxy-Secret` matches `PROXY_AUTH_SECRET`. Check if headers are being stripped by intermediate proxies. |
|
||||
| **403 CSRF origin validation failed** | Pulse rejected a browser write whose origin did not match Pulse's scheme, host and port. Check that the proxy preserves the public `Host` header, sends `X-Forwarded-Proto: https` on TLS routes and is listed in `PULSE_TRUSTED_PROXY_CIDRS`. Do not disable authentication or add `ALLOWED_ORIGINS=*` to bypass a header mismatch. |
|
||||
| **Not Admin** | Check the role header actually reaches Pulse and contains the admin role **exactly** — matching is case-sensitive and compares whole roles, so `Admins` and `authentik Admins` do not match the `admin` default. Set `PROXY_AUTH_ADMIN_ROLE` to your IdP's admin group name. Pulse logs a warning at startup when it falls back to the default. |
|
||||
| **Sign out returns to the same user** | Distinguish the [browser redirect, proxy session and IdP session](#sign-out-and-session-boundaries); a configured URL is not proof that access ended. |
|
||||
|
||||
|
||||
@@ -42,11 +42,27 @@ hop, so they share one login lockout and rate limit.
|
||||
`PULSE_TRUSTED_NETWORKS` is not a
|
||||
substitute for proxy trust, and proxy trust is not an authentication bypass.
|
||||
|
||||
Direct loopback trust requires a loopback peer, no reverse-proxy forwarding
|
||||
headers (`X-Forwarded-For`, `Forwarded`, `X-Real-IP`, `X-Forwarded-Host`,
|
||||
`X-Forwarded-Proto`, `Via` and similar headers), a local `Host` (`localhost`,
|
||||
`*.localhost` or a loopback IP) and a same-origin or non-browser request.
|
||||
A proxy on the same host that sends Pulse a `localhost` or loopback `Host`
|
||||
must also send `X-Forwarded-For` (all the configs below do). With no forwarding
|
||||
headers at all, Pulse cannot tell the proxy's requests from a local user's.
|
||||
See [configuration overrides](CONFIGURATION.md#common-overrides-environment-variables).
|
||||
|
||||
If a reverse proxy attaches `Authorization: Basic`, `X-API-Token` or
|
||||
`Authorization: Bearer` headers on forwarded requests, Pulse rejects cross-site
|
||||
browser writes under `/api/` with **403 `CSRF origin validation failed`** unless
|
||||
the browser origin has a matching CORS grant. For Basic credentials, only an
|
||||
exact listed origin in `ALLOWED_ORIGINS` is accepted (`*` does not grant
|
||||
credentialed browser writes). For API tokens, an exact listed origin or `*`
|
||||
admits the write. Never strip `Origin`, `Referer` or `Sec-Fetch-Site` headers in
|
||||
a proxy that injects credentials for all users, because that removes cross-site
|
||||
write protection. Non-browser API clients using Basic authentication do not
|
||||
receive browser session cookies, so script calls do not consume browser session
|
||||
slots.
|
||||
|
||||
## ⚡ Quick Configs
|
||||
|
||||
### Nginx
|
||||
@@ -168,6 +184,7 @@ HTTP/error status, not cookies, proxy secrets or a full network export.
|
||||
|
||||
- **"Connection lost" (Workloads), "Disconnected", "Reconnecting...", "Sync reconnecting", "Backend healthy" or a stuck "Connecting to Pulse" screen:** separate the WebSocket upgrade from state delivery. If an already-observed upgrade failed through this proxy, check its `Upgrade` and `Connection` forwarding. An HTTP 101 or welcome message without subsequent state is a different failure; changing those headers is not an established remedy. Use the [stalled-dashboard guidance](TROUBLESHOOTING.md#health-is-green-but-the-dashboard-is-stalled), even if `/api/health` returns 200. Keep authentication, TLS and origin checks enabled; do not expose the backend to test a bypass.
|
||||
- **502 Bad Gateway**: Check Pulse's actual listener and the proxy's upstream address, port and network reachability; this does not by itself prove Pulse is stopped. Container `localhost` refers to that container, not another service.
|
||||
- **403 CSRF origin validation failed**: Pulse blocked a browser write whose origin did not match its expected scheme, host and port, or arrived cross-site through a proxy attaching proxy-auth, Basic or API-token credentials. Check that the proxy preserves the public `Host` header, sends `X-Forwarded-Proto: https` on TLS routes and is listed in `PULSE_TRUSTED_PROXY_CIDRS`. Do not strip browser origin headers in a credential-injecting proxy.
|
||||
- **CORS Errors**: Do not add CORS headers in the proxy. Pulse handles them. Set **Settings → System → Network → CORS Allowed Origins** (`/settings/system-network`) or use `ALLOWED_ORIGINS` if needed.
|
||||
- **OIDC redirects fail**: [Check the saved callback address](OIDC.md#check-the-callback-address)
|
||||
against the identity provider's registration before changing proxy headers.
|
||||
|
||||
@@ -36,7 +36,12 @@ Generated Proxmox API setup uses a separate `pulse-monitor` account and token
|
||||
with monitoring ACLs. Review the generated script before running it, especially
|
||||
if your organization maintains its own Proxmox roles. Do not reuse an
|
||||
administrator's interactive account or a token that has unrelated write
|
||||
permissions.
|
||||
permissions. On Proxmox VE 9+, Pulse setup intentionally omits
|
||||
`VM.GuestAgent.FileRead` because Proxmox cannot restrict it to `/proc/meminfo`,
|
||||
and granting it on `/` exposes arbitrary guest files to the API token. Prefer
|
||||
QEMU memory ballooning or a guest-local Pulse agent for Linux cache-aware
|
||||
memory, and see [Proxmox Deployment Choices](AGENT_SECURITY.md#proxmox-deployment-choices)
|
||||
to tighten an older `PulseMonitor` role.
|
||||
|
||||
## What trusting a root agent means
|
||||
|
||||
@@ -151,6 +156,18 @@ and management API.
|
||||
- Restrict the Pulse data directory and backups as secrets. They contain
|
||||
encrypted credentials as well as sessions, API-token state, and the key
|
||||
material needed by the installation.
|
||||
- Browser session writes require the `X-CSRF-Token` header (query parameters
|
||||
and form fields are not accepted), and Pulse issues CSRF cookies only for
|
||||
validated live sessions. Proxy-authenticated, Basic-authenticated and
|
||||
proxy-attached API-token browser writes also enforce exact-origin checks (see
|
||||
[Proxy Authentication](PROXY_AUTH.md#-header-trust-boundary)).
|
||||
- Failed-login lockout is enforced atomically across login, Basic
|
||||
authentication, password changes and configuration transfer. Admitted
|
||||
sessions and API tokens are rechecked as request bodies arrive, and
|
||||
quick-setup credential rotation invalidates prior administrator sessions.
|
||||
- SSO provider changes and RBAC administration require full-access instance
|
||||
authority rather than narrowly scoped or tenant-bound tokens. In hosted
|
||||
multi-organization deployments, credential-less loopback trust is disabled.
|
||||
|
||||
The canonical disclosure, reporting process, and hardening checklist are in
|
||||
the [Security Policy](../SECURITY.md). Data and optional telemetry behavior are
|
||||
|
||||
@@ -73,6 +73,14 @@ Pulse trusts these headers completely — they *are* the identity and the privil
|
||||
|
||||
Neither of these can be enforced from inside Pulse: a forged header and a genuine one are indistinguishable once they arrive.
|
||||
|
||||
### Origin checks on proxy-authenticated writes
|
||||
|
||||
A forward-auth proxy attaches identity headers to every browser request that carries its sign-in cookie, so there is no Pulse session cookie to bind a CSRF token to. Pulse therefore checks the browser origin on every `/api/` write (`POST`, `PUT`, `PATCH`, `DELETE`, including `/api/setup-script-url`) and rejects cross-site browser writes with **403 `CSRF origin validation failed`**, recording a `csrf_failure` audit event.
|
||||
|
||||
A `Sec-Fetch-Site: same-site` write (for example from a sibling subdomain or another port on the same host) is admitted only when its `Origin` header, or its `Referer` header when `Origin` is absent, matches Pulse's exact scheme, host and port. An opaque `null` origin is rejected. Safe reads (`GET`, `HEAD`, `OPTIONS`) and non-browser clients sending no browser origin metadata keep their normal admission.
|
||||
|
||||
Behind an HTTPS-terminating proxy, Pulse trusts `X-Forwarded-Proto: https` for this origin comparison only when the immediate peer is listed in `PULSE_TRUSTED_PROXY_CIDRS`. Keep the public `Host` header intact and configure [trusted proxy CIDRs](REVERSE_PROXY.md#before-configuring-the-proxy). These origin checks are in addition to Pulse's session CSRF token check: if a browser also sends a Pulse session cookie, `X-CSRF-Token` is still required.
|
||||
|
||||
## 📦 Examples
|
||||
|
||||
These are integration requirements for an already configured authenticator,
|
||||
@@ -119,6 +127,7 @@ fall back to all-users-admin access.
|
||||
| Issue | Check |
|
||||
| :--- | :--- |
|
||||
| **401 Unauthorized** | Verify `X-Proxy-Secret` matches `PROXY_AUTH_SECRET`. Check if headers are being stripped by intermediate proxies. |
|
||||
| **403 CSRF origin validation failed** | Pulse rejected a browser write whose origin did not match Pulse's scheme, host and port. Check that the proxy preserves the public `Host` header, sends `X-Forwarded-Proto: https` on TLS routes and is listed in `PULSE_TRUSTED_PROXY_CIDRS`. Do not disable authentication or add `ALLOWED_ORIGINS=*` to bypass a header mismatch. |
|
||||
| **Not Admin** | Check the role header actually reaches Pulse and contains the admin role **exactly** — matching is case-sensitive and compares whole roles, so `Admins` and `authentik Admins` do not match the `admin` default. Set `PROXY_AUTH_ADMIN_ROLE` to your IdP's admin group name. Pulse logs a warning at startup when it falls back to the default. |
|
||||
| **Sign out returns to the same user** | Distinguish the [browser redirect, proxy session and IdP session](#sign-out-and-session-boundaries); a configured URL is not proof that access ended. |
|
||||
|
||||
|
||||
@@ -42,11 +42,27 @@ hop, so they share one login lockout and rate limit.
|
||||
`PULSE_TRUSTED_NETWORKS` is not a
|
||||
substitute for proxy trust, and proxy trust is not an authentication bypass.
|
||||
|
||||
Direct loopback trust requires a loopback peer, no reverse-proxy forwarding
|
||||
headers (`X-Forwarded-For`, `Forwarded`, `X-Real-IP`, `X-Forwarded-Host`,
|
||||
`X-Forwarded-Proto`, `Via` and similar headers), a local `Host` (`localhost`,
|
||||
`*.localhost` or a loopback IP) and a same-origin or non-browser request.
|
||||
A proxy on the same host that sends Pulse a `localhost` or loopback `Host`
|
||||
must also send `X-Forwarded-For` (all the configs below do). With no forwarding
|
||||
headers at all, Pulse cannot tell the proxy's requests from a local user's.
|
||||
See [configuration overrides](CONFIGURATION.md#common-overrides-environment-variables).
|
||||
|
||||
If a reverse proxy attaches `Authorization: Basic`, `X-API-Token` or
|
||||
`Authorization: Bearer` headers on forwarded requests, Pulse rejects cross-site
|
||||
browser writes under `/api/` with **403 `CSRF origin validation failed`** unless
|
||||
the browser origin has a matching CORS grant. For Basic credentials, only an
|
||||
exact listed origin in `ALLOWED_ORIGINS` is accepted (`*` does not grant
|
||||
credentialed browser writes). For API tokens, an exact listed origin or `*`
|
||||
admits the write. Never strip `Origin`, `Referer` or `Sec-Fetch-Site` headers in
|
||||
a proxy that injects credentials for all users, because that removes cross-site
|
||||
write protection. Non-browser API clients using Basic authentication do not
|
||||
receive browser session cookies, so script calls do not consume browser session
|
||||
slots.
|
||||
|
||||
## ⚡ Quick Configs
|
||||
|
||||
### Nginx
|
||||
@@ -168,6 +184,7 @@ HTTP/error status, not cookies, proxy secrets or a full network export.
|
||||
|
||||
- **"Connection lost" (Workloads), "Disconnected", "Reconnecting...", "Sync reconnecting", "Backend healthy" or a stuck "Connecting to Pulse" screen:** separate the WebSocket upgrade from state delivery. If an already-observed upgrade failed through this proxy, check its `Upgrade` and `Connection` forwarding. An HTTP 101 or welcome message without subsequent state is a different failure; changing those headers is not an established remedy. Use the [stalled-dashboard guidance](TROUBLESHOOTING.md#health-is-green-but-the-dashboard-is-stalled), even if `/api/health` returns 200. Keep authentication, TLS and origin checks enabled; do not expose the backend to test a bypass.
|
||||
- **502 Bad Gateway**: Check Pulse's actual listener and the proxy's upstream address, port and network reachability; this does not by itself prove Pulse is stopped. Container `localhost` refers to that container, not another service.
|
||||
- **403 CSRF origin validation failed**: Pulse blocked a browser write whose origin did not match its expected scheme, host and port, or arrived cross-site through a proxy attaching proxy-auth, Basic or API-token credentials. Check that the proxy preserves the public `Host` header, sends `X-Forwarded-Proto: https` on TLS routes and is listed in `PULSE_TRUSTED_PROXY_CIDRS`. Do not strip browser origin headers in a credential-injecting proxy.
|
||||
- **CORS Errors**: Do not add CORS headers in the proxy. Pulse handles them. Set **Settings → System → Network → CORS Allowed Origins** (`/settings/system-network`) or use `ALLOWED_ORIGINS` if needed.
|
||||
- **OIDC redirects fail**: [Check the saved callback address](OIDC.md#check-the-callback-address)
|
||||
against the identity provider's registration before changing proxy headers.
|
||||
|
||||
@@ -493,6 +493,40 @@ class AuthenticationDiagnosticDocsTest(unittest.TestCase):
|
||||
self.assertEqual(result.returncode, 73)
|
||||
self.assertEqual(requests, [])
|
||||
|
||||
def test_proxy_origin_checks_and_csrf_boundary_match_runtime(self):
|
||||
source = DOCUMENTS["PROXY_AUTH"].read_text(encoding="utf-8")
|
||||
boundary = markdown_section(source, "⚠ Header Trust Boundary")
|
||||
troubleshooting = markdown_section(source, "🔧 Troubleshooting")
|
||||
for phrase in (
|
||||
"### Origin checks on proxy-authenticated writes",
|
||||
"403 `CSRF origin validation failed`",
|
||||
"csrf_failure",
|
||||
"Sec-Fetch-Site: same-site",
|
||||
"matches Pulse's exact scheme, host and port",
|
||||
"opaque `null` origin is rejected",
|
||||
"PULSE_TRUSTED_PROXY_CIDRS",
|
||||
"REVERSE_PROXY.md#before-configuring-the-proxy",
|
||||
"X-CSRF-Token",
|
||||
):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, boundary)
|
||||
for phrase in (
|
||||
"403 CSRF origin validation failed",
|
||||
"X-Forwarded-Proto: https",
|
||||
"PULSE_TRUSTED_PROXY_CIDRS",
|
||||
"ALLOWED_ORIGINS=*",
|
||||
):
|
||||
with self.subTest(troubleshooting=phrase):
|
||||
self.assertIn(phrase, troubleshooting)
|
||||
|
||||
router = (ROOT / "internal/api/router.go").read_text(encoding="utf-8")
|
||||
self.assertIn("isValidProxyAuthRequest(r.config, req) && isCrossSiteBrowserRequest(req)", router)
|
||||
self.assertIn('http.Error(w, "CSRF origin validation failed", http.StatusForbidden)', router)
|
||||
self.assertIn('"Cross-site browser mutation blocked for proxy auth"', router)
|
||||
origin_test = (ROOT / "internal/api/proxy_csrf_origin_test.go").read_text(encoding="utf-8")
|
||||
self.assertIn("TestProxyAuthOriginComparisonUsesOnlyTrustedForwardedScheme", origin_test)
|
||||
self.assertIn("TestSessionCSRFTokenStillRequiredForSameSiteWrites", origin_test)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -255,6 +255,42 @@ class ProductionRolloutDocsTest(unittest.TestCase):
|
||||
self.assertEqual(TRUST_DOC.read_bytes(),
|
||||
(ROOT / "frontend-modern/public/docs/OPERATIONAL_TRUST.md").read_bytes())
|
||||
|
||||
def test_pve9_fileread_omission_and_auth_hardening_boundaries_match_runtime(self):
|
||||
collection = section("## Choose the least-privileged collection path")
|
||||
for phrase in (
|
||||
"On Proxmox VE 9+, Pulse setup intentionally omits `VM.GuestAgent.FileRead`",
|
||||
"cannot restrict it to `/proc/meminfo`",
|
||||
"exposes arbitrary guest files to the API token",
|
||||
"AGENT_SECURITY.md#proxmox-deployment-choices",
|
||||
):
|
||||
with self.subTest(collection=phrase):
|
||||
self.assertIn(phrase, collection)
|
||||
|
||||
creds = section("## Credentials, authentication, and data")
|
||||
for phrase in (
|
||||
"Browser session writes require the `X-CSRF-Token` header",
|
||||
"query parameters and form fields are not accepted",
|
||||
"issues CSRF cookies only for validated live sessions",
|
||||
"PROXY_AUTH.md#-header-trust-boundary",
|
||||
"Failed-login lockout is enforced atomically across login, Basic authentication, password changes and configuration transfer",
|
||||
"Admitted sessions and API tokens are rechecked as request bodies arrive",
|
||||
"quick-setup credential rotation invalidates prior administrator sessions",
|
||||
"SSO provider changes and RBAC administration require full-access instance authority",
|
||||
"credential-less loopback trust is disabled",
|
||||
):
|
||||
with self.subTest(creds=phrase):
|
||||
self.assertIn(phrase, creds)
|
||||
|
||||
security = (ROOT / "internal/api/security.go").read_text(encoding="utf-8")
|
||||
self.assertIn('csrfToken := r.Header.Get("X-CSRF-Token")', security)
|
||||
self.assertIn("if !ValidateSession(sessionID)", security)
|
||||
body_auth = (ROOT / "internal/api/request_body_authority.go").read_text(encoding="utf-8")
|
||||
self.assertIn("func retainRequestBodyAuthority(cfg *config.Config, r *http.Request)", body_auth)
|
||||
auth_go = (ROOT / "internal/api/auth.go").read_text(encoding="utf-8")
|
||||
self.assertIn("RecordLoginAttempt(", auth_go)
|
||||
router_go = (ROOT / "internal/api/router.go").read_text(encoding="utf-8")
|
||||
self.assertIn("InvalidateUserSessions(r.config.AuthUser)", router_go)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -79,6 +79,37 @@ class ServerHttpsDocsTest(unittest.TestCase):
|
||||
network = (ROOT / "frontend-modern/src/components/Settings/NetworkBoundarySettingsSection.tsx").read_text(encoding="utf-8")
|
||||
self.assertIn("CORS Allowed Origins", network)
|
||||
|
||||
def test_reverse_proxy_help_matches_loopback_and_credential_origin_runtime(self):
|
||||
canonical = ROOT / "docs/REVERSE_PROXY.md"
|
||||
shipped = ROOT / "frontend-modern/public/docs/REVERSE_PROXY.md"
|
||||
self.assertEqual(canonical.read_bytes(), shipped.read_bytes())
|
||||
text = " ".join(canonical.read_text(encoding="utf-8").split())
|
||||
for phrase in (
|
||||
"Direct loopback trust requires a loopback peer",
|
||||
"no reverse-proxy forwarding headers",
|
||||
"`localhost`, `*.localhost` or a loopback IP",
|
||||
"same-origin or non-browser request",
|
||||
"Authorization: Basic",
|
||||
"X-API-Token",
|
||||
"Authorization: Bearer",
|
||||
"403 `CSRF origin validation failed`",
|
||||
"exact listed origin in `ALLOWED_ORIGINS`",
|
||||
"Never strip `Origin`, `Referer` or `Sec-Fetch-Site` headers",
|
||||
"Non-browser API clients using Basic authentication do not receive browser session cookies",
|
||||
"**403 CSRF origin validation failed**:",
|
||||
):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, text)
|
||||
|
||||
loopback = (ROOT / "internal/api/loopback_trust.go").read_text(encoding="utf-8")
|
||||
self.assertIn("func isDirectLoopbackRequest(req *http.Request) bool", loopback)
|
||||
self.assertIn("isLocalRequestHost(req.Host)", loopback)
|
||||
router = (ROOT / "internal/api/router.go").read_text(encoding="utf-8")
|
||||
self.assertIn("!originMayUseCredentials && isCrossSiteBasicAuthWrite(req)", router)
|
||||
self.assertIn("!originHasCORSGrant && isCrossSiteAPITokenWrite(req)", router)
|
||||
basic = (ROOT / "internal/api/basic_auth_session.go").read_text(encoding="utf-8")
|
||||
self.assertIn("func issueBasicBrowserSession(", basic)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user