Documentation
¶
Overview ¶
Package interceptors is middleware to alter the graphql query
Index ¶
- Constants
- Variables
- func AddIDPredicate(ctx context.Context, q intercept.Query) error
- func FilterListQuery() ent.Interceptor
- func GetAuthorizedObjectIDs(ctx context.Context, queryType string) ([]string, error)
- func HistoryAccess(relation string, orgOwned, userOwed bool, objectOwner string) ent.Interceptor
- func InterceptorAPIToken() ent.Interceptor
- func InterceptorGroupSetting() ent.Interceptor
- func InterceptorHush() ent.Interceptor
- func InterceptorOrgMember() ent.Interceptor
- func InterceptorOrganization() ent.Interceptor
- func InterceptorOrganizationSetting() ent.Interceptor
- func InterceptorPat() ent.Interceptor
- func InterceptorPresignedURL() ent.Interceptor
- func InterceptorSubscriptionURL() ent.Interceptor
- func InterceptorUserSetting() ent.Interceptor
- func QueryLogger() ent.InterceptFunc
- func TraverseOrgMembers() ent.Interceptor
- func TraverseUser() ent.Interceptor
- type SkipMode
Constants ¶
const ( // ExistOperation is the operation type for Exist queries ExistOperation = "Exist" // OnlyOperation is the operation type for Only queries OnlyOperation = "Only" // IDsOperation is the operation type for IDs queries IDsOperation = "IDs" )
Operation types for queries
Variables ¶
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
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 This is automatically added to all schemas using the ObjectOwnedMixin, so should not be added directly if that mixin is used
func GetAuthorizedObjectIDs ¶ added in v0.3.1
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, objectOwner string) 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 InterceptorGroupSetting ¶ added in v0.7.0
func InterceptorGroupSetting() ent.Interceptor
InterceptorGroupSetting is middleware to change the GroupSetting query to only include the objects that the user has access to by filtering the group settings with groups from the authorized organization only
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 InterceptorPresignedURL ¶ added in v0.6.10
func InterceptorPresignedURL() ent.Interceptor
InterceptorPresignedURL is an ent interceptor that sets the presignedURL field on the file query if the field is requested
func InterceptorSubscriptionURL ¶ added in v0.6.6
func InterceptorSubscriptionURL() ent.Interceptor
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 )