Documentation ¶
Index ¶
- type BulkChecker
- type BulkCheckerRequest
- type BulkPublisher
- type CheckCombiner
- type CheckEngine
- type CheckFunction
- type CheckOption
- type CheckResponse
- type ERMap
- type EntityFilterEngine
- type ExpandCombiner
- type ExpandEngine
- type ExpandFunction
- type ExpandResponse
- type LookupEntityEngine
- func (engine *LookupEntityEngine) LookupEntity(ctx context.Context, request *base.PermissionLookupEntityRequest) (response *base.PermissionLookupEntityResponse, err error)
- func (engine *LookupEntityEngine) LookupEntityStream(ctx context.Context, request *base.PermissionLookupEntityRequest, ...) (err error)
- type LookupEntityOption
- type LookupSubjectCombiner
- type LookupSubjectEngine
- type LookupSubjectFunction
- type LookupSubjectOption
- type LookupSubjectResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkChecker ¶
type BulkChecker struct { // input queue for permission check requests RequestChan chan BulkCheckerRequest // contains filtered or unexported fields }
BulkChecker is a struct for checking permissions in bulk.
func NewBulkChecker ¶
func NewBulkChecker(ctx context.Context, engine *CheckEngine, callback func(entityID string, result base.PermissionCheckResponse_Result), concurrencyLimit int) *BulkChecker
NewBulkChecker creates a new BulkChecker instance. ctx: context for managing goroutines and cancellation engine: the CheckEngine to use for permission checks callback: a callback function that handles the result of each permission check concurrencyLimit: the maximum number of concurrent permission checks
func (*BulkChecker) Start ¶
func (c *BulkChecker) Start()
Start begins processing permission check requests from the RequestChan. It starts an errgroup that manages multiple goroutines for performing permission checks.
func (*BulkChecker) Stop ¶
func (c *BulkChecker) Stop()
Stop stops input by closing the RequestChan.
func (*BulkChecker) Wait ¶
func (c *BulkChecker) Wait() error
Wait waits for all goroutines in the errgroup to finish. Returns an error if any of the goroutines encounter an error.
type BulkCheckerRequest ¶
type BulkCheckerRequest struct { Request *base.PermissionCheckRequest Result base.PermissionCheckResponse_Result }
BulkCheckerRequest is a struct for a permission check request and the channel to send the result.
type BulkPublisher ¶
type BulkPublisher struct {
// contains filtered or unexported fields
}
BulkPublisher is a struct for streaming permission check results.
func NewBulkPublisher ¶
func NewBulkPublisher(ctx context.Context, request *base.PermissionLookupEntityRequest, bulkChecker *BulkChecker) *BulkPublisher
NewBulkPublisher creates a new BulkStreamer instance.
func (*BulkPublisher) Publish ¶
func (s *BulkPublisher) Publish(entity *base.Entity, metadata *base.PermissionCheckRequestMetadata, result base.PermissionCheckResponse_Result)
Publish publishes a permission check request to the BulkChecker.
type CheckCombiner ¶
type CheckCombiner func(ctx context.Context, functions []CheckFunction, limit int) (*base.PermissionCheckResponse, error)
CheckCombiner is a type that represents a function which takes a context, a slice of CheckFunctions, and a limit. It combines the results of multiple CheckFunctions according to a specific strategy and returns a PermissionCheckResponse along with an error.
type CheckEngine ¶
type CheckEngine struct {
// contains filtered or unexported fields
}
CheckEngine is a core component responsible for performing permission checks. It reads schema and relationship information, and uses the engine key manager to validate permission requests.
func NewCheckEngine ¶
func NewCheckEngine(sr storage.SchemaReader, rr storage.RelationshipReader, opts ...CheckOption) *CheckEngine
NewCheckEngine creates a new CheckEngine instance for performing permission checks. It takes a key manager, schema reader, and relationship reader as parameters. Additionally, it allows for optional configuration through CheckOption function arguments.
func (*CheckEngine) Check ¶ added in v0.4.0
func (engine *CheckEngine) Check(ctx context.Context, request *base.PermissionCheckRequest) (response *base.PermissionCheckResponse, err error)
Check executes a permission check based on the provided request. The permission field in the request can either be a relation or an permission. This function performs various checks and returns the permission check response along with any errors that may have occurred.
func (*CheckEngine) SetInvoker ¶ added in v0.4.0
func (engine *CheckEngine) SetInvoker(invoker invoke.Check)
SetInvoker sets the delegate for the CheckEngine.
type CheckFunction ¶
type CheckFunction func(ctx context.Context) (*base.PermissionCheckResponse, error)
CheckFunction is a type that represents a function that takes a context and returns a PermissionCheckResponse along with an error. It is used to perform individual permission checks within the CheckEngine.
type CheckOption ¶
type CheckOption func(engine *CheckEngine)
CheckOption - a functional option type for configuring the CheckEngine.
func CheckConcurrencyLimit ¶
func CheckConcurrencyLimit(limit int) CheckOption
CheckConcurrencyLimit - a functional option that sets the concurrency limit for the CheckEngine.
type CheckResponse ¶
type CheckResponse struct {
// contains filtered or unexported fields
}
CheckResponse - a struct that holds a PermissionCheckResponse and an error for a single check function.
type ERMap ¶
type ERMap struct {
// contains filtered or unexported fields
}
ERMap - a thread-safe map of ENR records.
type EntityFilterEngine ¶ added in v0.4.1
type EntityFilterEngine struct {
// contains filtered or unexported fields
}
EntityFilterEngine is responsible for executing linked entity operations
func NewEntityFilterEngine ¶ added in v0.4.1
func NewEntityFilterEngine(schemaReader storage.SchemaReader, relationshipReader storage.RelationshipReader) *EntityFilterEngine
NewEntityFilterEngine creates a new EntityFilter engine
func (*EntityFilterEngine) EntityFilter ¶ added in v0.4.1
func (engine *EntityFilterEngine) EntityFilter( ctx context.Context, request *base.PermissionEntityFilterRequest, visits *ERMap, publisher *BulkPublisher, ) (err error)
EntityFilter is a method of the EntityFilterEngine struct. It executes a permission request for linked entities.
type ExpandCombiner ¶
type ExpandCombiner func(ctx context.Context, target *base.EntityAndRelation, functions []ExpandFunction) ExpandResponse
ExpandCombiner represents a function that combines the results of multiple ExpandFunction calls into a single ExpandResponse.
type ExpandEngine ¶
type ExpandEngine struct {
// contains filtered or unexported fields
}
ExpandEngine - This comment is describing a type called ExpandEngine. The ExpandEngine type contains two fields: schemaReader, which is a storage.SchemaReader object, and relationshipReader, which is a storage.RelationshipReader object. The ExpandEngine type is used to expand permission scopes based on a given user ID and a set of permission requirements.
func NewExpandEngine ¶
func NewExpandEngine(sr storage.SchemaReader, rr storage.RelationshipReader) *ExpandEngine
NewExpandEngine - This function creates a new instance of ExpandEngine by taking a SchemaReader and a RelationshipReader as parameters and returning a pointer to the created instance. The SchemaReader is used to read schema definitions, while the RelationshipReader is used to read relationship definitions.
func (*ExpandEngine) Expand ¶ added in v0.4.0
func (engine *ExpandEngine) Expand(ctx context.Context, request *base.PermissionExpandRequest) (response *base.PermissionExpandResponse, err error)
Expand - This is the Run function of the ExpandEngine type, which takes a context, a PermissionExpandRequest, and returns a PermissionExpandResponse and an error. The function begins by starting a new OpenTelemetry span, with the name "permissions.expand.execute". It then checks if a snap token and schema version are included in the request. If not, it retrieves the head snapshot and head schema version, respectively, from the appropriate repository.
Finally, the function calls the expand function of the ExpandEngine type with the context, PermissionExpandRequest, and false value, and returns the resulting PermissionExpandResponse and error. If there is an error, the span records the error and sets the status to indicate an error.
type ExpandFunction ¶
type ExpandFunction func(ctx context.Context, expandChain chan<- ExpandResponse)
ExpandFunction represents a function that expands the schema and relationships of a request and sends the response through the provided channel.
type ExpandResponse ¶
type ExpandResponse struct { Response *base.PermissionExpandResponse Err error }
ExpandResponse is a struct that contains the response and error returned from the expand function in the ExpandEngine. It is used to return the response and error together as a single object.
type LookupEntityEngine ¶
type LookupEntityEngine struct {
// contains filtered or unexported fields
}
LookupEntityEngine is a struct that performs permission checks on a set of entities and returns the entities that have the requested permission.
func NewLookupEntityEngine ¶
func NewLookupEntityEngine(check *CheckEngine, filter *EntityFilterEngine, opts ...LookupEntityOption) *LookupEntityEngine
NewLookupEntityEngine creates a new LookupEntityEngine instance. engine: the CheckEngine to use for permission checks reader: the RelationshipReader to retrieve entity relationships
func (*LookupEntityEngine) LookupEntity ¶ added in v0.4.0
func (engine *LookupEntityEngine) LookupEntity(ctx context.Context, request *base.PermissionLookupEntityRequest) (response *base.PermissionLookupEntityResponse, err error)
LookupEntity performs a permission check on a set of entities and returns a response containing the IDs of the entities that have the requested permission.
func (*LookupEntityEngine) LookupEntityStream ¶ added in v0.4.0
func (engine *LookupEntityEngine) LookupEntityStream(ctx context.Context, request *base.PermissionLookupEntityRequest, server base.Permission_LookupEntityStreamServer) (err error)
LookupEntityStream performs a permission check on a set of entities and streams the results containing the IDs of the entities that have the requested permission.
type LookupEntityOption ¶
type LookupEntityOption func(engine *LookupEntityEngine)
LookupEntityOption - a functional option type for configuring the LookupEntityEngine.
func LookupEntityConcurrencyLimit ¶
func LookupEntityConcurrencyLimit(limit int) LookupEntityOption
LookupEntityConcurrencyLimit - a functional option that sets the concurrency limit for the LookupEntityEngine.
type LookupSubjectCombiner ¶ added in v0.4.2
type LookupSubjectCombiner func(ctx context.Context, functions []LookupSubjectFunction, limit int) (*base.PermissionLookupSubjectResponse, error)
LookupSubjectCombiner defines the type for a function that takes a context, a slice of LookupSubjectFunctions, an integer as a limit and returns a pointer to a PermissionLookupSubjectResponse and an error. This type is useful when you want to define a function that can execute multiple LookupSubjectFunctions in a specific way (like concurrently with a limit or sequentially) and combine their results into a single PermissionLookupSubjectResponse.
type LookupSubjectEngine ¶ added in v0.4.1
type LookupSubjectEngine struct {
// contains filtered or unexported fields
}
func NewLookupSubjectEngine ¶ added in v0.4.1
func NewLookupSubjectEngine(sr storage.SchemaReader, rr storage.RelationshipReader, opts ...LookupSubjectOption) *LookupSubjectEngine
NewLookupSubjectEngine is a constructor function for a LookupSubjectEngine. It initializes a new LookupSubjectEngine with a schema reader, a relationship reader, and an optional set of LookupSubjectOptions.
func (*LookupSubjectEngine) LookupSubject ¶ added in v0.4.1
func (engine *LookupSubjectEngine) LookupSubject(ctx context.Context, request *base.PermissionLookupSubjectRequest) (response *base.PermissionLookupSubjectResponse, err error)
LookupSubject is a method for the LookupSubjectEngine struct. It takes a context and a pointer to a PermissionLookupSubjectRequest and returns a pointer to a PermissionLookupSubjectResponse and an error.
type LookupSubjectFunction ¶ added in v0.4.2
type LookupSubjectFunction func(ctx context.Context) (*base.PermissionLookupSubjectResponse, error)
LookupSubjectFunction defines the type for a function that takes a context and returns a pointer to a PermissionLookupSubjectResponse and an error. This type is often used when you want to pass around functions with this specific signature.
type LookupSubjectOption ¶ added in v0.4.1
type LookupSubjectOption func(engine *LookupSubjectEngine)
LookupSubjectOption - a functional option type for configuring the LookupSubjectEngine.
func LookupSubjectConcurrencyLimit ¶ added in v0.4.1
func LookupSubjectConcurrencyLimit(limit int) LookupSubjectOption
LookupSubjectConcurrencyLimit - a functional option that sets the concurrency limit for the LookupSubjectEngine.
type LookupSubjectResponse ¶ added in v0.4.2
type LookupSubjectResponse struct {
// contains filtered or unexported fields
}
LookupSubjectResponse -