Andrey Antukh 530574a0c5 ✨ Honor trusted alternate origins for backend links and OIDC
Add PENPOT_TRUSTED_ORIGINS, an optional list of bare scheme://host[:port]
alternate origins. A request whose Origin matches (exact, trimmed and
lowercased) uses that origin as the base for links generated while serving
it: emails, asset URLs, audit and webhook link fields, and redirects.
Unlisted origins, requests without Origin, and background or server-to-server
work keep the canonical public-uri (fail-closed). Malformed entries warn at
startup and never match.

Stamp the trusted origin on the request with a global http middleware that
binds config public-uri for the request extent; expose the chain as
root-middleware so tests assert it runs before auth and errors. Build every
backend link through the canonical cf/get-public-uri.

Carry the origin in the signed OIDC state (auth and organization SSO) so the
callback, a navigation without Origin, re-applies it with with-public-uri for
the token-exchange redirect_uri and every redirect, including logout. Verify
the state token once per callback and reuse the claims; build redirect URIs
with ensure-path-slash plus join and append-query-param for hash routes. A
removed origin does not invalidate states signed before it (up to four hours).

Bring MCP OAuth into scope: wrap its routes, stage the origin in the Redis
request record at authorize time, and re-apply it in decision so issuer,
resource, the approval redirect and the code-exchange iss agree on one base.

Keep the log-capture watch installed while waiting for the async rejection
record in the save tests; a watch removed first lost late records and read
nil. Add a delayed-executor regression test that makes the race deterministic
and document the rule in the backend testing memory.

Closes #11625

AI-assisted-by: deepseek-v4.1-flash
AI-assisted-by: qwen3.7-plus
AI-assisted-by: gpt-5.6-luna
AI-assisted-by: muse-spark-1.3-contributor
2026-11-19 09:40:34 +01:00
..
2026-09-29 09:07:34 +02:00
2026-10-13 14:33:32 +02:00