authorize: fix not found check (#3410)

This commit is contained in:
Caleb Doxsey 2022-06-08 09:15:57 -06:00 committed by GitHub
parent 4635509d5c
commit 493148b13f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -3,11 +3,10 @@ package authorize
import (
"context"
"github.com/open-policy-agent/opa/storage"
"github.com/pomerium/pomerium/internal/telemetry/trace"
"github.com/pomerium/pomerium/pkg/grpc/session"
"github.com/pomerium/pomerium/pkg/grpc/user"
"github.com/pomerium/pomerium/pkg/storage"
)
type sessionOrServiceAccount interface {

View file

@ -113,3 +113,8 @@ func matchProtoMapValue(fd protoreflect.FieldDescriptor, m protoreflect.Map, que
})
return matches
}
// IsNotFound returns true if the error is because a record was not found.
func IsNotFound(err error) bool {
return errors.Is(err, ErrNotFound) || status.Code(err) == codes.NotFound
}