Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: allow TemplateAdmin to delete prebuilds via auth layer (POC)#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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
ssncferreira wants to merge4 commits intomain
base:main
Choose a base branch
Loading
fromssncferreira/poc-prebuild-rbac-authz

Conversation

ssncferreira
Copy link
Contributor

@ssncferreirassncferreira commentedJun 11, 2025
edited
Loading

POC (Do not Merge)

Support TemplateAdmin to delete prebuild workspaces via the authorization layer

@ssncferreirassncferreira changed the titlefeat: POC for allowing TemplateAdmin to delete prebuild workspaces via auth layerfeat: poc to allow TemplateAdmin to delete prebuilds via auth layerJun 11, 2025
@ssncferreirassncferreiraforce-pushed thessncferreira/poc-prebuild-rbac-authz branch 2 times, most recently frome05480d todb80b4dCompareJune 11, 2025 19:37
@ssncferreirassncferreiraforce-pushed thessncferreira/poc-prebuild-rbac-authz branch fromdb80b4d to2ba15c5CompareJune 11, 2025 19:38
Comment on lines +235 to +247
func (w Workspace) IsPrebuild() bool {
// TODO: avoid import cycle
return w.OwnerID == uuid.MustParse("c42fdf75-3097-471c-8c33-fb52454d81c0")
}

func (w Workspace) PrebuildRBAC() rbac.Object {
if w.IsPrebuild() {
return rbac.ResourcePrebuiltWorkspace.WithID(w.ID).
InOrg(w.OrganizationID).
WithOwner(w.OwnerID.String())
}
return w.RBACObject()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

🤔 what about

func (w Workspace) AsPrebuild (rbac.Object, bool) {}if pb, ok := obj.AsPrebuild(); ok {  ...}

@ssncferreirassncferreira changed the titlefeat: poc to allow TemplateAdmin to delete prebuilds via auth layerfeat: allow TemplateAdmin to delete prebuilds via auth layer in POCJun 12, 2025
@ssncferreirassncferreira changed the titlefeat: allow TemplateAdmin to delete prebuilds via auth layer in POCfeat: allow TemplateAdmin to delete prebuilds via auth layer (POC)Jun 12, 2025
Comment on lines +408 to +416
workspaceObj, ok := object.(database.Workspace)
if ok {
prebuild := workspaceObj.PrebuildRBAC()
// Fallback to normal workspace auth check
if auth := api.Authorize(r, action, prebuild); auth {
return auth
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggestion: use inline conditional assignment e.g.

if workspaceObj, ok := object.(database.Workspace); ok {  // prebuild auth}

ssncferreira reacted with thumbs up emoji
Comment on lines 499 to 507
{
Name: "PrebuiltWorkspace",
Actions: []policy.Action{policy.ActionRead, policy.ActionUpdate, policy.ActionDelete},
Resource: rbac.ResourcePrebuiltWorkspace.WithID(uuid.New()).InOrg(orgID).WithOwner(memberMe.Actor.ID),
AuthorizeMap: map[bool][]hasAuthSubjects{
true: {owner, orgMemberMe, templateAdmin, orgTemplateAdmin},
false: {setOtherOrg, userAdmin, memberMe, orgAdmin, orgUserAdmin, orgAuditor},
},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think this needs to be two separate tests:

  1. owner, templateAdmin, orgTemplateAdmin can delete and update
  2. owner, templateAdmin, orgTemplateAdmin, orgMemberMe can read

ssncferreira reacted with rocket emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ah good point 👍

{
Name: "PrebuiltWorkspace",
Actions: []policy.Action{policy.ActionRead, policy.ActionUpdate, policy.ActionDelete},
Resource: rbac.ResourcePrebuiltWorkspace.WithID(uuid.New()).InOrg(orgID).WithOwner(memberMe.Actor.ID),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I thinkWithOwner(memberMe) is what's tripping you up here. It should be owned by the prebuilds user instead, right?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@johnstcnjohnstcnjohnstcn left review comments

At least 1 approving review is required to merge this pull request.

Assignees

@ssncferreirassncferreira

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ssncferreira@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp