@@ -408,7 +408,7 @@ func (api *api) putUserRoles(rw http.ResponseWriter, r *http.Request) {
408
408
// Assigning a role requires the create permission. The middleware checks if
409
409
// we can update this user, so the combination of the 2 permissions enables
410
410
// assigning new roles.
411
- err := api .Authorizer .AuthorizeByRoleName (r .Context (), roles .ID .String (), roles .Roles ,
411
+ err := api .Authorizer .ByRoleName (r .Context (), roles .ID .String (), roles .Roles ,
412
412
rbac .ActionCreate , rbac .ResourceUserRole .WithID (roleName ))
413
413
if err != nil {
414
414
httpapi .Write (rw , http .StatusUnauthorized , httpapi.Response {
@@ -420,7 +420,7 @@ func (api *api) putUserRoles(rw http.ResponseWriter, r *http.Request) {
420
420
421
421
// Any roles that were removed also need to be checked.
422
422
for roleName := range has {
423
- err := api .Authorizer .AuthorizeByRoleName (r .Context (), roles .ID .String (), roles .Roles ,
423
+ err := api .Authorizer .ByRoleName (r .Context (), roles .ID .String (), roles .Roles ,
424
424
rbac .ActionDelete , rbac .ResourceUserRole .WithID (roleName ))
425
425
if err != nil {
426
426
httpapi .Write (rw , http .StatusUnauthorized , httpapi.Response {
@@ -490,7 +490,7 @@ func (api *api) organizationsByUser(rw http.ResponseWriter, r *http.Request) {
490
490
491
491
publicOrganizations := make ([]codersdk.Organization , 0 , len (organizations ))
492
492
for _ , organization := range organizations {
493
- err := api .Authorizer .AuthorizeByRoleName (r .Context (), roles .ID .String (), roles .Roles , rbac .ActionRead ,
493
+ err := api .Authorizer .ByRoleName (r .Context (), roles .ID .String (), roles .Roles , rbac .ActionRead ,
494
494
rbac .ResourceOrganization .
495
495
WithID (organization .ID .String ()).
496
496
InOrg (organization .ID ),
@@ -522,7 +522,7 @@ func (api *api) organizationByUserAndName(rw http.ResponseWriter, r *http.Reques
522
522
return
523
523
}
524
524
525
- err = api .Authorizer .AuthorizeByRoleName (r .Context (), roles .ID .String (), roles .Roles , rbac .ActionRead ,
525
+ err = api .Authorizer .ByRoleName (r .Context (), roles .ID .String (), roles .Roles , rbac .ActionRead ,
526
526
rbac .ResourceOrganization .
527
527
InOrg (organization .ID ).
528
528
WithID (organization .ID .String ()),
@@ -825,7 +825,7 @@ func (api *api) workspacesByUser(rw http.ResponseWriter, r *http.Request) {
825
825
}
826
826
organizationIDs := make ([]uuid.UUID , 0 )
827
827
for _ , organization := range organizations {
828
- err = api .Authorizer .AuthorizeByRoleName (r .Context (), user .ID .String (), roles .Roles , rbac .ActionRead , rbac .ResourceWorkspace .All ().InOrg (organization .ID ))
828
+ err = api .Authorizer .ByRoleName (r .Context (), user .ID .String (), roles .Roles , rbac .ActionRead , rbac .ResourceWorkspace .All ().InOrg (organization .ID ))
829
829
var apiErr * rbac.UnauthorizedError
830
830
if xerrors .As (err , & apiErr ) {
831
831
continue
0 commit comments