Skip to content
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

Use request.userInfo.groups to validate the organization label #14

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions component/namespace-policies.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,14 @@ local organizationNamespaces = kyverno.ClusterPolicy('organization-namespaces')
value: '',
},
],
context: [
{
name: 'groups',
apiCall: {
urlPath: '/apis/user.openshift.io/v1/groups',
jmesPath: 'items',
},
},
],
validate: {
message: 'Creating namespace for {{request.object.metadata.labels."appuio.io/organization"}} but {{request.userInfo.username}} is not in organization',
deny: {
conditions: [
{
key: '{{request.userInfo.username}}',
key: '{{request.object.metadata.labels."appuio.io/organization"}}',
operator: 'NotIn',
value: "{{groups[?metadata.name=='{{request.object.metadata.labels.\"appuio.io/organization\"}}'].users[]}}",
value: '{{request.userInfo.groups}}',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,7 @@ spec:
metadata:
labels:
appuio.io/organization: ?*
- context:
- apiCall:
jmesPath: items
urlPath: /apis/user.openshift.io/v1/groups
name: groups
exclude:
- exclude:
clusterRoles:
- cluster-admin
- cluster-image-registry-operator
Expand Down Expand Up @@ -143,9 +138,9 @@ spec:
validate:
deny:
conditions:
- key: '{{request.userInfo.username}}'
- key: '{{request.object.metadata.labels."appuio.io/organization"}}'
operator: NotIn
value: '{{groups[?metadata.name==''{{request.object.metadata.labels."appuio.io/organization"}}''].users[]}}'
value: '{{request.userInfo.groups}}'
message: Creating namespace for {{request.object.metadata.labels."appuio.io/organization"}}
but {{request.userInfo.username}} is not in organization
validationFailureAction: enforce