Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: remove EntityLoader interface #55

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion authorize.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (

// IsAuthorized uses the combination of the PolicySet and Entities to determine
// if the given Request to determine Decision and Diagnostic.
func (p PolicySet) IsAuthorized(entities EntityLoader, req Request) (Decision, Diagnostic) {
func (p PolicySet) IsAuthorized(entities types.EntityMap, req Request) (Decision, Diagnostic) {
env := eval.Env{
Entities: entities,
Principal: req.Principal,
Expand Down
2 changes: 1 addition & 1 deletion internal/eval/evalers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func zeroValue() types.Value {
}

type Env struct {
Entities types.EntityLoader
Entities types.EntityMap
Principal, Action, Resource types.Value
Context types.Value
}
Expand Down
1 change: 0 additions & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type String = types.String

// Other Cedar types

type EntityLoader = types.EntityLoader
type Entities = types.EntityMap
type Entity = types.Entity
type EntityType = types.EntityType
Expand Down
5 changes: 0 additions & 5 deletions types/entity_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
"golang.org/x/exp/maps"
)

// EntityLoader defines the interface for loading entities from an entity store.
type EntityLoader interface {
Load(EntityUID) (Entity, bool)
}

// An EntityMap is a collection of all the entities that are needed to evaluate
// authorization requests. The key is an EntityUID which uniquely identifies
// the Entity (it must be the same as the UID within the Entity itself.)
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 @@ -102,7 +102,7 @@ var errInvalidPart = fmt.Errorf("invalid part")
// - It will error in case there are unused variables.
//
// The result passed to the callback must be used / cloned immediately and not modified.
func Authorize(ctx context.Context, ps *cedar.PolicySet, entities types.EntityLoader, request Request, cb Callback) error {
func Authorize(ctx context.Context, ps *cedar.PolicySet, entities types.EntityMap, request Request, cb Callback) error {
be := &batchEvaler{}
var found mapset.MapSet[types.String]
findVariables(&found, request.Principal)
Expand Down
Loading