Skip to content

Commit d72f4b2

Browse files
committed
fiiiine steven
1 parent 944127b commit d72f4b2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

coderd/httpapi/httpapi.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func Write(ctx context.Context, rw http.ResponseWriter, status int, response int
199199
_, span := tracing.StartSpan(ctx)
200200
defer span.End()
201201

202-
if rec, err := rbac.GetAuthzCheckRecorder(ctx); err == nil {
202+
if rec, ok := rbac.GetAuthzCheckRecorder(ctx); ok {
203203
// If you're here because you saw this header in a response, and you're
204204
// trying to investigate the code, here are a couple of notable things
205205
// for you to know:
@@ -230,7 +230,7 @@ func WriteIndent(ctx context.Context, rw http.ResponseWriter, status int, respon
230230
_, span := tracing.StartSpan(ctx)
231231
defer span.End()
232232

233-
if rec, err := rbac.GetAuthzCheckRecorder(ctx); err == nil {
233+
if rec, ok := rbac.GetAuthzCheckRecorder(ctx); ok {
234234
rw.Header().Set("x-dbauthz-checks", rec.String())
235235
}
236236

coderd/rbac/authz.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,13 +822,13 @@ func recordAuthzCheck(ctx context.Context, action policy.Action, object Object,
822822
r.checks.Store(b.String(), authorized)
823823
}
824824

825-
func GetAuthzCheckRecorder(ctx context.Context) (*AuthzCheckRecorder, error) {
825+
func GetAuthzCheckRecorder(ctx context.Context) (*AuthzCheckRecorder, bool) {
826826
checks, ok := ctx.Value(authzCheckRecorderKey{}).(*AuthzCheckRecorder)
827827
if !ok {
828-
return nil, xerrors.New("no authz checks recorded")
828+
return nil, false
829829
}
830830

831-
return checks, nil
831+
return checks, true
832832
}
833833

834834
// String serializes all of the checks recorded, using the following syntax:

0 commit comments

Comments
 (0)