feat: add support for reverse proxy header handling - #835
Draft
razvan wants to merge 13 commits into
Draft
Conversation
…le, and error causes Reject CIDR entries with host bits set (e.g. 10.244.0.5/16), which uvicorn silently treats as an opaque literal that matches no peer -- disabling proxy trust entirely without any error. Also reject "*" combined with other entries in the list, since uvicorn only always-trusts when the value is exactly "*". Keep the underlying AddrParseError/ParseIntError as snafu sources, correct the InvalidPrefixLength message for out-of-range values, make proxy_headers_argument take &self instead of hard-coding Webserver, and warn (not error) when trustedProxies is set on an Airflow 2.x cluster where it has no effect.
The Pod-IP jsonpath example previously read as producing a CIDR, but Pod IPs are host addresses, not network addresses -- following it literally could produce a CIDR with host bits set, which is now rejected. Clarify that entries must be network addresses or bare host IPs, state the "* must be the only entry" rule, and note that an envOverrides override for FORWARDED_ALLOW_IPS only takes effect while trustedProxies is non-empty.
Rust's u8::from_str accepts a leading '+' (e.g. "10.0.0.0/+16"), but
Python's ipaddress prefix parser used by uvicorn only accepts ASCII
digits. Such entries used to pass CRD validation but were silently
filed by uvicorn as dead literals matching no peer, disabling proxy
trust with no error anywhere -- exactly the failure class this type
exists to prevent.
Require the prefix-length substring to be a non-empty run of ASCII
digits before parsing, routed through the existing
InvalidPrefixLength error. As a side effect, "10.0.0.0/+0" now
reports an invalid prefix length instead of the misleading "did you
mean 0.0.0.0/0" host-bits suggestion. Leading zeros ("10.0.0.0/016")
remain accepted, matching Python's parser.
Also simplify masked_network to return IpAddr directly (the None
case was unreachable) and correct a comment that mischaracterized a
full-width shift guard as preventing undefined behaviour -- it's an
overflow panic in debug and a masked shift in release, not UB.
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.
Description
Fixes #816
Depends on the decision https://github.com/stackabletech/decisions/issues/93
Definition of Done Checklist
Author
Reviewer
Acceptance
type/deprecationlabel & add to the deprecation scheduletype/experimentallabel & add to the experimental features tracker