feat: support listener name in SecurityPolicy target#5916
feat: support listener name in SecurityPolicy target#5916arkodg merged 3 commits intoenvoyproxy:mainfrom
Conversation
4bc326b to
08e352f
Compare
|
Test is fixed, |
There was a problem hiding this comment.
- similar to L567, can we add a var for
h.Name[strings.LastIndex(h.Name, "/")+1:] - can you add some tests in
internal/gatewayapi/testdata - the current implementation is incomplete, it only ensures a listener policy targets/applies the config to the right IR, the remaining piece is to skip any top level Gateway policy that is targeting this listener level policy, similar to whats done for Gateway and Route
There was a problem hiding this comment.
Thanks for pointing these issues out! I've addressed all of them in 3f7c7bb6454040b667b4fe4d370500bed1c865e3
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5916 +/- ##
==========================================
+ Coverage 70.64% 70.68% +0.03%
==========================================
Files 220 220
Lines 36868 36937 +69
==========================================
+ Hits 26046 26108 +62
- Misses 9291 9295 +4
- Partials 1531 1534 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @kinolaev Could you clarify in the description how the overriding/merging strategy works between Gateway/Listener/Route? |
|
Sorry for long reply(
A Listener attached security policy applies only to Routes that doesn't have a security policy attached to them directly. Could you please be more specific about where exactly you want me to add this explanation?
It depends on your decision) In the issue I've described two possibilities of mTLS authorization - using ClientTrafficPolicy (during handshake) or using SecurityPolicy (after handshake). ClientTrafficPolicy is a good place to add SAN allowlist into envoy's CertificateValidationContext and we don't need this PR for that. But if you only want to authorize SANs using envoy's RBAC then SecurityPolicy might be a better place and consequently we need this PR as a prerequisite. So, yeah, I made steps in both directions because I didn't want to guess what you would decide) But as you already mentioned, this PR could be useful even without relation to the mTLS authorization issue. |
|
requesting @zirain to review, who implemented something similar for BTP but per route rule |
There was a problem hiding this comment.
Is this wording correct? Do we only need to tell the end users on which routes the current policy takes effect?
cc @arkodg
There was a problem hiding this comment.
this is fine, this is consistent with overrides today
Yeah, this makes sense as we need to apply SAN based authz for the entire listener. |
api/v1alpha1/securitypolicy_types.go
Outdated
There was a problem hiding this comment.
| // +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.kind == 'Gateway' || !has(self.targetRef.sectionName) : true",message="this policy supports the sectionName field only for gateways" | |
| // +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.kind == 'Gateway' || !has(self.targetRef.sectionName) : true",message="this policy supports the sectionName field only for kind Gateway" |
There was a problem hiding this comment.
Updated in f1a1fd5262b6609b7617e39edee602514d3c4595
api/v1alpha1/securitypolicy_types.go
Outdated
There was a problem hiding this comment.
| // +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind == 'Gateway' || !has(ref.sectionName)) : true",message="this policy supports the sectionName field only for gateways" | |
| // +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind == 'Gateway' || !has(ref.sectionName)) : true",message="this policy supports the sectionName field only for kind Gateway" |
There was a problem hiding this comment.
Updated in f1a1fd5262b6609b7617e39edee602514d3c4595
There was a problem hiding this comment.
can we have one with Gateway so we also tst posiitive case
There was a problem hiding this comment.
Added in f1a1fd5262b6609b7617e39edee602514d3c4595
There was a problem hiding this comment.
can you add a comment for this ? can't understand this code
There was a problem hiding this comment.
"A HTTPListener name has the format namespace/gatewayName/listenerName" and "If specified the sectionName must match the listenerName part of the HTTPListener name" added in f1a1fd5262b6609b7617e39edee602514d3c4595
f1a1fd5 to
0f354fe
Compare
|
the test is failing due to a difference in string you should be able to repro this locally using |
0f354fe to
32d0223
Compare
|
Oh, sorry, forgot "for" in "only kind Gateway"( fixed |
Signed-off-by: Sergei Nikolaev <kinolaev@gmail.com>
Signed-off-by: Sergei Nikolaev <kinolaev@gmail.com>
Signed-off-by: Sergei Nikolaev <kinolaev@gmail.com>
32d0223 to
11818cb
Compare
What type of PR is this?
feat: support listener name in SecurityPolicy target
What this PR does / why we need it:
It allows to target only a specific listener in a Security Policy. One usage example is attaching mtls authorization as described in #5909
Release Notes: No