privacy

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 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 CardMutationRuleFunc

type CardMutationRuleFunc func(context.Context, *ent.CardMutation) error

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

func (CardMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type CardQueryRuleFunc

type CardQueryRuleFunc func(context.Context, *ent.CardQuery) error

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

func (CardQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type CommentMutationRuleFunc

type CommentMutationRuleFunc func(context.Context, *ent.CommentMutation) error

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

func (CommentMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type CommentQueryRuleFunc

type CommentQueryRuleFunc func(context.Context, *ent.CommentQuery) error

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

func (CommentQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type FieldTypeMutationRuleFunc

type FieldTypeMutationRuleFunc func(context.Context, *ent.FieldTypeMutation) error

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

func (FieldTypeMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type FieldTypeQueryRuleFunc

type FieldTypeQueryRuleFunc func(context.Context, *ent.FieldTypeQuery) error

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

func (FieldTypeQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type FileMutationRuleFunc

type FileMutationRuleFunc func(context.Context, *ent.FileMutation) error

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

func (FileMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type FileQueryRuleFunc

type FileQueryRuleFunc func(context.Context, *ent.FileQuery) error

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

func (FileQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type FileTypeMutationRuleFunc

type FileTypeMutationRuleFunc func(context.Context, *ent.FileTypeMutation) error

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

func (FileTypeMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type FileTypeQueryRuleFunc

type FileTypeQueryRuleFunc func(context.Context, *ent.FileTypeQuery) error

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

func (FileTypeQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type GoodsMutationRuleFunc added in v0.4.3

type GoodsMutationRuleFunc func(context.Context, *ent.GoodsMutation) error

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

func (GoodsMutationRuleFunc) EvalMutation added in v0.4.3

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

EvalMutation calls f(ctx, m).

type GoodsQueryRuleFunc added in v0.4.3

type GoodsQueryRuleFunc func(context.Context, *ent.GoodsQuery) error

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

func (GoodsQueryRuleFunc) EvalQuery added in v0.4.3

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

EvalQuery return f(ctx, q).

type GroupInfoMutationRuleFunc

type GroupInfoMutationRuleFunc func(context.Context, *ent.GroupInfoMutation) error

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

func (GroupInfoMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type GroupInfoQueryRuleFunc

type GroupInfoQueryRuleFunc func(context.Context, *ent.GroupInfoQuery) error

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

func (GroupInfoQueryRuleFunc) EvalQuery

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

type ItemMutationRuleFunc func(context.Context, *ent.ItemMutation) error

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

func (ItemMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type ItemQueryRuleFunc

type ItemQueryRuleFunc func(context.Context, *ent.ItemQuery) error

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

func (ItemQueryRuleFunc) EvalQuery

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

type NodeMutationRuleFunc func(context.Context, *ent.NodeMutation) error

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

func (NodeMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type NodeQueryRuleFunc

type NodeQueryRuleFunc func(context.Context, *ent.NodeQuery) error

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

func (NodeQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type PetMutationRuleFunc

type PetMutationRuleFunc func(context.Context, *ent.PetMutation) error

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

func (PetMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type PetQueryRuleFunc

type PetQueryRuleFunc func(context.Context, *ent.PetQuery) error

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

func (PetQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

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 SpecMutationRuleFunc

type SpecMutationRuleFunc func(context.Context, *ent.SpecMutation) error

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

func (SpecMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type SpecQueryRuleFunc

type SpecQueryRuleFunc func(context.Context, *ent.SpecQuery) error

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

func (SpecQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type TaskMutationRuleFunc added in v0.4.1

type TaskMutationRuleFunc func(context.Context, *ent.TaskMutation) error

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

func (TaskMutationRuleFunc) EvalMutation added in v0.4.1

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

EvalMutation calls f(ctx, m).

type TaskQueryRuleFunc added in v0.4.1

type TaskQueryRuleFunc func(context.Context, *ent.TaskQuery) error

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

func (TaskQueryRuleFunc) EvalQuery added in v0.4.1

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

EvalQuery return f(ctx, q).

type UserMutationRuleFunc

type UserMutationRuleFunc func(context.Context, *ent.UserMutation) error

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

func (UserMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type UserQueryRuleFunc

type UserQueryRuleFunc func(context.Context, *ent.UserQuery) error

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

func (UserQueryRuleFunc) EvalQuery

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