privacy

package
v0.0.0-...-b7d53eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Allow may be returned by rules to indicate that the policy
	// evaluation should terminate with an allow decision.
	Allow = privacy.Allow

	// Deny may be returned by rules to indicate that the policy
	// evaluation should terminate with an deny decision.
	Deny = privacy.Deny

	// Skip may be returned by rules to indicate that the policy
	// evaluation should continue to the next rule.
	Skip = privacy.Skip
)

Functions

func Allowf

func Allowf(format string, a ...interface{}) error

Allowf returns an formatted wrapped Allow decision.

func DecisionContext

func DecisionContext(parent context.Context, decision error) context.Context

DecisionContext creates a new context from the given parent context with a policy decision attach to it.

func DecisionFromContext

func DecisionFromContext(ctx context.Context) (error, bool)

DecisionFromContext retrieves the policy decision from the context.

func Denyf

func Denyf(format string, a ...interface{}) error

Denyf returns an formatted wrapped Deny decision.

func Skipf

func Skipf(format string, a ...interface{}) error

Skipf returns an formatted wrapped Skip decision.

Types

type APIAuditMutationRuleFunc

type APIAuditMutationRuleFunc func(context.Context, *ent.APIAuditMutation) error

The APIAuditMutationRuleFunc type is an adapter to allow the use of ordinary functions as a mutation rule.

func (APIAuditMutationRuleFunc) EvalMutation

