privacy

package
v0.0.0-...-7d6f566 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: GPL-3.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 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 ClassroomMutationRuleFunc

type ClassroomMutationRuleFunc func(context.Context, *ent.ClassroomMutation) error

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

func (ClassroomMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type ClassroomQueryRuleFunc

type ClassroomQueryRuleFunc func(context.Context, *ent.ClassroomQuery) error

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

func (ClassroomQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type CredentialMutationRuleFunc

type CredentialMutationRuleFunc func(context.Context, *ent.CredentialMutation) error

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

func (CredentialMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type CredentialQueryRuleFunc

type CredentialQueryRuleFunc func(context.Context, *ent.CredentialQuery) error

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

func (CredentialQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type LevelMutationRuleFunc

type LevelMutationRuleFunc func(context.Context, *ent.LevelMutation) error

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

func (LevelMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type LevelQueryRuleFunc

type LevelQueryRuleFunc func(context.Context, *ent.LevelQuery) error

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

func (LevelQueryRuleFunc) EvalQuery

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

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.

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 UserLevelMutationRuleFunc

type UserLevelMutationRuleFunc func(context.Context, *ent.UserLevelMutation) error

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

func (UserLevelMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type UserLevelQueryRuleFunc

type UserLevelQueryRuleFunc func(context.Context, *ent.UserLevelQuery) error

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

func (UserLevelQueryRuleFunc) EvalQuery

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