Commit Graph

3 Commits

Author SHA1 Message Date
Bolke de Bruin
ddc037ea41 Require trusted-proxy CIDR allow-list for header authentication
Header auth previously trusted any request that carried the configured
user header, with no check that the request came from a known upstream
proxy. Anyone reaching rdpgw directly could mint an authenticated
session as any user by setting the header.

Add `Header.TrustedProxies` (CIDR list) checked against `RemoteAddr`
before reading the user header. Refuse the request with 401 when the
remote is outside the allow-list. Refuse to start when header
authentication is enabled but `Header.TrustedProxies` is empty.

The CIDR allow-list gates the immediate upstream only; operators must
still configure their proxy to strip duplicate inbound copies of the
user header so a client cannot smuggle one through the trusted hop.
Documented in docs/header-authentication.md.

TestHeaderAuthRequiresTrustedProxy is a 3-case table covering: no
allow-list (refused), outside allow-list (refused), inside allow-list
(allowed). Existing TestHeaderAuthenticated cases updated to declare
trust for httptest.NewRequest's default RemoteAddr (192.0.2.1).
2026-04-30 13:42:36 +02:00
Bolke de Bruin
46d12c52be Add extra info on app gateway 2025-09-18 23:03:46 +02:00
Bolke de Bruin
75a7ca62a9 Add header authentication 2025-09-18 22:36:04 +02:00