Repository navigation
api: add tcpAuthorization and udpAuthorization to SecurityPolicy - #10664
zhaohuabing wants to merge 7 commits into
Conversation
✅ Deploy Preview for cerulean-figolla-1f9435 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c73bda7907
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10664 +/- ##
==========================================
+ Coverage 82.85% 82.87% +0.02%
==========================================
Files 278 278
Lines 44695 44695
==========================================
+ Hits 37032 37041 +9
+ Misses 7662 7653 -9
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e2affbcd6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // +kubebuilder:validation:XValidation:rule="!has(self.tcpAuthorization) || ((!has(self.targetRef) || !(self.targetRef.kind in ['HTTPRoute', 'GRPCRoute'])) && (!has(self.targetRefs) || !self.targetRefs.exists(ref, ref.kind in ['HTTPRoute', 'GRPCRoute'])) && (!has(self.targetSelectors) || !self.targetSelectors.exists(sel, sel.kind in ['HTTPRoute', 'GRPCRoute'])))", message="tcpAuthorization cannot be used with HTTPRoute or GRPCRoute targets" | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.udpAuthorization) || ((!has(self.targetRef) || !(self.targetRef.kind in ['HTTPRoute', 'GRPCRoute'])) && (!has(self.targetRefs) || !self.targetRefs.exists(ref, ref.kind in ['HTTPRoute', 'GRPCRoute'])) && (!has(self.targetSelectors) || !self.targetSelectors.exists(sel, sel.kind in ['HTTPRoute', 'GRPCRoute'])))", message="udpAuthorization cannot be used with HTTPRoute or GRPCRoute targets" |
There was a problem hiding this comment.
Reject unsupported route kinds in L4 authorization selectors
When targetSelectors is used, these rules only reject HTTPRoute and GRPCRoute. Unlike targetRef and targetRefs, selectors have no general kind allowlist, and the translator includes TLSRoute in the route candidates resolved by ProcessSecurityPolicies. A TLSRoute selector with either new L4 authorization field therefore passes admission and reaches policy processing even though TLSRoute is not a supported SecurityPolicy target; apply the supported-kind allowlist to selectors too.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Ignored for incompatible routes instead of rejecting them.
We could add warning status in the implementation PR.
0efcab1 to
aae963b
Compare
aae963b to
21034a3
Compare
|
/retest |
9470336 to
d5c472a
Compare
d5c472a to
0aa8e4c
Compare
a482aca to
834d65a
Compare
Adds separate authorization fields for TCP and UDP traffic so each listener type has its own rules instead of sharing the HTTP authorization field. TCP and UDP get their own types because Envoy can match on more for TCP (SNI, client certs, CEL), and the two will diverge. Using authorization for TCP and UDP is now deprecated but keeps working until the new fields are set. The implementation follows in a separate PR. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Spells out in the SecurityPolicy docs that using authorization for TCPRoute and UDPRoute targets is deprecated and will be removed in a future release, and that it keeps applying until the new fields are set. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Marks the new fields as not implemented so they stay out of the API docs until the translator supports them. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
A policy that targets both TCPRoutes and UDPRoutes can now set both fields; each one is ignored for the other route kind, the same way Gateway targets work. Only HTTPRoute and GRPCRoute targets are still rejected. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Drops the target-kind CEL rules so tcpAuthorization and udpAuthorization can sit on any SecurityPolicy target. Each one only applies to its own listeners and routes and is ignored elsewhere, the same way Gateway targets work. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
The l4 name was left over from an earlier design. One file per protocol matches how the rest of the API is laid out and lets the two types grow apart. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
The split into separate files left the UDP types behind in the TCP file, so the package failed to build. Remove the leftover copies. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
834d65a to
338c80b
Compare
Adds
tcpAuthorizationandudpAuthorizationto SecurityPolicy, so TCP and UDP traffic each get their own authorization rules instead of sharing the HTTPauthorizationfield. This is the API only; the implementation follows in a separate PR.Today one
authorizationfield covers HTTP, TCP and UDP. On a Gateway-level policy the same rules land on every listener, so there's no way to give TCP or UDP listeners rules that differ from the HTTP ones, and the field exposes JWT, headers, methods and CEL, none of which mean anything for a TCP connection or a UDP datagram. Splitting it per protocol makes the intent of each policy clear and limits each field to what its protocol can actually match on.TCP and UDP get separate types even though both only take
clientCIDRstoday. Envoy can match a lot more on TCP connections (SNI, client certs, CEL), and keeping the types apart lets TCP grow without those fields leaking into UDP.Using
authorizationfor TCP and UDP is deprecated but keeps working until the matching new field is set. Dropping it right away would quietly remove existing Gateway-level CIDR rules from TCP and UDP listeners on upgrade.This also gives #7825 a place to land later. A Gateway-level
tcpAuthorizationcould apply to HTTP listeners as a connection-level check on the peer IP, for example only accepting connections from Cloudflare's ranges. Route-levelauthorizationwould keep checking the real client IP from XFF or proxy protocol. Keeping that check on Gateway targets avoids the per-route problem that gotsourceCIDRsreverted in #8471.Part of #10359