privacy

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: MIT Imports: 4 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 = errors.New("ent/privacy: allow rule")

	// Deny may be returned by rules to indicate that the policy
	// evaluation should terminate with an deny decision.
	Deny = errors.New("ent/privacy: deny rule")

	// Skip may be returned by rules to indicate that the policy
	// evaluation should continue to the next rule.
	Skip = errors.New("ent/privacy: skip rule")
)

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 decision 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 AlertMutationRuleFunc

type AlertMutationRuleFunc func(context.Context, *ent.AlertMutation) error

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

func (AlertMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type AlertQueryRuleFunc

type AlertQueryRuleFunc func(context.Context, *ent.AlertQuery) error

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

func (AlertQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type BouncerMutationRuleFunc

type BouncerMutationRuleFunc func(context.Context, *ent.BouncerMutation) error

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

func (BouncerMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type BouncerQueryRuleFunc

type BouncerQueryRuleFunc func(context.Context, *ent.BouncerQuery) error

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

func (BouncerQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type DecisionMutationRuleFunc

type DecisionMutationRuleFunc func(context.Context, *ent.DecisionMutation) error

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

func (DecisionMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type DecisionQueryRuleFunc

type DecisionQueryRuleFunc func(context.Context, *ent.DecisionQuery) error

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

func (DecisionQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type EventMutationRuleFunc

type EventMutationRuleFunc func(context.Context, *ent.EventMutation) error

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

func (EventMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type EventQueryRuleFunc

type EventQueryRuleFunc func(context.Context, *ent.EventQuery) error

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

func (EventQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type MachineMutationRuleFunc

type MachineMutationRuleFunc func(context.Context, *ent.MachineMutation) error

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

func (MachineMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type MachineQueryRuleFunc

type MachineQueryRuleFunc func(context.Context, *ent.MachineQuery) error

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

func (MachineQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type MetaMutationRuleFunc

type MetaMutationRuleFunc func(context.Context, *ent.MetaMutation) error

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

func (MetaMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type MetaQueryRuleFunc

type MetaQueryRuleFunc func(context.Context, *ent.MetaQuery) error

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

func (MetaQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type MutationPolicy

type MutationPolicy []MutationRule

MutationPolicy combines multiple mutation rules into a single policy.

func (MutationPolicy) EvalMutation

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

EvalMutation evaluates a mutation against a mutation policy.

type MutationRule

type MutationRule interface {
	EvalMutation(context.Context, ent.Mutation) error
}

MutationRule defines the interface deciding whether a mutation is allowed and optionally modify 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 to allow 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 mutation policy.

func (Policy) EvalQuery

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

EvalQuery forwards evaluation to query policy.

type QueryMutationRule

type QueryMutationRule interface {
	QueryRule
	MutationRule
}

QueryMutationRule is the interface that 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 []QueryRule

QueryPolicy combines multiple query rules into a single policy.

func (QueryPolicy) EvalQuery

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

EvalQuery evaluates a query against a query policy.

type QueryRule

type QueryRule interface {
	EvalQuery(context.Context, ent.Query) error
}

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).

Jump to

Keyboard shortcuts

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