-
Notifications
You must be signed in to change notification settings - Fork 398
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
Adding CEL Validation for Permission Claim #1529
Adding CEL Validation for Permission Claim #1529
Conversation
4d12f5d
to
1f61d58
Compare
@@ -69,6 +69,12 @@ spec: | |||
required: | |||
- resource | |||
type: object | |||
x-kubernetes-validations: | |||
- message: if claim for core group must only be one of configmaps, |
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.
core group does not really matter here. You can claim Services or Pods. I think the only restriction we can and should have is about the identity.
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.
We don't have all of those types in internal api schemes yet so they would have no effect and we wouldn't be able to serve them.
Are we planning on adding all the internal types?
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.
We may want to update this in the future. But if we are providing things like RBAC, that will not be the core group and will not have an identityHash. I believe that for now let's keep as is (most restrictive) and we can open it up as that path is usually more accessible. Thoughts?
aed23f7
to
f014f44
Compare
@@ -25,14 +25,6 @@ import ( | |||
tenancyv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/tenancy/v1alpha1" | |||
) | |||
|
|||
func TestClusterWorkspaceInitializerLabelPrefix(t *testing.T) { |
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.
@stevekuznetsov Can you please verify that this ok?
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.
ClusterWorkspaceInitializerLabelPrefix is ending a slash. So yes, this test is not valid anymore.
50123c2
to
2d58978
Compare
e78569b
to
d910bf6
Compare
path: /spec/versions/name=v1alpha1/schema/openAPIV3Schema/properties/spec/properties/acceptedPermissionClaims/items/x-kubernetes-validations | ||
value: | ||
- rule: | | ||
(((has(self.group) && self.group == '') || !(has(self.group))) && self.resource in ['configmaps', 'namespaces', 'secrets', 'serviceaccounts']) || ((has(self.group) && self.group != '') && (has(self.identityHash) && self.identityHash != '')) |
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.
I do not have a way to do it because the rules are ANDed together AFAICT
* Validate that empty group means only internal types that are valid * Validate that if a group is set, that an identityHash must also be set.
fbbc381
to
0fcf51f
Compare
['configmaps', 'namespaces', 'secrets', 'serviceaccounts'] | ||
- message: .identityHash must be set if .group is not empty. | ||
rule: '!(has(self.group) && self.group != '''') || (has(self.identityHash) | ||
&& self.identityHash != '''')' |
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.
much better
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.
I honestly have never done logic like this or at least forgot that it was possible. Thanks for teaching!
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 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sttts The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
rule: (has(self.group) && self.group != '') || self.resource in | ||
['configmaps', 'namespaces', 'secrets', 'serviceaccounts'] | ||
- message: .identityHash must be set if .group is not empty. | ||
rule: '!(has(self.group) && self.group != '''') || (has(self.identityHash) |
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.
What's up with the ''''
?
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.
Hm, probably not ideal, but does look like it still passes the identity hash test.
Summary
Adding CEL Validation as an option for the APIServer
For Permission Claims adding validations:
Related issue(s)
Fixes #1331