feat: add rbac tracing (#4093)

This commit is contained in:
Colin Adler
2022-09-16 18:32:15 +00:00
committed by GitHub
parent 1bca269b90
commit b340634aaa
14 changed files with 79 additions and 34 deletions
+8
View File
@@ -6,6 +6,8 @@ import (
"golang.org/x/xerrors"
"github.com/open-policy-agent/opa/rego"
"github.com/coder/coder/coderd/tracing"
)
type PartialAuthorizer struct {
@@ -24,6 +26,9 @@ type PartialAuthorizer struct {
}
func newPartialAuthorizer(ctx context.Context, subjectID string, roles []Role, action Action, objectType string) (*PartialAuthorizer, error) {
ctx, span := tracing.StartSpan(ctx)
defer span.End()
input := map[string]interface{}{
"subject": authSubject{
ID: subjectID,
@@ -83,6 +88,9 @@ func newPartialAuthorizer(ctx context.Context, subjectID string, roles []Role, a
// Authorize authorizes a single object using the partially prepared queries.
func (a PartialAuthorizer) Authorize(ctx context.Context, object Object) error {
ctx, span := tracing.StartSpan(ctx)
defer span.End()
if a.alwaysTrue {
return nil
}