Skip to content

Commit ae9dba2

Browse files
committed
re-order parameters
1 parent ec2cf09 commit ae9dba2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

coderd/authz/authz.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import (
1010

1111
var ErrUnauthorized = errors.New("unauthorized")
1212

13-
func Authorize(ctx context.Context, subj Subject, res Object, action rbac.Operation) error {
13+
func Authorize(ctx context.Context, subj Subject, action rbac.Operation, res Object) error {
1414
if res.ObjectType == "" {
1515
return ErrUnauthorized
1616
}
1717

1818
// Own actions only succeed if the subject owns the resource.
1919
if !isAll(action) {
2020
// Before we reject this, the user could be an admin with "-all" perms.
21-
err := Authorize(ctx, subj, res, rbac.Operation(strings.ReplaceAll(string(action), "-own", "-all")))
21+
err := Authorize(ctx, subj, rbac.Operation(strings.ReplaceAll(string(action), "-own", "-all")), res)
2222
if err == nil {
2323
return nil
2424
}

coderd/authz/authz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func TestAuthorize(t *testing.T) {
102102

103103
for _, c := range testCases {
104104
t.Run(c.Name, func(t *testing.T) {
105-
err := authz.Authorize(context.Background(), c.Subject, c.Resource, c.Action)
105+
err := authz.Authorize(context.Background(), c.Subject, c.Action, c.Resource)
106106
if c.ExpectedError {
107107
require.EqualError(t, err, authz.ErrUnauthorized.Error(), "unauth")
108108
} else {

0 commit comments

Comments
 (0)