func (f APIAuditMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error

EvalMutation calls f(ctx, m).

type APIAuditQueryRuleFunc

type APIAuditQueryRuleFunc func(context.Context, *ent.APIAuditQuery) error

The APIAuditQueryRuleFunc type is an adapter to allow the use of ordinary functions as a query rule.

func (APIAuditQueryRuleFunc) EvalQuery

func (f APIAuditQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error

EvalQuery return f(ctx, q).

type FactMutationRuleFunc

type FactMutationRuleFunc func(context.Context, *ent.FactMutation) error

The FactMutationRuleFunc type is an adapter to allow the use of ordinary functions as a mutation rule.

func (FactMutationRuleFunc) EvalMutation

func (f FactMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error

EvalMutation calls f(ctx, m).

type FactQueryRuleFunc

type FactQueryRuleFunc func(context.Context, *ent.FactQuery) error

The FactQueryRuleFunc type is an adapter to allow the use of ordinary functions as a query rule.

func (FactQueryRuleFunc) EvalQuery

func (f FactQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error

EvalQuery return f(ctx, q).

type FactTypeMutationRuleFunc

type FactTypeMutationRuleFunc func(context.Context, *ent.FactTypeMutation) error

The FactTypeMutationRuleFunc type is an adapter to allow the use of ordinary functions as a mutation rule.

func (FactTypeMutationRuleFunc) EvalMutation

func (f FactTypeMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error

EvalMutation calls f(ctx, m).

type FactTypeQueryRuleFunc

type FactTypeQueryRuleFunc func(context.Context, *ent.FactTypeQuery) error

The FactTypeQueryRuleFunc type is an adapter to allow the use of ordinary functions as a query rule.

func (FactTypeQueryRuleFunc) EvalQuery

func (f FactTypeQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error

EvalQuery return f(ctx, q).

type Filter

type Filter interface {
	// Where applies a filter on the executed query/mutation.
	Where(entql.P)
}

Filter is the interface that wraps the Where function for filtering nodes in queries and mutations.

type FilterFunc

type FilterFunc func(context.Context, Filter) error

The FilterFunc type is an adapter that allows the use of ordinary functions as filters for query and mutation types.

func (FilterFunc) EvalMutation

func (f FilterFunc) EvalMutation(ctx context.Context, m ent.Mutation) error

EvalMutation calls f(ctx, q) if the mutation implements the Filter interface, otherwise it is denied.

func (FilterFunc) EvalQuery

func (f FilterFunc) EvalQuery(ctx context.Context, q ent.Query) error

EvalQuery calls f(ctx, q) if the query implements the Filter interface, otherwise it is denied.

type GrantMutationRuleFunc

type GrantMutationRuleFunc func(context.Context, *ent.GrantMutation) error

The GrantMutationRuleFunc type is an adapter to allow the use of ordinary functions as a mutation rule.

func (GrantMutationRuleFunc) EvalMutation

func (f GrantMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error

EvalMutation calls f(ctx, m).

type GrantQueryRuleFunc

type GrantQueryRuleFunc func(context.Context, *ent.GrantQuery) error

The GrantQueryRuleFunc type is an adapter to allow the use of ordinary functions as a query rule.

func (GrantQueryRuleFunc) EvalQuery

func (f GrantQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error

EvalQuery return f(ctx, q).

type MutationPolicy

type MutationPolicy = privacy.MutationPolicy

MutationPolicy combines multiple mutation rules into a single policy.

type MutationRule

type MutationRule = privacy.MutationRule

MutationRule defines the interface which decides whether a mutation is allowed and optionally modifies it.

func DenyMutationOperationRule

func DenyMutationOperationRule(op ent.Op) MutationRule

DenyMutationOperationRule returns a rule denying specified mutation operation.

func OnMutationOperation

func OnMutationOperation(rule MutationRule, op ent.Op) MutationRule

OnMutationOperation evaluates the given rule only on a given mutation operation.

type MutationRuleFunc

type MutationRuleFunc func(context.Context, ent.Mutation) error

MutationRuleFunc type is an adapter which allows the use of ordinary functions as mutation rules.

func (MutationRuleFunc) EvalMutation

func (f MutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error

EvalMutation returns f(ctx, m).

type Policy

type Policy struct {
	Query    QueryPolicy
	Mutation MutationPolicy
}

Policy groups query and mutation policies.

func (Policy) EvalMutation

func (policy Policy) EvalMutation(ctx context.Context, m ent.Mutation) error

EvalMutation forwards evaluation to mutate a policy.

func (Policy) EvalQuery

func (policy Policy) EvalQuery(ctx context.Context, q ent.Query) error

EvalQuery forwards evaluation to query a policy.

type QueryMutationRule

type QueryMutationRule interface {
	QueryRule
	MutationRule
}

QueryMutationRule is an interface which groups query and mutation rules.

func AlwaysAllowRule

func AlwaysAllowRule() QueryMutationRule

AlwaysAllowRule returns a rule that returns an allow decision.

func AlwaysDenyRule

func AlwaysDenyRule() QueryMutationRule

AlwaysDenyRule returns a rule that returns a deny decision.

func ContextQueryMutationRule

func ContextQueryMutationRule(eval func(context.Context) error) QueryMutationRule

ContextQueryMutationRule creates a query/mutation rule from a context eval func.

type QueryPolicy

type QueryPolicy = privacy.QueryPolicy

QueryPolicy combines multiple query rules into a single policy.

type QueryRule

type QueryRule = privacy.QueryRule

QueryRule defines the interface deciding whether a query is allowed and optionally modify it.

type QueryRuleFunc

type QueryRuleFunc func(context.Context, ent.Query) error

QueryRuleFunc type is an adapter to allow the use of ordinary functions as query rules.

func (QueryRuleFunc) EvalQuery

func (f QueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error

Eval returns f(ctx, q).

type ScopeMutationRuleFunc

type ScopeMutationRuleFunc func(context.Context, *ent.ScopeMutation) error

The ScopeMutationRuleFunc type is an adapter to allow the use of ordinary functions as a mutation rule.

func (ScopeMutationRuleFunc) EvalMutation

func (f ScopeMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error

EvalMutation calls f(ctx, m).

type ScopeQueryRuleFunc

type ScopeQueryRuleFunc func(context.Context, *ent.ScopeQuery) error

The ScopeQueryRuleFunc type is an adapter to allow the use of ordinary functions as a query rule.

func (ScopeQueryRuleFunc) EvalQuery

func (f ScopeQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error

EvalQuery return f(ctx, q).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL