mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
feat: implement composite API key scopes for workspaces and templates (#19945)
# Add Composite API Key Scopes This PR adds high-level composite API key scopes to simplify token creation with common permission sets: - `coder:workspaces.create` - Create and update workspaces - `coder:workspaces.operate` - Read and update workspaces - `coder:workspaces.delete` - Read and delete workspaces - `coder:workspaces.access` - Read, SSH, and connect to workspace applications - `coder:templates.build` - Read templates and create/read files - `coder:templates.author` - Full template management with insights - `coder:apikeys.manage_self` - Manage your own API keys These composite scopes are persisted in the database and expanded during authorization, providing a more intuitive way to grant permissions compared to the granular resource:action scopes.
This commit is contained in:
@@ -203,6 +203,13 @@ func (s APIKeyScopes) Expand() (rbac.Scope, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// De-duplicate permissions across Site/Org/User
|
||||
merged.Site = rbac.DeduplicatePermissions(merged.Site)
|
||||
for orgID, perms := range merged.Org {
|
||||
merged.Org[orgID] = rbac.DeduplicatePermissions(perms)
|
||||
}
|
||||
merged.User = rbac.DeduplicatePermissions(merged.User)
|
||||
|
||||
if allowAll || len(allowSet) == 0 {
|
||||
merged.AllowIDList = []rbac.AllowListElement{rbac.AllowListAll()}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user