privacy

package
v0.11.10 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 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 ...any) 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 ...any) error

Denyf returns an formatted wrapped Deny decision.

func Skipf

func Skipf(format string, a ...any) error

Skipf returns an formatted wrapped Skip decision.

Types

type AttachedFileMutationRuleFunc added in v0.11.8

type AttachedFileMutationRuleFunc func(context.Context, *ent.AttachedFileMutation) error

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

func (AttachedFileMutationRuleFunc) EvalMutation added in v0.11.8

EvalMutation calls f(ctx, m).

type AttachedFileQueryRuleFunc added in v0.11.8

type AttachedFileQueryRuleFunc func(context.Context, *ent.AttachedFileQuery) error

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

func (AttachedFileQueryRuleFunc) EvalQuery added in v0.11.8

EvalQuery return f(ctx, q).

type FileMutationRuleFunc added in v0.11.8

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 added in v0.11.8

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

EvalMutation calls f(ctx, m).

type FileQueryRuleFunc added in v0.11.8

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 added in v0.11.8

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

EvalQuery return f(ctx, q).

type Filter added in v0.11.2

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 added in v0.11.2

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 added in v0.11.2

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 added in v0.11.2

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 FriendshipMutationRuleFunc

type FriendshipMutationRuleFunc func(context.Context, *ent.FriendshipMutation) error

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

func (FriendshipMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type FriendshipQueryRuleFunc

type FriendshipQueryRuleFunc func(context.Context, *ent.FriendshipQuery) error

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

func (FriendshipQueryRuleFunc) EvalQuery

func (f FriendshipQueryRuleFunc) 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 GroupTagMutationRuleFunc added in v0.11.5

type GroupTagMutationRuleFunc func(context.Context, *ent.GroupTagMutation) error

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

func (GroupTagMutationRuleFunc) EvalMutation added in v0.11.5

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

EvalMutation calls f(ctx, m).

type GroupTagQueryRuleFunc added in v0.11.5

type GroupTagQueryRuleFunc func(context.Context, *ent.GroupTagQuery) error

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

func (GroupTagQueryRuleFunc) EvalQuery added in v0.11.5

func (f GroupTagQueryRuleFunc) 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 ProcessMutationRuleFunc added in v0.11.8

type ProcessMutationRuleFunc func(context.Context, *ent.ProcessMutation) error

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

func (ProcessMutationRuleFunc) EvalMutation added in v0.11.8

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

EvalMutation calls f(ctx, m).

type ProcessQueryRuleFunc added in v0.11.8

type ProcessQueryRuleFunc func(context.Context, *ent.ProcessQuery) error

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

func (ProcessQueryRuleFunc) EvalQuery added in v0.11.8

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

EvalQuery return f(ctx, q).

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 RelationshipInfoMutationRuleFunc

type RelationshipInfoMutationRuleFunc func(context.Context, *ent.RelationshipInfoMutation) error

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

func (RelationshipInfoMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type RelationshipInfoQueryRuleFunc

type RelationshipInfoQueryRuleFunc func(context.Context, *ent.RelationshipInfoQuery) error

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

func (RelationshipInfoQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type RelationshipMutationRuleFunc

type RelationshipMutationRuleFunc func(context.Context, *ent.RelationshipMutation) error

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

func (RelationshipMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type RelationshipQueryRuleFunc

type RelationshipQueryRuleFunc func(context.Context, *ent.RelationshipQuery) error

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

func (RelationshipQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type RoleMutationRuleFunc added in v0.11.1

type RoleMutationRuleFunc func(context.Context, *ent.RoleMutation) error

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

func (RoleMutationRuleFunc) EvalMutation added in v0.11.1

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

EvalMutation calls f(ctx, m).

type RoleQueryRuleFunc added in v0.11.1

type RoleQueryRuleFunc func(context.Context, *ent.RoleQuery) error

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

func (RoleQueryRuleFunc) EvalQuery added in v0.11.1

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

EvalQuery return f(ctx, q).

type RoleUserMutationRuleFunc added in v0.11.1

type RoleUserMutationRuleFunc func(context.Context, *ent.RoleUserMutation) error

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

func (RoleUserMutationRuleFunc) EvalMutation added in v0.11.1

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

EvalMutation calls f(ctx, m).

type RoleUserQueryRuleFunc added in v0.11.1

type RoleUserQueryRuleFunc func(context.Context, *ent.RoleUserQuery) error

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

func (RoleUserQueryRuleFunc) EvalQuery added in v0.11.1

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

EvalQuery return 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).

type TweetLikeMutationRuleFunc

type TweetLikeMutationRuleFunc func(context.Context, *ent.TweetLikeMutation) error

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

func (TweetLikeMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type TweetLikeQueryRuleFunc

type TweetLikeQueryRuleFunc func(context.Context, *ent.TweetLikeQuery) error

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

func (TweetLikeQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type TweetMutationRuleFunc

type TweetMutationRuleFunc func(context.Context, *ent.TweetMutation) error

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

func (TweetMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type TweetQueryRuleFunc

type TweetQueryRuleFunc func(context.Context, *ent.TweetQuery) error

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

func (TweetQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type TweetTagMutationRuleFunc

type TweetTagMutationRuleFunc func(context.Context, *ent.TweetTagMutation) error

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

func (TweetTagMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type TweetTagQueryRuleFunc

type TweetTagQueryRuleFunc func(context.Context, *ent.TweetTagQuery) error

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

func (TweetTagQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type UserGroupMutationRuleFunc

type UserGroupMutationRuleFunc func(context.Context, *ent.UserGroupMutation) error

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

func (UserGroupMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type UserGroupQueryRuleFunc

type UserGroupQueryRuleFunc func(context.Context, *ent.UserGroupQuery) error

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

func (UserGroupQueryRuleFunc) EvalQuery

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

type UserTweetMutationRuleFunc

type UserTweetMutationRuleFunc func(context.Context, *ent.UserTweetMutation) error

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

func (UserTweetMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type UserTweetQueryRuleFunc

type UserTweetQueryRuleFunc func(context.Context, *ent.UserTweetQuery) error

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

func (UserTweetQueryRuleFunc) EvalQuery

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