mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: Allow RecordingAuthorizer to record multiple rbac authz calls (#6024)
* chore: Allow RecordingAuthorizer to record multiple rbac authz calls Prior iteration only recorded the last call. This is required for more comprehensive testing
This commit is contained in:
@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/coder/coder/coderd/rbac/regosql"
|
||||
"github.com/coder/coder/coderd/tracing"
|
||||
"github.com/coder/coder/coderd/util/slice"
|
||||
)
|
||||
|
||||
// Subject is a struct that contains all the elements of a subject in an rbac
|
||||
@ -26,6 +27,25 @@ type Subject struct {
|
||||
Scope ExpandableScope
|
||||
}
|
||||
|
||||
func (s Subject) Equal(b Subject) bool {
|
||||
if s.ID != b.ID {
|
||||
return false
|
||||
}
|
||||
|
||||
if !slice.SameElements(s.Groups, b.Groups) {
|
||||
return false
|
||||
}
|
||||
|
||||
if !slice.SameElements(s.SafeRoleNames(), b.SafeRoleNames()) {
|
||||
return false
|
||||
}
|
||||
|
||||
if s.SafeScopeName() != b.SafeScopeName() {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// SafeScopeName prevent nil pointer dereference.
|
||||
func (s Subject) SafeScopeName() string {
|
||||
if s.Scope == nil {
|
||||
|
Reference in New Issue
Block a user