interceptors

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package interceptors is middleware to alter the graphql query

Index

Constants

This section is empty.

Variables

View Source
var (
	// ExistOperation is the operation type for Exist queries
	ExistOperation = "Exist"
	// IDsOperation is the operation type for IDs queries
	IDsOperation = "IDs"
)
View Source
var (
	// ErrInternalServerError is returned when an internal error occurs.
	ErrInternalServerError = errors.New("internal server error")

	// ErrUnableToRetrieveUserID is returned when the user cannot be retrieved from the context
	ErrUnableToRetrieveUserID = errors.New("unable to retrieve user from context")

	// ErrRetrievingObjects is returned when an error occurs while retrieving objects
	ErrRetrievingObjects = errors.New("error retrieving objects")
)

Functions

func AddIDPredicate added in v0.3.1

func AddIDPredicate(ctx context.Context, q intercept.Query) error

AddIDPredicate adds a predicate to the query to only include the objects that the user has access to This is generally used by object owned setups with the ObjectOwnedMixin

func FilterListQuery added in v0.3.1

func FilterListQuery() ent.Interceptor

FilterListQuery filters any list query to only include the objects that the user has access to

func GetAuthorizedObjectIDs added in v0.3.1

func GetAuthorizedObjectIDs(ctx context.Context, objectType string) ([]string, error)

GetAuthorizedObjectIDs does a list objects request to pull all ids the current user has access to within the FGA system

func HistoryAccess

func HistoryAccess(relation string, orgOwned, userOwed bool) ent.Interceptor

HistoryAccess is a traversal interceptor that checks if the user has the required role for the organization

func InterceptorAPIToken

func InterceptorAPIToken() ent.Interceptor

InterceptorAPIToken is middleware to change the api token query

func InterceptorGroup

func InterceptorGroup() ent.Interceptor

InterceptorGroup is middleware to change the Group query

func InterceptorHush

func InterceptorHush() ent.Interceptor

InterceptorHush keeps it secret, keeps it safe

func InterceptorOrgMember

func InterceptorOrgMember() ent.Interceptor

InterceptorOrgMember is middleware to change the OrgMember query result

func InterceptorOrganization

func InterceptorOrganization() ent.Interceptor

InterceptorOrganization is middleware to change the Organization query

func InterceptorOrganizationSetting

func InterceptorOrganizationSetting() ent.Interceptor

InterceptorOrganizationSetting is middleware to change the org setting query

func InterceptorPat

func InterceptorPat() ent.Interceptor

InterceptorPat is middleware to change the PAT query

func InterceptorUserSetting

func InterceptorUserSetting() ent.Interceptor

func QueryLogger

func QueryLogger() ent.InterceptFunc

func TraverseOrgMembers

func TraverseOrgMembers() ent.Interceptor

TraverseOrgMembers is middleware to change the Org Members query

func TraverseUser

func TraverseUser() ent.Interceptor

TraverseUser returns an ent interceptor for user that filters users based on the context of the query

Types

type SkipMode

type SkipMode int

SkipMode is a bit flag for the Skip annotation.

const (
	// SkipOnlyQuery skips the interceptor on `Only` queries.
	SkipOnlyQuery SkipMode = 1 << iota
	// SkipAllQuery skips the interceptor on `All` queries.
	SkipAllQuery
	// SkipExistsQuery skips the interceptor on `Exists` queries.
	SkipExistsQuery

	// SkipAll is default mode to skip all.
	SkipAll = SkipOnlyQuery |
		SkipAllQuery |
		SkipExistsQuery
)

Jump to

Keyboard shortcuts

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