privacy

package
v0.0.0-...-2eeffc0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: Apache-2.0 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 ApplicationMutationRuleFunc

type ApplicationMutationRuleFunc func(context.Context, *ent.ApplicationMutation) error

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

func (ApplicationMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type ApplicationQueryRuleFunc

type ApplicationQueryRuleFunc func(context.Context, *ent.ApplicationQuery) error

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

func (ApplicationQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type CounterMutationRuleFunc

type CounterMutationRuleFunc func(context.Context, *ent.CounterMutation) error

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

func (CounterMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type CounterQueryRuleFunc

type CounterQueryRuleFunc func(context.Context, *ent.CounterQuery) error

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

func (CounterQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type GaugeMutationRuleFunc

type GaugeMutationRuleFunc func(context.Context, *ent.GaugeMutation) error

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

func (GaugeMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type GaugeQueryRuleFunc

type GaugeQueryRuleFunc func(context.Context, *ent.GaugeQuery) error

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

func (GaugeQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type GraphMutationRuleFunc

type GraphMutationRuleFunc func(context.Context, *ent.GraphMutation) error

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

func (GraphMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type GraphQueryRuleFunc

type GraphQueryRuleFunc func(context.Context, *ent.GraphQuery) error

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

func (GraphQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type GroupMutationRuleFunc

type GroupMutationRuleFunc func(context.Context, *ent.GroupMutation) error

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

func (GroupMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type GroupQueryRuleFunc

type GroupQueryRuleFunc func(context.Context, *ent.GroupQuery) error

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

func (GroupQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type HistogramMutationRuleFunc

type HistogramMutationRuleFunc func(context.Context, *ent.HistogramMutation) error

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

func (HistogramMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type HistogramQueryRuleFunc

type HistogramQueryRuleFunc func(context.Context, *ent.HistogramQuery) error

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

func (HistogramQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type MetricMutationRuleFunc

type MetricMutationRuleFunc func(context.Context, *ent.MetricMutation) error

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

func (MetricMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type MetricQueryRuleFunc

type MetricQueryRuleFunc func(context.Context, *ent.MetricQuery) error

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

func (MetricQueryRuleFunc) EvalQuery

func (f MetricQueryRuleFunc) 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).

type TagMutationRuleFunc

type TagMutationRuleFunc func(context.Context, *ent.TagMutation) error

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

func (TagMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type TagQueryRuleFunc

type TagQueryRuleFunc func(context.Context, *ent.TagQuery) error

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

func (TagQueryRuleFunc) EvalQuery

func (f TagQueryRuleFunc) 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