-
Notifications
You must be signed in to change notification settings - Fork 897
chore: merge provisioner key and provisioner permissions #16628
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
Changes from 3 commits
0e0cd23
1abff51
0f15263
aee3289
ccc3afa
a6fcd52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,9 +147,13 @@ func (api *API) putOrgRoles(rw http.ResponseWriter, r *http.Request) { | |
UUID: organization.ID, | ||
Valid: true, | ||
}, | ||
SitePermissions: db2sdk.List(req.SitePermissions, sdkPermissionToDB), | ||
OrgPermissions: db2sdk.List(req.OrganizationPermissions, sdkPermissionToDB), | ||
UserPermissions: db2sdk.List(req.UserPermissions, sdkPermissionToDB), | ||
// Invalid permissions are filtered out. If this is changed | ||
// to throw an error, then the story of a previously valid role | ||
// now being invalid has to be addressed. Coder can change permissions, | ||
// objects, and actions at any time. | ||
SitePermissions: db2sdk.List(filterInvalidPermissions(req.SitePermissions), sdkPermissionToDB), | ||
OrgPermissions: db2sdk.List(filterInvalidPermissions(req.OrganizationPermissions), sdkPermissionToDB), | ||
UserPermissions: db2sdk.List(filterInvalidPermissions(req.UserPermissions), sdkPermissionToDB), | ||
Comment on lines
+154
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this, custom roles with the old perm are unable to be updated. |
||
}) | ||
if httpapi.Is404Error(err) { | ||
httpapi.ResourceNotFound(rw) | ||
|
@@ -247,6 +251,23 @@ func (api *API) deleteOrgRole(rw http.ResponseWriter, r *http.Request) { | |
httpapi.Write(ctx, rw, http.StatusNoContent, nil) | ||
} | ||
|
||
func filterInvalidPermissions(permissions []codersdk.Permission) []codersdk.Permission { | ||
// Filter out any invalid permissions | ||
var validPermissions []codersdk.Permission | ||
for _, permission := range permissions { | ||
err := rbac.Permission{ | ||
Negate: permission.Negate, | ||
ResourceType: string(permission.ResourceType), | ||
Action: policy.Action(permission.Action), | ||
}.Valid() | ||
if err != nil { | ||
continue | ||
} | ||
validPermissions = append(validPermissions, permission) | ||
} | ||
return validPermissions | ||
} | ||
|
||
Comment on lines
+254
to
+270
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to filter these out? Is this in order to handle custom roles? EDIT: Now I see your above comment. This is legit, but we should probably have some way of surfacing this to admins so that they can update the role. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @johnstcn yea this is really unfortunate. This is the continuous problem of "warnings" vs "errors", and our product does not support warnings very well. I can make a follow up issue. Without this change, a stale role is a blocking thing that is impossible to fix via the UI. Custom roles unfortunately just have not been given the resources to come up with a proper UX yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue made here: #16632 |
||
func sdkPermissionToDB(p codersdk.Permission) database.CustomRolePermission { | ||
return database.CustomRolePermission{ | ||
Negate: p.Negate, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.