Documentation
¶
Index ¶
- Variables
- func ContextWithResolutionDepth(parent context.Context, depth uint32) context.Context
- func ResolutionDepthFromContext(ctx context.Context) (uint32, bool)
- type CheckFuncReducer
- type CheckHandlerFunc
- type CheckResolver
- type ConnectedObjectGraph
- func (g *ConnectedObjectGraph) PrunedRelationshipIngresses(target *openfgav1.RelationReference, source *openfgav1.RelationReference) ([]*RelationshipIngress, error)
- func (g *ConnectedObjectGraph) RelationshipIngresses(target *openfgav1.RelationReference, source *openfgav1.RelationReference) ([]*RelationshipIngress, error)
- type IngressCondition
- type LocalChecker
- type LocalCheckerOption
- type RelationshipIngress
- type RelationshipIngressType
- type ResolutionMetadata
- type ResolveCheckRequest
- func (r *ResolveCheckRequest) GetAuthorizationModelID() string
- func (r *ResolveCheckRequest) GetContextualTuples() []*openfgav1.TupleKey
- func (r *ResolveCheckRequest) GetResolutionMetadata() *ResolutionMetadata
- func (r *ResolveCheckRequest) GetStoreID() string
- func (r *ResolveCheckRequest) GetTupleKey() *openfgav1.TupleKey
- type ResolveCheckResponse
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ContextWithResolutionDepth ¶ added in v0.2.5
ContextWithResolutionDepth attaches the provided graph resolution depth to the parent context.
Types ¶
type CheckFuncReducer ¶ added in v0.3.5
type CheckFuncReducer func(ctx context.Context, concurrencyLimit uint32, handlers ...CheckHandlerFunc) (*openfgav1.CheckResponse, error)
CheckFuncReducer defines a function that combines or reduces one or more CheckHandlerFunc into a single CheckResponse with a maximum limit on the number of concurrent evaluations that can be in flight at any given time.
type CheckHandlerFunc ¶ added in v0.3.5
type CheckHandlerFunc func(ctx context.Context) (*openfgav1.CheckResponse, error)
CheckHandlerFunc defines a function that evaluates a CheckResponse or returns an error otherwise.
type CheckResolver ¶ added in v0.3.5
type CheckResolver interface {
ResolveCheck(ctx context.Context, req *ResolveCheckRequest) (*ResolveCheckResponse, error)
}
CheckResolver represents an interface that can be implemented to provide recursive resolution of a Check.
type ConnectedObjectGraph ¶
type ConnectedObjectGraph struct {
// contains filtered or unexported fields
}
ConnectedObjectGraph represents a graph of relationships and the connectivity between object and relation references within the graph through direct or indirect relationships. The ConnectedObjectGraph should be used to introspect what kind of relationships between object types can exist.
func BuildConnectedObjectGraph ¶
func BuildConnectedObjectGraph(typesystem *typesystem.TypeSystem) *ConnectedObjectGraph
BuildConnectedObjectGraph builds an object graph representing the graph of relationships between connected object types either through direct or indirect relationships.
func (*ConnectedObjectGraph) PrunedRelationshipIngresses ¶ added in v1.2.0
func (g *ConnectedObjectGraph) PrunedRelationshipIngresses(target *openfgav1.RelationReference, source *openfgav1.RelationReference) ([]*RelationshipIngress, error)
PrunedRelationshipIngresses compute the minimum incoming endges (ingresses) that are possible between the target and the source.
PrunedRelationshipIngresses is primarily used as the driver behind ingresses that work for models including intersection and exclusion. If the ingresses from the source to the target pass through a relationship involving intersection or exclusion (directly or indirectly), then the PrunedRelationshipIngresses will just return the first-most ingress involved in the rewrite.
Consider the following model:
type user type document
relations define allowed: [user] define viewer: [user] and allowed
The pruned relationship ingresses from the 'user' type to 'document#viewer' returns only the `document#viewer` ingress but with a 'RequiresFurtherEvalCondition' ingress condition. This is because when evaluating relationships involving intersection or exclusion we choose to only evaluate one operand of the rewrite rule, and for each result found we call Check on the result to evaluate the sub-condition on the 'and allowed' bit.
func (*ConnectedObjectGraph) RelationshipIngresses ¶
func (g *ConnectedObjectGraph) RelationshipIngresses(target *openfgav1.RelationReference, source *openfgav1.RelationReference) ([]*RelationshipIngress, error)
RelationshipIngresses computes the incoming edges (ingresses) that are possible between the target relation reference and the source relational reference.
To look up Ingresses(`document#viewer`, `source`), where `source` is a type with no relation, look up the definition of relation `document#viewer` and: 1. If `source` is a directly related type then add `source, direct` to the result. 2. If `objectType#relation` is a type and `objectType#relation` can be a `source` then add `objectType#relation, direct` to the result. 3. If computed userset, say `define viewer as writer`, then recurse on `document#writer, source`. 4. If tuple-to-userset, say, `define viewer as viewer from parent`. Go to parent and find its types. In this case, `folder`. Go to `folder` and see if it has a `viewer` relation. If so, recurse on `folder#viewer, source`.
To look up Ingresses(`document#viewer`, `folder#viewer`), look up the definition of relation `document#viewer` and: 1. If `folder#viewer` is a directly related type then add `folder#viewer, direct` to the result. 2. If computed userset, say `define viewer as writer`, then recurse on `document#writer, folder#viewer`. 3. If tuple-to-userset, say, `define viewer as viewer from parent`. Go to parent and find its related types.
- If parent's types includes `folder` type, and `folder` contains `viewer` relation then this is exactly a ttu rewrite and....?
- Otherwise, suppose the types contains `objectType` which has a relation `viewer`, then recurse on `objectType#viewer, folder#viewer`
type IngressCondition ¶ added in v1.2.0
type IngressCondition int
const ( // RequiresFurtherEvalCondition indicates an ingress condition whereby results expanded // under such an ingress require further Check evaluation before a determination of the // outcome can be made. // // Relationships involving intersection ('and') and/or exclusion ('but not') fall under // ingresses with this condition. RequiresFurtherEvalCondition IngressCondition = iota // NoFurtherEvalCondition indicates an ingress condition whereby results are factual and // known to be true and require no further evaluation before a determination of the outcome // can be made. NoFurtherEvalCondition )
type LocalChecker ¶ added in v0.3.5
type LocalChecker struct {
// contains filtered or unexported fields
}
func NewLocalChecker ¶ added in v0.3.5
func NewLocalChecker(ds storage.RelationshipTupleReader, opts ...LocalCheckerOption) *LocalChecker
NewLocalChecker constructs a LocalChecker that can be used to evaluate a Check request locally.
func (*LocalChecker) ResolveCheck ¶ added in v0.3.5
func (c *LocalChecker) ResolveCheck( ctx context.Context, req *ResolveCheckRequest, ) (*ResolveCheckResponse, error)
ResolveCheck resolves a node out of a tree of evaluations. If the depth of the tree has gotten too large, evaluation is aborted and an error is returned. The depth is NOT increased on computed usersets.
type LocalCheckerOption ¶ added in v1.3.0
type LocalCheckerOption func(d *LocalChecker)
func WithMaxConcurrentReads ¶ added in v1.3.0
func WithMaxConcurrentReads(limit uint32) LocalCheckerOption
WithMaxConcurrentReads see server.WithMaxConcurrentReadsForCheck
func WithResolveNodeBreadthLimit ¶ added in v1.3.0
func WithResolveNodeBreadthLimit(limit uint32) LocalCheckerOption
WithResolveNodeBreadthLimit see server.WithResolveNodeBreadthLimit
type RelationshipIngress ¶
type RelationshipIngress struct {
// The type of the relationship ingress
Type RelationshipIngressType
// The relationship reference that defines the ingress to some target relation
Ingress *openfgav1.RelationReference
// TuplesetRelation defines the tupleset relation reference that relates a source
// object reference with a target if the type of the relationship ingress is that
// of a TupleToUserset
TuplesetRelation *openfgav1.RelationReference
Condition IngressCondition
}
RelationshipIngress represents a possible ingress point between some source object reference and a target user reference.
func (RelationshipIngress) String ¶ added in v0.4.3
func (r RelationshipIngress) String() string
type RelationshipIngressType ¶
type RelationshipIngressType int
RelationshipIngressType is used to define an enum of the type of ingresses between source object references and target user references that exist in the graph of relationships.
const ( // DirectIngress defines a direct ingress connection between a source object reference // and some target user reference. DirectIngress RelationshipIngressType = iota TupleToUsersetIngress ComputedUsersetIngress )
func (RelationshipIngressType) String ¶ added in v0.3.5
func (r RelationshipIngressType) String() string
type ResolutionMetadata ¶ added in v0.3.5
type ResolutionMetadata struct {
Depth uint32
}
type ResolveCheckRequest ¶ added in v0.3.5
type ResolveCheckRequest struct {
StoreID string
AuthorizationModelID string
TupleKey *openfgav1.TupleKey
ContextualTuples []*openfgav1.TupleKey
ResolutionMetadata *ResolutionMetadata
}
func (*ResolveCheckRequest) GetAuthorizationModelID ¶ added in v0.3.5
func (r *ResolveCheckRequest) GetAuthorizationModelID() string
func (*ResolveCheckRequest) GetContextualTuples ¶ added in v0.3.5
func (r *ResolveCheckRequest) GetContextualTuples() []*openfgav1.TupleKey
func (*ResolveCheckRequest) GetResolutionMetadata ¶ added in v0.3.5
func (r *ResolveCheckRequest) GetResolutionMetadata() *ResolutionMetadata
func (*ResolveCheckRequest) GetStoreID ¶ added in v0.3.5
func (r *ResolveCheckRequest) GetStoreID() string
func (*ResolveCheckRequest) GetTupleKey ¶ added in v0.3.5
func (r *ResolveCheckRequest) GetTupleKey() *openfgav1.TupleKey
type ResolveCheckResponse ¶ added in v0.3.5
type ResolveCheckResponse struct {
Allowed bool
}