-
Notifications
You must be signed in to change notification settings - Fork 914
feat: allow TemplateAdmin to delete prebuilds via auth layer #18333
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
Open
ssncferreira
wants to merge
10
commits into
main
Choose a base branch
from
ssncferreira/poc-prebuild-rbac-authz
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+403
−62
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e05480d
to
db80b4d
Compare
db80b4d
to
2ba15c5
Compare
johnstcn
reviewed
Jun 12, 2025
johnstcn
reviewed
Jun 12, 2025
johnstcn
reviewed
Jun 18, 2025
Comment on lines
498
to
502
runningWorkspaces, err := db.GetRunningPrebuiltWorkspaces(ctx) | ||
require.NoError(t, err) | ||
|
||
prebuiltWorkspace, err := db.GetWorkspaceByID(ctx, runningWorkspaces[0].ID) | ||
require.NoError(t, err) |
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.
You should also require there to be at least one running workspace. This may need to be done in a testutil.Eventually(ctx)
to avoid potential flakiness.
…resolve import cycle
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for deleting prebuilt workspaces via the authorization layer. It introduces special-case handling to ensure that
prebuilt_workspace
permissions are evaluated when attempting to delete a prebuilt workspace, falling back to the standardworkspace
resource as needed.Prebuilt workspaces are a subset of workspaces, identified by having
owner_id
set toPREBUILD_SYSTEM_USER
.This means:
prebuilt_workspace.delete
permission is allowed to delete only prebuilt workspaces.workspace.delete
permission can delete both normal and prebuilt workspaces.prebuilt_workspace
resource.To delete a workspace, users must have the following permissions:
workspace.read
: to read the current workspace stateupdate
: to modify workspace metadata and related resources during deletion (e.g., updating thedeleted
field in the database)delete
: to perform the actual deletion of the workspaceChanges
authorizeWorkspace()
helper to handle prebuilt workspace authorization logic.prebuilt_workspace
andworkspace
permissions are checked.SystemUserID
constant from theprebuilds
package to thedatabase
packagePrebuildsSystemUserID
to resolve an import cycle (commit f24e4ab).