privacy

package
v0.0.0-...-1ac7f0e Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 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 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 a 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 a formatted wrapped Deny decision.

func Skipf

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

Skipf returns a formatted wrapped Skip decision.

Types

type AuthenticationMutationRuleFunc

type AuthenticationMutationRuleFunc func(context.Context, *data.AuthenticationMutation) error

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

func (AuthenticationMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type AuthenticationQueryRuleFunc

type AuthenticationQueryRuleFunc func(context.Context, *data.AuthenticationQuery) error

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

func (AuthenticationQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type AuthorizationMutationRuleFunc

type AuthorizationMutationRuleFunc func(context.Context, *data.AuthorizationMutation) error

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

func (AuthorizationMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type AuthorizationQueryRuleFunc

type AuthorizationQueryRuleFunc func(context.Context, *data.AuthorizationQuery) error

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

func (AuthorizationQueryRuleFunc) EvalQuery

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 data.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 data.Query) error

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

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 data.Op) MutationRule

DenyMutationOperationRule returns a rule denying specified mutation operation.

func OnMutationOperation

func OnMutationOperation(rule MutationRule, op data.Op) MutationRule

OnMutationOperation evaluates the given rule only on a given mutation operation.

type MutationRuleFunc

type MutationRuleFunc = privacy.MutationRuleFunc

MutationRuleFunc type is an adapter which allows the use of ordinary functions as mutation rules.

type PersonMutationRuleFunc

type PersonMutationRuleFunc func(context.Context, *data.PersonMutation) error

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

func (PersonMutationRuleFunc) EvalMutation

func (f PersonMutationRuleFunc) EvalMutation(ctx context.Context, m data.Mutation) error

EvalMutation calls f(ctx, m).

type PersonQueryRuleFunc

type PersonQueryRuleFunc func(context.Context, *data.PersonQuery) error

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

func (PersonQueryRuleFunc) EvalQuery

func (f PersonQueryRuleFunc) EvalQuery(ctx context.Context, q data.Query) error

EvalQuery return f(ctx, q).

type Policy

type Policy = privacy.Policy

Policy groups query and mutation policies.

type QueryMutationRule

type QueryMutationRule = privacy.QueryMutationRule

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, data.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 data.Query) error

Eval returns f(ctx, q).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL