Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75747f5

Browse files
committed
Use sentinel error always
1 parent b583a1e commit 75747f5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

coderd/authzquery/authzquerier.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77

88
"cdr.dev/slog"
99

10-
"golang.org/x/xerrors"
11-
1210
"github.com/coder/coder/coderd/database"
1311
"github.com/coder/coder/coderd/rbac"
1412
)
@@ -58,12 +56,12 @@ func (q *AuthzQuerier) InTx(function func(querier database.Store) error, txOpts
5856
func (q *AuthzQuerier) authorizeContext(ctx context.Context, action rbac.Action, object rbac.Objecter) error {
5957
act, ok := ActorFromContext(ctx)
6058
if !ok {
61-
return xerrors.Errorf("no authorization actor in context")
59+
return NoActorError
6260
}
6361

6462
err := q.authorizer.Authorize(ctx, act, action, object.RBACObject())
6563
if err != nil {
66-
return xerrors.Errorf("unauthorized: %w", err)
64+
return LogNotAuthorizedError(ctx, q.logger, err)
6765
}
6866
return nil
6967
}

coderd/authzquery/methods_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ func (s *MethodTestSuite) RunMethodTest(testCaseF func(t *testing.T, db database
9090

9191
db := databasefake.New()
9292
rec := &coderdtest.RecordingAuthorizer{
93-
Wrapped: &coderdtest.FakeAuthorizer{},
93+
Wrapped: &coderdtest.FakeAuthorizer{
94+
AlwaysReturn: nil,
95+
},
9496
}
9597
az := authzquery.NewAuthzQuerier(db, rec, slog.Make())
9698
actor := rbac.Subject{

0 commit comments

Comments
 (0)