Skip to content

Commit

Permalink
Merge pull request #75 from strongdm/idx-470/batch-authorize-entity-g…
Browse files Browse the repository at this point in the history
…etter

Change batch Authorize() to take an EntityGetter in place of an EntityMap
  • Loading branch information
kjamieson-sdm authored Dec 4, 2024
2 parents 2401ad8 + 01976d4 commit 38eae78
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ type String = types.String

// Other Cedar types

type EntityMap = types.EntityMap
type Entity = types.Entity
type EntityMap = types.EntityMap
type EntityType = types.EntityType
type EntityUIDSet = types.EntityUIDSet
type Pattern = types.Pattern
type Wildcard = types.Wildcard

// cedar-go types

type EntityGetter = types.EntityGetter
type Value = types.Value

// ____ _ _
Expand Down
2 changes: 1 addition & 1 deletion x/exp/batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var errInvalidPart = fmt.Errorf("invalid part")
// - It will error in case of a callback error.
//
// The result passed to the callback must be used / cloned immediately and not modified.
func Authorize(ctx context.Context, ps *cedar.PolicySet, entities types.EntityMap, request Request, cb Callback) error {
func Authorize(ctx context.Context, ps *cedar.PolicySet, entities types.EntityGetter, request Request, cb Callback) error {
be := &batchEvaler{}
var found mapset.MapSet[types.String]
findVariables(&found, request.Principal)
Expand Down
2 changes: 1 addition & 1 deletion x/exp/batch/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestBatch(t *testing.T) {
tests := []struct {
name string
policy *ast.Policy
entities types.EntityMap
entities types.EntityGetter
request Request
results []Result
}{
Expand Down

0 comments on commit 38eae78

Please sign in to comment.