privacy

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 5 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 AccountMutationRuleFunc

type AccountMutationRuleFunc func(context.Context, *ent.AccountMutation) error

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

func (AccountMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type AccountQueryRuleFunc

type AccountQueryRuleFunc func(context.Context, *ent.AccountQuery) error

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

func (AccountQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type BlobLinkMutationRuleFunc

type BlobLinkMutationRuleFunc func(context.Context, *ent.BlobLinkMutation) error

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

func (BlobLinkMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type BlobLinkQueryRuleFunc

type BlobLinkQueryRuleFunc func(context.Context, *ent.BlobLinkQuery) error

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

func (BlobLinkQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type BlobMutationRuleFunc

type BlobMutationRuleFunc func(context.Context, *ent.BlobMutation) error

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

func (BlobMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type BlobQueryRuleFunc

type BlobQueryRuleFunc func(context.Context, *ent.BlobQuery) error

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

func (BlobQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type CarMutationRuleFunc

type CarMutationRuleFunc func(context.Context, *ent.CarMutation) error

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

func (CarMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type CarQueryRuleFunc

type CarQueryRuleFunc func(context.Context, *ent.CarQuery) error

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

func (CarQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type DeviceMutationRuleFunc

type DeviceMutationRuleFunc func(context.Context, *ent.DeviceMutation) error

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

func (DeviceMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type DeviceQueryRuleFunc

type DeviceQueryRuleFunc func(context.Context, *ent.DeviceQuery) error

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

func (DeviceQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type DocMutationRuleFunc

type DocMutationRuleFunc func(context.Context, *ent.DocMutation) error

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

func (DocMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type DocQueryRuleFunc

type DocQueryRuleFunc func(context.Context, *ent.DocQuery) error

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

func (DocQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type Filter

type Filter interface {
	// Where applies a filter on the executed query/mutation.
	Where(entql.P)
}

Filter is the interface that wraps the Where function for filtering nodes in queries and mutations.

type FilterFunc

type FilterFunc func(context.Context, Filter) error

The FilterFunc type is an adapter that allows the use of ordinary functions as filters for query and mutation types.

func (FilterFunc) EvalMutation

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

EvalMutation calls f(ctx, q) if the mutation implements the Filter interface, otherwise it is denied.

func (FilterFunc) EvalQuery

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

EvalQuery calls f(ctx, q) if the query implements the Filter interface, otherwise it is denied.

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 IntSIDMutationRuleFunc

type IntSIDMutationRuleFunc func(context.Context, *ent.IntSIDMutation) error

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

func (IntSIDMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type IntSIDQueryRuleFunc

type IntSIDQueryRuleFunc func(context.Context, *ent.IntSIDQuery) error

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

func (IntSIDQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type MixinIDMutationRuleFunc

type MixinIDMutationRuleFunc func(context.Context, *ent.MixinIDMutation) error

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

func (MixinIDMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type MixinIDQueryRuleFunc

type MixinIDQueryRuleFunc func(context.Context, *ent.MixinIDQuery) error

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

func (MixinIDQueryRuleFunc) EvalQuery

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

type NoteMutationRuleFunc func(context.Context, *ent.NoteMutation) error

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

func (NoteMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type NoteQueryRuleFunc

type NoteQueryRuleFunc func(context.Context, *ent.NoteQuery) error

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

func (NoteQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type OtherMutationRuleFunc

type OtherMutationRuleFunc func(context.Context, *ent.OtherMutation) error

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

func (OtherMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type OtherQueryRuleFunc

type OtherQueryRuleFunc func(context.Context, *ent.OtherQuery) error

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

func (OtherQueryRuleFunc) EvalQuery

func (f OtherQueryRuleFunc) 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 = 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 RevisionMutationRuleFunc

type RevisionMutationRuleFunc func(context.Context, *ent.RevisionMutation) error

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

func (RevisionMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type RevisionQueryRuleFunc

type RevisionQueryRuleFunc func(context.Context, *ent.RevisionQuery) error

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

func (RevisionQueryRuleFunc) EvalQuery

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

type TokenMutationRuleFunc func(context.Context, *ent.TokenMutation) error

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

func (TokenMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type TokenQueryRuleFunc

type TokenQueryRuleFunc func(context.Context, *ent.TokenQuery) error

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

func (TokenQueryRuleFunc) EvalQuery

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