Skip to content

Commit 24e4f43

Browse files
committed
add RBACObject acl attributes
1 parent 409e6ad commit 24e4f43

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

coderd/database/modelmethods.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ func (w WorkspaceTable) RBACObject() rbac.Object {
276276

277277
return rbac.ResourceWorkspace.WithID(w.ID).
278278
InOrg(w.OrganizationID).
279-
WithOwner(w.OwnerID.String())
279+
WithOwner(w.OwnerID.String()).
280+
WithGroupACL(w.GroupACL.RBACACL()).
281+
WithACLUserList(w.UserACL.RBACACL())
280282
}
281283

282284
func (w WorkspaceTable) DormantRBAC() rbac.Object {

coderd/database/types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ func (t *WorkspaceACL) Scan(src interface{}) error {
9191
return xerrors.Errorf("unexpected type %T", src)
9292
}
9393

94+
func (w WorkspaceACL) RBACACL() map[string][]policy.Action {
95+
// Convert WorkspaceACL to a map of string to []policy.Action.
96+
// This is used for RBAC checks.
97+
rbacACL := make(map[string][]policy.Action, len(w))
98+
for id, entry := range w {
99+
rbacACL[id] = entry.Permissions
100+
}
101+
return rbacACL
102+
}
103+
94104
func (t WorkspaceACL) Value() (driver.Value, error) {
95105
return json.Marshal(t)
96106
}

0 commit comments

Comments
 (0)