privacy

package
v0.0.0-...-34fc03e Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: AGPL-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 allow decision.
	Allow = privacy.Allow

	// Deny may be returned by rules to indicate that the policy
	// evaluation should terminate with 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 ActorMutationRuleFunc

type ActorMutationRuleFunc func(context.Context, *ent.ActorMutation) error

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

func (ActorMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type ActorQueryRuleFunc

type ActorQueryRuleFunc func(context.Context, *ent.ActorQuery) error

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

func (ActorQueryRuleFunc) EvalQuery

func (f ActorQueryRuleFunc) 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 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 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 = privacy.Policy

Policy groups query and mutation policies.

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 ReactionMutationRuleFunc

type ReactionMutationRuleFunc func(context.Context, *ent.ReactionMutation) error

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

func (ReactionMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type ReactionQueryRuleFunc

type ReactionQueryRuleFunc func(context.Context, *ent.ReactionQuery) error

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

func (ReactionQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type ServerMutationRuleFunc

type ServerMutationRuleFunc func(context.Context, *ent.ServerMutation) error

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

func (ServerMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type ServerQueryRuleFunc

type ServerQueryRuleFunc func(context.Context, *ent.ServerQuery) error

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

func (ServerQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type SessionMutationRuleFunc

type SessionMutationRuleFunc func(context.Context, *ent.SessionMutation) error

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

func (SessionMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type SessionQueryRuleFunc

type SessionQueryRuleFunc func(context.Context, *ent.SessionQuery) error

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

func (SessionQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type StatusMutationRuleFunc

type StatusMutationRuleFunc func(context.Context, *ent.StatusMutation) error

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

func (StatusMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type StatusQueryRuleFunc

type StatusQueryRuleFunc func(context.Context, *ent.StatusQuery) error

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

func (StatusQueryRuleFunc) EvalQuery

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