Repository navigation
feat(server)!: sign in through a trusted reverse proxy - #1574
Merged
Merged
Conversation
[trusted_proxy] gains username_header (default X-SQB-User), optional display_name_header and email_header, unknown_users (provision_viewer, the default, or reject) and proxy_logout_url; identities become optional pre-bindings. The origin may be plain HTTP, with a start-up warning. A newcomer gets a principal named by the canonical username, with an id derived from it, and the installation-wide viewer role; a username that already names another principal is refused rather than taken over. Requests from trusted peers may report the browser host in X-Forwarded-Host, as Apache's mod_proxy does without ProxyPreserveHost. Each untrusted peer that sends the username header is logged once, without header values. Change feeds send Cache-Control: no-cache, no-transform and X-Accel-Buffering: no.
… by default, case-insensitive name check - A request from a trusted peer may use any host name the proxy serves; a write needs the X-SQB-CSRF header, which the UI now always sends, or the configured Origin. The server still allows no cross-origin requests, so a cross-site page cannot send the header. Password, OIDC and untrusted-peer requests keep the exact Host and Origin checks. - trusted_peers defaults to 127.0.0.1 and ::1 when unset. - A newcomer whose username matches another principal's name in any case is refused rather than provisioned, without a schema change. - Proxy-Authorization, Via, X-Forwarded-Proto, X-Real-IP and any Sec- header are reserved identity-header names.
…ding and access removal
… by default Drive the sign-in routes in process with a chosen socket peer, so the default `trusted_peers` is checked against real non-loopback IPv4, IPv6 and IPv4-mapped peers, against forwarding headers that claim loopback, and against a server without `[trusted_proxy]`. State in the server docs that the default lets any process on the host assert an identity, and that listing the proxy's own address narrows it.
The trusted-proxy resolver made `authorization/main` hold 21 modules, one over the container limit. Group them one level deep, as `credentials/main` already is: `roles` for role definitions, assignments and administrator grants; `decisions` for per-person, scope and row decisions and the security audit; `people` for the first administrator, proxy usernames and each person's access. Only module paths change.
…nd ignored Start the server on this machine's routed address with the default trusted peers and send the username header to it, with a forwarding header claiming loopback. The server refuses both requests, logs the peer once and never logs the username. Drop history wording from the server page.
A DNS-rebinding page in a browser on a trusted-peer host reaches the server under its own host name, and could then send the username and CSRF headers. Refuse every request from a trusted peer, reads included, unless its real Host is 127.0.0.1, localhost or [::1] with any port, the host of `origin`, or a name in the new `allowed_hosts` list, which only a proxy that keeps the browser's host name needs. X-Forwarded-Host never counts. A refused Host gets 403 and is logged once with the setting that allows it. The CSRF rule and the loopback trusted_peers default are unchanged.
…lowed_hosts A stock proxy on another host forwards with its backend address as Host, which is not a loopback name, so it needs allowed_hosts too. Say so in the docs and in the refused-Host warning.
kvlonge
marked this pull request as ready for review
November 18, 2026 13:23
kvlonge
enabled auto-merge
November 18, 2026 13:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Teams with a stock reverse proxy and its own login in front of internal tools want
sqb serverto trust the username the proxy sends, without setting up OIDC or listing every person in advance.Changes
[trusted_proxy]gainsusername_header(defaultX-SQB-User), optionaldisplay_name_headerandemail_header,unknown_users(provision_viewer, the default, orreject),proxy_logout_urlandallowed_hosts. Identities become optional pre-bindings.trusted_peersdefaults to127.0.0.1and::1. A peer outside it that sends the username header is ignored and logged once, without header values.origin's host or a name inallowed_hosts. This closes DNS rebinding; X-Forwarded-Host never counts. A refused Host gets 403, logged once. A proxy that keeps the browser's host name or reaches the server by another name must list it inallowed_hosts.X-SQB-CSRF(the UI always sends it) or the configured Origin. Password and OIDC checks are unchanged.roles,decisionsandpeople.Verification
allowed_hosts.test_proxy: a non-loopback peer's username header and a refused Host are each logged once.vitest(581) andmake check-cipassed on the final head.