pkg/admission: block WS creation if user cannot bind to default exports - #4311
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
hmm, unclear why the |
There was a problem hiding this comment.
Pull request overview
This PR adds an admission-time permission gate to prevent creating a Workspace from a WorkspaceType when the requesting user cannot bind to the APIExports referenced by the type’s spec.defaultAPIBindings, and factors the shared authorization logic into a reusable helper in pkg/admission/apibinding.
Changes:
- Add a default-APIBindings access check to the
WorkspaceTypeExistsadmission plugin to block workspace creation early whenbindis not permitted. - Extract common “default APIBindings bind permission” logic into
apibindingadmission.CheckDefaultAPIBindingsAccess()and reuse it from the WorkspaceType admission path. - Add unit tests covering allow/deny scenarios, including inherited bindings through extended types.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/admission/workspacetypeexists/admission.go | Adds defaultAPIBindings access enforcement during workspace create; wires LogicalCluster lookup helpers/indexers. |
| pkg/admission/workspacetypeexists/admission_test.go | Adds tests to ensure workspace creation is rejected when bind on default APIExports is missing. |
| pkg/admission/workspacetype/admission.go | Refactors existing WorkspaceType defaultAPIBindings permission logic to use the shared helper. |
| pkg/admission/apibinding/binding_permissions.go | Introduces CheckDefaultAPIBindingsAccess helper for centralized default binding authorization checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Block the creation of Workspace based on a custom WorkspaceType, if the user cannot bind to the APIExports requested on the WorkspaceType's defaultAPIBindings. Extract some common logic from pkg/admission/workspacetype/admission.go in a function apibindingadmission.CheckDefaultAPIBindingsAccess(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
6594ca5 to
6d38bea
Compare
/retest |
/retest |
|
/retest |
|
CI errors seem related EDIT: NVM, it passed. |
|
/test pull-kcp-test-e2e-multiple-runs |
Summary
Block the creation of Workspace based on a custom WorkspaceType, if the user cannot bind to the APIExports requested on the WorkspaceType's defaultAPIBindings.
Extract some common logic from pkg/admission/workspacetype/admission.go in a function apibindingadmission.CheckDefaultAPIBindingsAccess().
i have tested the creation block with a script locally and it works.
What Type of PR Is This?
/kind bug
Related Issue(s)
Fixes #4299
(second attempt)
Release Notes