-
Notifications
You must be signed in to change notification settings - Fork 451
fix: SecurityPolicy reference grant #5792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: kkk777-7 <[email protected]>
Signed-off-by: kkk777-7 <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5792 +/- ##
==========================================
+ Coverage 65.19% 65.72% +0.52%
==========================================
Files 214 220 +6
Lines 34321 35101 +780
==========================================
+ Hits 22377 23070 +693
- Misses 10591 10611 +20
- Partials 1353 1420 +67 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks!
Signed-off-by: kkk777-7 <[email protected]>
Signed-off-by: kkk777-7 <[email protected]>
@kkk777-7 Sorry for the extra churn, but could we reuse the If yes, it should be renamed back to |
Signed-off-by: kkk777-7 <[email protected]>
@zhaohuabing Would it be better to replace routes.go in this PR? |
Yes, please also use |
Signed-off-by: kkk777-7 <[email protected]>
@zhaohuabing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks!
"name", refGrant.Name) | ||
} | ||
} | ||
if err := r.processBackendRef( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also add a testcase for ExtAuth in TestProcessSecurityPolicyObjectRefs
? TIA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added by the following commit.
b6f83df
resource.KindSecurityPolicy, | ||
policy.Namespace, | ||
policy.Name, | ||
*backendRef); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may panic here if backendRef is a nil pointer, can you also add a testcase to verify this? and should not call processBackendRef
anymore if backendRef is a nil pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for review!
You're right. I have fixed the logic where the variable is defined before calling processBackendRef
.
6bb7c7d
ownerKind string, | ||
ownerNS string, | ||
ownerName string, | ||
backendRef gwapiv1.BackendObjectReference, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would a pointer type be better? in this way, can directly return if backendRef is a nil pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for comment, You're right.
In this case, only the mentioned situation above pass pointer type to function.
In most cases, gwapiv1.BackendObjectReference
type is passed to function.
e.g. routes.go
gateway/internal/provider/kubernetes/routes.go
Lines 237 to 253 in d0fbe14
for _, backendRef := range rule.BackendRefs { | |
if err := validateBackendRef(&backendRef.BackendRef); err != nil { | |
r.log.Error(err, "invalid backendRef") | |
continue | |
} | |
if err := r.processBackendRef( | |
ctx, | |
resourceMap, | |
resourceTree, | |
resource.KindHTTPRoute, | |
httpRoute.Namespace, | |
httpRoute.Name, | |
backendRef.BackendObjectReference); err != nil { | |
r.log.Error(err, | |
"failed to process BackendRef for HTTPRoute", | |
"httpRoute", httpRoute, "backendRef", backendRef.BackendObjectReference) | |
} |
https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1/shared_types.go#L264-L287
so, fixed in the following commit.
6bb7c7d
@@ -450,3 +589,19 @@ func TestProcessEnvoyExtensionPolicyObjectRefs(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func setupFakeReconciler(objs []client.Object) *gatewayAPIReconciler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: about naming here, prefer setupReferenceGrantReconciler
, since it's just for ReferenceGrant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for review, I've renamed setupReferenceGrantReconciler.
Signed-off-by: kkk777-7 <[email protected]>
Signed-off-by: kkk777-7 <[email protected]>
Signed-off-by: kkk777-7 <[email protected]>
@zhaohuabing @shawnh2 |
What this PR does / why we need it:
Fix reference grant from SecurityPolicy to referenced remoteJWKS backend not respected.
Which issue(s) this PR fixes:
Fixes #5743
Release Notes: Yes