-
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 2 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 @@ | |
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,24 @@ | |
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 { | ||
validPermissions = append(validPermissions, permission) | ||
} else { | ||
fmt.Println(err.Error()) | ||
} | ||
} | ||
return validPermissions | ||
} | ||
|
||
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.