privacy

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT 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 APIKeyMutationRuleFunc

type APIKeyMutationRuleFunc func(context.Context, *ent.APIKeyMutation) error

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

func (APIKeyMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type APIKeyQueryRuleFunc

type APIKeyQueryRuleFunc func(context.Context, *ent.APIKeyQuery) error

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

func (APIKeyQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type AgentMutationRuleFunc added in v0.2.0

type AgentMutationRuleFunc func(context.Context, *ent.AgentMutation) error

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

func (AgentMutationRuleFunc) EvalMutation added in v0.2.0

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

EvalMutation calls f(ctx, m).

type AgentQueryRuleFunc added in v0.2.0

type AgentQueryRuleFunc func(context.Context, *ent.AgentQuery) error

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

func (AgentQueryRuleFunc) EvalQuery added in v0.2.0

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

EvalQuery return f(ctx, q).

type ApplicationMutationRuleFunc added in v0.2.0

type ApplicationMutationRuleFunc func(context.Context, *ent.ApplicationMutation) error

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

func (ApplicationMutationRuleFunc) EvalMutation added in v0.2.0

EvalMutation calls f(ctx, m).

type ApplicationQueryRuleFunc added in v0.2.0

type ApplicationQueryRuleFunc func(context.Context, *ent.ApplicationQuery) error

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

func (ApplicationQueryRuleFunc) EvalQuery added in v0.2.0

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

EvalQuery return f(ctx, q).

type CredentialMutationRuleFunc added in v0.2.0

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

EvalMutation calls f(ctx, m).

type CredentialQueryRuleFunc added in v0.2.0

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

func (f CredentialQueryRuleFunc) 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 HumanMutationRuleFunc added in v0.2.0

type HumanMutationRuleFunc func(context.Context, *ent.HumanMutation) error

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

func (HumanMutationRuleFunc) EvalMutation added in v0.2.0

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

EvalMutation calls f(ctx, m).

type HumanQueryRuleFunc added in v0.2.0

type HumanQueryRuleFunc func(context.Context, *ent.HumanQuery) error

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

func (HumanQueryRuleFunc) EvalQuery added in v0.2.0

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

EvalQuery return f(ctx, q).

type InviteMutationRuleFunc added in v0.2.0

type InviteMutationRuleFunc func(context.Context, *ent.InviteMutation) error

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

func (InviteMutationRuleFunc) EvalMutation added in v0.2.0

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

EvalMutation calls f(ctx, m).

type InviteQueryRuleFunc added in v0.2.0

type InviteQueryRuleFunc func(context.Context, *ent.InviteQuery) error

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

func (InviteQueryRuleFunc) EvalQuery added in v0.2.0

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

EvalQuery return f(ctx, q).

type MembershipMutationRuleFunc

type MembershipMutationRuleFunc func(context.Context, *ent.MembershipMutation) error

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

func (MembershipMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type MembershipQueryRuleFunc

type MembershipQueryRuleFunc func(context.Context, *ent.MembershipQuery) error

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

func (MembershipQueryRuleFunc) EvalQuery

func (f MembershipQueryRuleFunc) 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 = privacy.MutationRuleFunc

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

type OAuthAccountMutationRuleFunc

type OAuthAccountMutationRuleFunc func(context.Context, *ent.OAuthAccountMutation) error

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

func (OAuthAccountMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type OAuthAccountQueryRuleFunc

type OAuthAccountQueryRuleFunc func(context.Context, *ent.OAuthAccountQuery) error

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

func (OAuthAccountQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type OAuthAppMutationRuleFunc

type OAuthAppMutationRuleFunc func(context.Context, *ent.OAuthAppMutation) error

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

func (OAuthAppMutationRuleFunc) EvalMutation

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

EvalMutation calls f(ctx, m).

type OAuthAppQueryRuleFunc

type OAuthAppQueryRuleFunc func(context.Context, *ent.OAuthAppQuery) error

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

func (OAuthAppQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type OAuthAppSecretMutationRuleFunc

type OAuthAppSecretMutationRuleFunc func(context.Context, *ent.OAuthAppSecretMutation) error

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

func (OAuthAppSecretMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type OAuthAppSecretQueryRuleFunc

type OAuthAppSecretQueryRuleFunc func(context.Context, *ent.OAuthAppSecretQuery) error

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

func (OAuthAppSecretQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type OAuthAuthCodeMutationRuleFunc

type OAuthAuthCodeMutationRuleFunc func(context.Context, *ent.OAuthAuthCodeMutation) error

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

func (OAuthAuthCodeMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type OAuthAuthCodeQueryRuleFunc

type OAuthAuthCodeQueryRuleFunc func(context.Context, *ent.OAuthAuthCodeQuery) error

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

func (OAuthAuthCodeQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type OAuthConsentMutationRuleFunc

type OAuthConsentMutationRuleFunc func(context.Context, *ent.OAuthConsentMutation) error

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

func (OAuthConsentMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type OAuthConsentQueryRuleFunc

type OAuthConsentQueryRuleFunc func(context.Context, *ent.OAuthConsentQuery) error

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

func (OAuthConsentQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type OAuthTokenMutationRuleFunc

type OAuthTokenMutationRuleFunc func(context.Context, *ent.OAuthTokenMutation) error

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

func (OAuthTokenMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type OAuthTokenQueryRuleFunc

type OAuthTokenQueryRuleFunc func(context.Context, *ent.OAuthTokenQuery) error

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

func (OAuthTokenQueryRuleFunc) EvalQuery

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

EvalQuery return f(ctx, q).

type OrganizationMutationRuleFunc

type OrganizationMutationRuleFunc func(context.Context, *ent.OrganizationMutation) error

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

func (OrganizationMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type OrganizationQueryRuleFunc

type OrganizationQueryRuleFunc func(context.Context, *ent.OrganizationQuery) error

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

func (OrganizationQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type Policy

type Policy = privacy.Policy

Policy groups query and mutation policies.

type PrincipalMembershipMutationRuleFunc added in v0.2.0

type PrincipalMembershipMutationRuleFunc func(context.Context, *ent.PrincipalMembershipMutation) error

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

func (PrincipalMembershipMutationRuleFunc) EvalMutation added in v0.2.0

EvalMutation calls f(ctx, m).

type PrincipalMembershipQueryRuleFunc added in v0.2.0

type PrincipalMembershipQueryRuleFunc func(context.Context, *ent.PrincipalMembershipQuery) error

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

func (PrincipalMembershipQueryRuleFunc) EvalQuery added in v0.2.0

EvalQuery return f(ctx, q).

type PrincipalMutationRuleFunc added in v0.2.0

type PrincipalMutationRuleFunc func(context.Context, *ent.PrincipalMutation) error

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

func (PrincipalMutationRuleFunc) EvalMutation added in v0.2.0

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

EvalMutation calls f(ctx, m).

type PrincipalQueryRuleFunc added in v0.2.0

type PrincipalQueryRuleFunc func(context.Context, *ent.PrincipalQuery) error

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

func (PrincipalQueryRuleFunc) EvalQuery added in v0.2.0

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

EvalQuery return f(ctx, q).

type PrincipalTokenMutationRuleFunc added in v0.2.0

type PrincipalTokenMutationRuleFunc func(context.Context, *ent.PrincipalTokenMutation) error

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

func (PrincipalTokenMutationRuleFunc) EvalMutation added in v0.2.0

EvalMutation calls f(ctx, m).

type PrincipalTokenQueryRuleFunc added in v0.2.0

type PrincipalTokenQueryRuleFunc func(context.Context, *ent.PrincipalTokenQuery) error

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

func (PrincipalTokenQueryRuleFunc) EvalQuery added in v0.2.0

EvalQuery return f(ctx, q).

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, 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 RefreshTokenMutationRuleFunc

type RefreshTokenMutationRuleFunc func(context.Context, *ent.RefreshTokenMutation) error

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

func (RefreshTokenMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type RefreshTokenQueryRuleFunc

type RefreshTokenQueryRuleFunc func(context.Context, *ent.RefreshTokenQuery) error

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

func (RefreshTokenQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type ServiceAccountKeyPairMutationRuleFunc

type ServiceAccountKeyPairMutationRuleFunc func(context.Context, *ent.ServiceAccountKeyPairMutation) error

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

func (ServiceAccountKeyPairMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type ServiceAccountKeyPairQueryRuleFunc

type ServiceAccountKeyPairQueryRuleFunc func(context.Context, *ent.ServiceAccountKeyPairQuery) error

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

func (ServiceAccountKeyPairQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type ServiceAccountMutationRuleFunc

type ServiceAccountMutationRuleFunc func(context.Context, *ent.ServiceAccountMutation) error

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

func (ServiceAccountMutationRuleFunc) EvalMutation

EvalMutation calls f(ctx, m).

type ServiceAccountQueryRuleFunc

type ServiceAccountQueryRuleFunc func(context.Context, *ent.ServiceAccountQuery) error

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

func (ServiceAccountQueryRuleFunc) EvalQuery

EvalQuery return f(ctx, q).

type ServicePrincipalMutationRuleFunc added in v0.2.0

type ServicePrincipalMutationRuleFunc func(context.Context, *ent.ServicePrincipalMutation) error

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

func (ServicePrincipalMutationRuleFunc) EvalMutation added in v0.2.0

EvalMutation calls f(ctx, m).

type ServicePrincipalQueryRuleFunc added in v0.2.0

type ServicePrincipalQueryRuleFunc func(context.Context, *ent.ServicePrincipalQuery) error

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

func (ServicePrincipalQueryRuleFunc) EvalQuery added in v0.2.0

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