Documentation
¶
Overview ¶
Package hooks is middleware to alter the graphql mutation
Index ¶
- Constants
- Variables
- func AddOrDeletePublicStandardTuple(ctx context.Context, m *generated.StandardMutation) (bool, bool, error)
- func AddPostMutationHook[T any](hook func(ctx context.Context, v T) error)
- func Decrypt(encryptedValue string) ([]byte, error)
- func DecryptEntityFields(entity any, fieldNames []string) error
- func DecryptHush(u *generated.Hush) error
- func EmitEventHook(e *Eventer) ent.Hook
- func Encrypt(plaintext []byte) (string, error)
- func GenerateTinkKeyset() (string, error)
- func GetObjectIDFromEntValue(m ent.Value) (string, error)
- func GetObjectIDsFromMutation(ctx context.Context, m utils.GenericMutation, v ent.Value) ([]string, error)
- func GetObjectTypeFromEntMutation(m ent.Mutation) string
- func HookContact() ent.Hook
- func HookControlImplementation() ent.Hook
- func HookControlReferenceFramework() ent.Hook
- func HookCreateAPIToken() ent.Hook
- func HookCreateCustomDomain() ent.Hook
- func HookCreatePersonalAccessToken() ent.Hook
- func HookDeleteCustomDomain() ent.Hook
- func HookDeleteUser() ent.Hook
- func HookEdgePermissions() ent.Hook
- func HookEmailVerificationToken() ent.Hook
- func HookEnableTFA() ent.Hook
- func HookEncryption(fieldNames ...string) ent.Hook
- func HookEntityCreate() ent.Hook
- func HookEvidenceFiles() ent.Hook
- func HookExport() ent.Hook
- func HookFieldEncryption(fieldName string) ent.Hook
- func HookFileDelete() ent.Hook
- func HookGroup() ent.Hook
- func HookGroupAuthz() ent.Hook
- func HookGroupMembers() ent.Hook
- func HookGroupPermissionsTuples() ent.Hook
- func HookGroupSettingVisibility() ent.Hook
- func HookHush() ent.Hook
- func HookInvite() ent.Hook
- func HookInviteAccepted() ent.Hook
- func HookInviteGroups() ent.Hook
- func HookJobResultFiles() ent.Hook
- func HookJobRunnerCreate() ent.Hook
- func HookJobRunnerDelete() ent.Hook
- func HookJobRunnerRegistrationToken() ent.Hook
- func HookJobTemplate() ent.Hook
- func HookManagedGroups() ent.Hook
- func HookMappedControl() ent.Hook
- func HookMembershipSelf(table string) ent.Hook
- func HookNoteFiles() ent.Hook
- func HookObjectOwnedTuples(parents []string, ownerRelation string) ent.Hook
- func HookOnboarding() ent.Hook
- func HookOrgMembers() ent.Hook
- func HookOrgMembersDelete() ent.Hook
- func HookOrgModule() ent.Hook
- func HookOrgModuleUpdate() ent.Hook
- func HookOrganization() ent.Hook
- func HookOrganizationCreatePolicy() ent.Hook
- func HookOrganizationDelete() ent.Hook
- func HookOrganizationUpdatePolicy() ent.Hook
- func HookPasswordResetToken() ent.Hook
- func HookPolicy() ent.Hook
- func HookProcedure() ent.Hook
- func HookProgramAuthz() ent.Hook
- func HookProgramMembers() ent.Hook
- func HookRelationTuples(objects map[string]string, relation fgax.Relation) ent.Hook
- func HookRevisionUpdate() ent.Hook
- func HookScheduledJobCreate() ent.Hook
- func HookStandardCreate() ent.Hook
- func HookStandardDelete() ent.Hook
- func HookStandardPublicAccessTuples() ent.Hook
- func HookSubcontrolCreate() ent.Hook
- func HookSubcontrolUpdate() ent.Hook
- func HookSubprocessor() ent.Hook
- func HookSubscriberCreate() ent.Hook
- func HookSubscriberUpdated() ent.Hook
- func HookSummarizeDetails() ent.Hook
- func HookTaskCreate() ent.Hook
- func HookTaskPermissions() ent.Hook
- func HookTemplate() ent.Hook
- func HookTrustCenter() ent.Hook
- func HookTrustCenterComplianceAuthz() ent.Hook
- func HookTrustCenterSetting() ent.Hook
- func HookTrustCenterSettingAuthz() ent.Hook
- func HookUpdateAPIToken() ent.Hook
- func HookUpdateManagedGroups() ent.Hook
- func HookUpdatePersonalAccessToken() ent.Hook
- func HookUser() ent.Hook
- func HookUserCanViewTuple() ent.Hook
- func HookUserPermissions() ent.Hook
- func HookUserSetting() ent.Hook
- func HookValidateIdentityProviderConfig() ent.Hook
- func HookVerifyTFA() ent.Hook
- func HookWebauthnDelete() ent.Hook
- func IsSchemaExportable(schemaName string) bool
- func IsUniqueConstraintError(err error) bool
- func MetricsHook() ent.Hook
- func OrgOwnedTuplesHook() ent.Hook
- func OrgOwnedTuplesHookWithAdmin() ent.Hook
- func RegisterGlobalHooks(client *entgen.Client, e *Eventer)
- func RegisterListeners(e *Eventer) error
- func SetNewRevision(ctx context.Context, mut MutationWithRevision) error
- func SetSlackConfig(cfg SlackConfig)
- func ValidateExportType(exportType string) error
- func ValidateIdentityProviderConfig(ctx context.Context, m *generated.OrganizationSettingMutation) error
- type AvatarMutation
- type EventID
- type Eventer
- type EventerOpts
- type ManagedContextKey
- type MutationMember
- type MutationWithRevision
- type OrgMember
- type SlackConfig
Constants ¶
const ( // AdminsGroup is the group name for all organization admins and owner, these users have full read and write access in the organization AdminsGroup = "Admins" // ViewersGroup is the group name for all organization members that only have view access in the organization ViewersGroup = "Viewers" // AllMembersGroup is the group name for all members of the organization, no matter their role AllMembersGroup = "All Members" )
Variables ¶
var ( // ErrFieldNotString is returned when a field is not a string type ErrFieldNotString = fmt.Errorf("field is not a string") // ErrSetterNotFound is returned when no setter method is found for a field ErrSetterNotFound = fmt.Errorf("no setter found for field") // ErrCiphertextTooShort is returned when the ciphertext is too short ErrCiphertextTooShort = fmt.Errorf("ciphertext too short") // ErrInvalidKeyLength is returned when the key length is invalid ErrInvalidKeyLength = fmt.Errorf("invalid key length") // ErrFieldNotFound is returned when a field is not found ErrFieldNotFound = fmt.Errorf("field not found") // ErrSetterMethodNotFound is returned when no setter method is found ErrSetterMethodNotFound = fmt.Errorf("setter method not found") )
var ( // ErrInternalServerError is returned when an internal error occurs. ErrInternalServerError = errors.New("internal server error") // ErrInvalidInput is returned when the input is invalid. ErrInvalidInput = errors.New("invalid input") // ErrPersonalOrgsNoChildren is returned when personal org attempts to add a child org ErrPersonalOrgsNoChildren = errors.New("personal organizations are not allowed to have child organizations") // ErrPersonalOrgsNoMembers is returned when personal org attempts to add members ErrPersonalOrgsNoMembers = errors.New("personal organizations are not allowed to have members other than the owner") // ErrOrgOwnerCannotBeDeleted is returned when an org owner is attempted to be deleted ErrOrgOwnerCannotBeDeleted = errors.New("organization owner cannot be deleted, it must be transferred to a new owner first") // ErrPersonalOrgsNoUser is returned when personal org has no user associated, so no permissions can be added ErrPersonalOrgsNoUser = errors.New("personal organizations missing user association") // ErrUserNotInOrg is returned when a user is not a member of an organization when trying to add them to a group ErrUserNotInOrg = errors.New("user not in organization") // ErrUnsupportedFGARole is returned when a role is assigned that is not supported in our fine grained authorization system ErrUnsupportedFGARole = errors.New("unsupported role") // ErrMissingRole is returned when an update request is made that contains no role ErrMissingRole = errors.New("missing role in update") // ErrUserAlreadyOrgMember is returned when an user attempts to be invited to an org they are already a member of ErrUserAlreadyOrgMember = errors.New("user already member of organization") // ErrUserAlreadySubscriber is returned when an user attempts to subscribe to an organization but is already a subscriber ErrUserAlreadySubscriber = errors.New("subscriber already exists") // ErrEmailRequired is returned when an email is required but not provided ErrEmailRequired = errors.New("email is required but not provided") // ErrMaxAttempts is returned when a user has reached the max attempts to resend an invitation to an org ErrMaxAttempts = errors.New("too many attempts to resend org invitation") // ErrMaxSubscriptionAttempts is returned when a user has reached the max attempts to subscribe to an org ErrMaxSubscriptionAttempts = errors.New("too many attempts to resend org subscription email") // ErrMissingRecipientEmail is returned when an email is required but not provided ErrMissingRecipientEmail = errors.New("recipient email is required but not provided") // ErrMissingRequiredName is returned when a name is required but not provided ErrMissingRequiredName = errors.New("name or display name is required but not provided") // ErrTooManyAvatarFiles is returned when a user attempts to upload more than one avatar file ErrTooManyAvatarFiles = errors.New("too many avatar files uploaded, only one is allowed") // ErrFailedToRegisterListener is returned when a listener fails to register ErrFailedToRegisterListener = errors.New("failed to register listener") // ErrNoControls is returned when a subcontrol has no controls assigned ErrNoControls = errors.New("subcontrol must have at least one control assigned") // ErrUnableToCast is returned when a type assertion fails ErrUnableToCast = errors.New("unable to cast") // ErrNoSubscriptions is returned when an organization has no subscriptions ErrNoSubscriptions = errors.New("organization has no subscriptions") // ErrTooManySubscriptions is returned when an organization has too many subscriptions ErrTooManySubscriptions = errors.New("organization has too many subscriptions") // ErrTooManyPrices is returned when an organization has too many subscriptions ErrTooManyPrices = errors.New("organization has too many prices on a subscription") // ErrNoPrices is returned when a subscription has no price ErrNoPrices = errors.New("subscription has no price") // ErrManagedGroup is returned when a user attempts to modify a managed group ErrManagedGroup = errors.New("managed groups cannot be modified") // ErrMaxAttemptsOrganization is returned when the max attempts have been reached to create an organization via onboarding ErrMaxAttemptsOrganization = errors.New("too many attempts to create organization") // ErrEmailDomainNotAllowed is returned when an email domain is not allowed to be used for an organization ErrEmailDomainNotAllowed = errors.New("email domain not allowed in organization") // ErrUserNotFound is returned when a user is not found in the system ErrUserNotFound = errors.New("user not found") // ErrCronRequired is returned when a user does not provide a cron expression ErrCronRequired = errors.New("cron expression must be specified") // ErrZeroTimeNotAllowed is returned when you try to set a non usable time value ErrZeroTimeNotAllowed = errors.New("time cannot be empty. Provide a valid time/date") // ErrFutureTimeNotAllowed is returned when you try to set a time into the future. // future being any second/minute past the current time of validation ErrFutureTimeNotAllowed = errors.New("time cannot be in the future") // ErrFieldRequired is returned when a field is required but not provided ErrFieldRequired = errors.New("field is required but not provided") // ErrOwnerIDNotExists is returned when an owner_id cannot be found ErrOwnerIDNotExists = errors.New("owner_id is required") // ErrArchivedProgramUpdateNotAllowed is returned when an archived program is updated. It only // allows updates if the status is changed ErrArchivedProgramUpdateNotAllowed = errors.New("you cannot update an archived program") // ErrNotSingularUpload is returned when a user is importing content to create a schema // and they upload more than one file ErrNotSingularUpload = errors.New("multiple uploads not supported") // ErrSSONotEnforceable makes sure the connection has been tested before it can be enforced for an org ErrSSONotEnforceable = errors.New("you cannot enforce sso without testing the connection works correctly") )
var ( // ErrPublicStandardCannotBeDeleted defines an error that denotes a public standard cannot be // deleted once made public ErrPublicStandardCannotBeDeleted = errors.New("public standard not allowed to be deleted") )
var ErrTooManyFaviconFiles = errors.New("too many favicon files uploaded, only one is allowed")
var ErrTooManyLogoFiles = errors.New("too many logo files uploaded, only one is allowed")
var ExportableSchemas = map[string]bool{ "CONTROL": true, "EVIDENCE": true, "INTERNAL_POLICY": true, "PROCEDURE": true, "RISK": true, "SUBSCRIBER": true, "TASK": true, }
ExportableSchemas contains all schemas that have Exportable annotation
var OrgSubscriptionCreate = fmt.Sprintf("%s.%s", entgen.TypeOrgSubscription, entgen.OpCreate.String())
var OrganizationCreate = fmt.Sprintf("%s.%s", entgen.TypeOrganization, entgen.OpCreate.String())
var OrganizationDelete = fmt.Sprintf("%s.%s", entgen.TypeOrganization, entgen.OpDelete.String())
var OrganizationDeleteOne = fmt.Sprintf("%s.%s", entgen.TypeOrganization, entgen.OpDeleteOne.String())
var OrganizationSettingUpdateOne = fmt.Sprintf("%s.%s", entgen.TypeOrganizationSetting, entgen.OpUpdateOne.String())
OrganizationSettingCreate and OrganizationSettingUpdateOne are the topics for the organization setting events; formatted as `type.operation`
var SubscriberCreate = fmt.Sprintf("%s.%s", entgen.TypeSubscriber, entgen.OpCreate.String())
Functions ¶
func AddOrDeletePublicStandardTuple ¶ added in v0.8.3
func AddOrDeletePublicStandardTuple(ctx context.Context, m *generated.StandardMutation) (bool, bool, error)
AddOrDeletePublicStandardTuple determines whether to add or delete a standard tuple based on the mutation operation and field values.
Parameters: - ctx: The context for the operation. - m: The StandardMutation containing the mutation details.
Returns: - add: A boolean indicating whether to add the tuple. - delete: A boolean indicating whether to delete the tuple. - err: An error if any occurred during the operation.
The function handles the following mutation operations: - OpCreate: Adds the tuple if both systemOwned and isPublic are true. - OpDelete, OpDeleteOne: Deletes the tuple. - OpUpdateOne: Deletes the tuple if it's a soft delete or if isPublic fields has changed. Adds the tuple if both fields are true. - OpUpdate: Deletes the tuple if isPublic field has been cleared. Adds the tuple if both fields are true.
func AddPostMutationHook ¶ added in v0.5.0
The `AddPostMutationHook` function is used to add a post-mutation hook to the list of runtime hooks. This function takes a hook function as a parameter, which will be executed after a mutation operation is performed. The hook function is expected to take a context and a value of type `T` as input parameters and return an error if any
func DecryptEntityFields ¶ added in v0.24.1
DecryptEntityFields decrypts multiple string fields in an entity using Tink
func DecryptHush ¶ added in v0.24.1
DecryptHush decrypts the secret value in a Hush entity using Tink
func EmitEventHook ¶ added in v0.4.1
EmitEventHook emits an event to the event pool when a mutation is performed
func GenerateTinkKeyset ¶ added in v0.24.1
GenerateTinkKeyset generates a new Tink keyset for initial setup (exported)
func GetObjectIDFromEntValue ¶ added in v0.6.13
GetObjectIDFromEntValue extracts the object id from a generic ent value return type this function should be called after the mutation has been successful
func GetObjectIDsFromMutation ¶ added in v0.7.3
func GetObjectIDsFromMutation(ctx context.Context, m utils.GenericMutation, v ent.Value) ([]string, error)
GetObjectIDsFromMutation gets the object ids from the mutation, if it is a create it will use the ent.Value to get the id, requiring the mutation be executed first For updates, it will use the `IDs()` function to get the IDs by querying the database and returning the entity ids that match the mutation's predicate.
func GetObjectTypeFromEntMutation ¶ added in v0.6.13
GetObjectTypeFromEntMutation gets the object type from the ent mutation
func HookContact ¶ added in v0.6.21
HookContact runs on contact create mutations
func HookControlImplementation ¶ added in v0.8.10
HookControlImplementation sets default values for the control implementation
func HookControlReferenceFramework ¶ added in v0.18.3
HookControlReferenceFramework runs on control mutations to set the reference framework based on the standard's short name
func HookCreateAPIToken ¶
HookCreateAPIToken runs on api token mutations and sets the owner id
func HookCreateCustomDomain ¶ added in v0.15.1
HookCustomDomain runs on create mutations
func HookCreatePersonalAccessToken ¶
HookCreatePersonalAccessToken runs on access token mutations and sets the owner id
func HookDeleteCustomDomain ¶ added in v0.15.1
HookCustomDomain runs on create mutations
func HookDeleteUser ¶
HookDeleteUser runs on user deletions to clean up personal organizations
func HookEdgePermissions ¶ added in v0.26.0
HookEdgePermissions runs on edge mutations to ensure the user has access to the object they are trying to add for edges. It uses the accessmap generated to get the object type and checks if the user has access to it.
func HookEmailVerificationToken ¶
HookEmailVerificationToken runs on email verification mutations and sets expires
func HookEnableTFA ¶
HookEnableTFA is a hook that generates the tfa secrets if the totp setting is set to allowed
func HookEncryption ¶ added in v0.24.1
HookEncryption provides field encryption for multiple fields
func HookEntityCreate ¶
HookEntityCreate runs on entity mutations to set default values that are not provided
func HookEvidenceFiles ¶ added in v0.6.19
HookEvidenceFiles runs on evidence mutations to check for uploaded files
func HookExport ¶ added in v0.22.3
func HookFieldEncryption ¶ added in v0.24.1
HookFieldEncryption provides encryption for existing fields with migration support
func HookFileDelete ¶ added in v0.22.3
HookFileDelete makes sure to clean up the file from external storage once deleted
func HookGroupAuthz ¶
HookGroupAuthz runs on group mutations to setup or remove relationship tuples
func HookGroupMembers ¶
func HookGroupPermissionsTuples ¶ added in v0.6.21
HookGroupPermissionsTuples is a hook that adds group permissions tuples for the object being created this is the reverse edge of the object owned tuples, meaning these run on group mutations whereas the other hooks run on the object mutations
func HookGroupSettingVisibility ¶ added in v0.7.0
HookGroupSettingVisibility is a hook that updates the conditional tuples for group settings based on the visibility setting changing the initial tuple is set up on group creation
func HookInviteAccepted ¶
HookInviteAccepted adds the user to the organization when the status is accepted and any groups specified in the invite
func HookInviteGroups ¶ added in v0.23.3
HookInviteGroups checks the user has access to the groups specified in the invite mutation before allowing the mutation to proceed users must have edit access to the group to be able to add an invite
func HookJobResultFiles ¶ added in v0.30.0
HookJobResultFiles runs on jobresult mutations to check for uploaded files
func HookJobRunnerCreate ¶ added in v0.14.1
HookJobRunnerCreate makes sure there is always a token for the job runner node when a new runner is created
This also deletes the registration token
func HookJobRunnerDelete ¶ added in v0.14.1
HookJobRunnerDelete deletes all token associated with a runner when the runner is deleted
func HookJobRunnerRegistrationToken ¶ added in v0.14.1
HookJobRunnerRegistrationToken auto deletes registration tokens
There can also be only one token available at any given time. - If a new token is generated, delete the existing registration tokens - If a token has been used to successfully register a job runner node, delete it
func HookJobTemplate ¶ added in v0.24.0
HookJobTemplate verifies a scheduled job has a cron and the configuration matches what is expected It also validates the download URL and creates a Windmill flow if configured
func HookManagedGroups ¶ added in v0.6.11
HookManagedGroups runs on group mutations to prevent updates to managed groups
func HookMappedControl ¶ added in v0.32.1
HookMappedControl runs on mapped control create and update mutations
func HookMembershipSelf ¶ added in v0.6.23
HookMembershipSelf is a hook that runs on membership mutations to prevent users from updating their own membership
func HookNoteFiles ¶ added in v0.8.9
HookNoteFiles runs on note mutations to check for uploaded files
func HookObjectOwnedTuples ¶ added in v0.3.4
HookObjectOwnedTuples is a hook that adds object owned tuples for the object being created given a set of parent id fields, it will add the user and parent permissions to the object on creation by default, it will always add a user permission to the object ownerRelation should normally be set to fgax.ParentRelation, but in some cases this is set to owner to account for different inherited permissions from parent objects vs. the user/service owner of the object (see notes as an example)
func HookOnboarding ¶ added in v0.6.24
HookOnboarding runs on onboarding mutations to create the organization and settings
func HookOrgMembers ¶
func HookOrgMembersDelete ¶
HookOrgMembersDelete is a hook that runs during the delete operation of an org membership
func HookOrgModule ¶ added in v0.28.2
HookOrgModule adds the feature tuples to fga as needed
func HookOrgModuleUpdate ¶ added in v0.28.2
HookOrgModuleUpdate updates the feature tuple in fga based off the module status in the database
func HookOrganization ¶
HookOrganization runs on org mutations to set default values that are not provided
func HookOrganizationCreatePolicy ¶ added in v0.7.0
HookOrganizationCreatePolicy is used on organization and organization setting creation mutations if the allowed email domains are set, it will create a conditional tuple that restricts access to the organization based on the email domain
func HookOrganizationDelete ¶
HookOrganizationDelete runs on org delete mutations to ensure the org can be deleted
func HookOrganizationUpdatePolicy ¶ added in v0.7.0
HookOrganizationUpdatePolicy is used on organization setting mutations where the allowed email domains are set in the request it will update the conditional tuple that restricts access to the organization based on the email domain
func HookPasswordResetToken ¶
HookPasswordResetToken runs on reset token mutations and sets expires
func HookPolicy ¶ added in v0.30.6
HookPolicy checks to see if we have an uploaded file. If we do, use that as the details of the procedure. and also use the name of the file
func HookProcedure ¶ added in v0.30.6
HookProcedure checks to see if we have an uploaded file. If we do, use that as the details of the procedure. and also use the name of the file
func HookProgramAuthz ¶ added in v0.3.5
HookProgramAuthz runs on program mutations to setup or remove relationship tuples and prevents updates to archived programs - except if the update contains status changes too
func HookProgramMembers ¶ added in v0.3.5
HookProgramMembers is a hook that ensures that the user is a member of the organization before allowing them to be added to a program TODO (sfunk): can this be generic across all edges with users that are owned by an organization?
func HookRelationTuples ¶ added in v0.4.2
HookRelationTuples is a hook that adds tuples for the object being created the objects input is a map of object id fields to the object type these tuples based are based on the direct relation, e.g. a group#member to another object this is the reverse of the HookGroupPermissionsTuples
func HookRevisionUpdate ¶ added in v0.7.5
HookRevisionUpdate is a hook that runs on update mutations to handle the revision of an object It checks if the revision is set, and if not, it retrieves the current revision from the database and bumps the patch version If the revision is cleared, it sets the revision to the default value
func HookScheduledJobCreate ¶ added in v0.15.0
HookScheduledJobCreate verifies a job that can be attached to a control/subcontrol has a cron and the configuration matches what is expected
func HookStandardCreate ¶ added in v0.8.3
HookStandardCreate sets default values on creation, such as setting the short name to the name if it's not provided
func HookStandardDelete ¶ added in v0.23.9
HookStandardDelete cascades the deletion of all controls for a system-owned standard connected as long as the standard is not public. This is to prevent the deletion of a standard that is actively used by an organization.
func HookStandardPublicAccessTuples ¶ added in v0.7.3
HookStandardPublicAccessTuples adds tuples for publicly available standards based on the system owned and isPublic fields; and deletes them when the fields are cleared. see AddOrDeleteStandardTuple for details on how the fields are checked and it's called functions for specifics on mutation types
func HookSubcontrolCreate ¶ added in v0.8.9
HookSubcontrolCreate sets default values for the subcontrol on creation
func HookSubcontrolUpdate ¶ added in v0.5.0
HookSubcontrolUpdate ensures that there is at least 1 control assigned to the subcontrol
func HookSubprocessor ¶ added in v0.22.3
func HookSubscriberCreate ¶ added in v0.8.4
HookSubscriberCreate runs on subscriber create mutations
func HookSubscriberUpdated ¶ added in v0.8.4
HookSubscriberUpdated runs on subscriber update mutations to set the active status to false if the user is unsubscribed
func HookSummarizeDetails ¶ added in v0.11.0
HookSummarizeDetails summarizes the policy and produces a short human readable copy
func HookTaskCreate ¶ added in v0.3.4
HookTaskCreate runs on task create mutations to set default values that are not provided this will set the assigner to the current user if it is not provided
func HookTaskPermissions ¶ added in v0.7.1
HookTaskPermissions runs on task create and update mutations to add and remove the assignee tuple
func HookTemplate ¶ added in v0.32.1
HookTemplate runs on template create and update mutations
func HookTrustCenter ¶ added in v0.19.0
HookTrustCenter runs on trust center create mutations
func HookTrustCenterComplianceAuthz ¶ added in v0.28.2
HookTrustCenterComplianceAuthz runs on trust center compliance mutations to setup or remove relationship tuples
func HookTrustCenterSetting ¶ added in v0.20.7
func HookTrustCenterSettingAuthz ¶ added in v0.20.7
HookTrustCenterAuthz runs on trust center mutations to setup or remove relationship tuples
func HookUpdateAPIToken ¶
HookUpdateAPIToken runs on api token update and redacts the token
func HookUpdateManagedGroups ¶ added in v0.6.11
HookUpdateManagedGroups runs when org members are added to add the users to the system managed groups
func HookUpdatePersonalAccessToken ¶
HookUpdatePersonalAccessToken runs on access token update and redacts the token
func HookUser ¶
HookUser runs on user mutations validate and hash the password and set default values that are not provided
func HookUserCanViewTuple ¶ added in v0.28.2
HookUserCanViewTuple adds the user#can_view relation for the created object it is agnostic to the object type so it can be used on any schema
func HookUserPermissions ¶ added in v0.3.1
HookUserPermissions runs on user creations to add user _self permissions these are used for parent inherited relations on other objects in the system
func HookUserSetting ¶
HookUserSetting runs on user settings mutations and validates input on update
func HookValidateIdentityProviderConfig ¶ added in v0.22.0
HookValidateIdentityProviderConfig ensures identity provider configuration is present when SSO login is enforced and resets enforced/tested status when SSO configuration fields change
func HookVerifyTFA ¶ added in v0.6.12
HookVerifyTFA is a hook that will generate recovery codes and enable TFA for a user if the TFA has been verified
func HookWebauthnDelete ¶ added in v0.10.10
HookWebauthnDelete runs on passkey delete mutations to ensure that we update the user's settings if needed
func IsSchemaExportable ¶ added in v0.22.3
IsSchemaExportable checks if a schema name is exportable
func IsUniqueConstraintError ¶
IsUniqueConstraintError reports if the error resulted from a DB uniqueness constraint violation. e.g. duplicate value in unique index.
func MetricsHook ¶ added in v0.9.0
MetricsHook inits the collectors with count total at beginning, error on mutation error and a duration after the mutation
func OrgOwnedTuplesHook ¶ added in v0.16.0
OrgOwnedTuplesHook is a hook that adds organization owned tuples for the object being created it will only add the parent organization permissions, and no specific user permissions
func OrgOwnedTuplesHookWithAdmin ¶ added in v0.16.0
OrgOwnedTuplesHookWithAdmin is a hook that adds organization owned tuples for the object being created it will add the user and parent (organization owner_id) permissions to the object on creation, and will also add an admin user permission to the object
func RegisterGlobalHooks ¶ added in v0.4.1
RegisterGlobalHooks registers global event hooks for the entdb client and expects a pointer to an Eventer
func RegisterListeners ¶ added in v0.4.1
RegisterListeners is currently used to globally register what listeners get applied on the entdb client
func SetNewRevision ¶ added in v0.7.5
func SetNewRevision(ctx context.Context, mut MutationWithRevision) error
SetNewRevision sets the new revision for a mutation based on the current revision and the revision bump If the revision is set, it does nothing If the revision is not set, it retrieves the current revision from the database and bumps the version based on the revision bump If there is no revision bump set, it bumps the patch version
func SetSlackConfig ¶ added in v0.18.8
func SetSlackConfig(cfg SlackConfig)
SetSlackConfig sets the Slack configuration for event handlers
func ValidateExportType ¶ added in v0.22.3
ValidateExportType validates that an export type corresponds to an exportable schema
func ValidateIdentityProviderConfig ¶ added in v0.22.0
func ValidateIdentityProviderConfig(ctx context.Context, m *generated.OrganizationSettingMutation) error
ValidateIdentityProviderConfig checks if the identity provider configuration is valid the intent of the function is to ensure all necessary identity provider configuration fields are present and valid when SSO enforcement is being set to active, while also supporting partial updates by falling back to existing values when appropriate
Types ¶
type AvatarMutation ¶ added in v0.6.10
type AvatarMutation interface { SetAvatarLocalFileID(s string) ID() (id string, exists bool) Type() string }
AvatarMutation is an interface for setting the local file ID for an avatar
type EventID ¶ added in v0.4.1
type EventID struct {
ID string `json:"id,omitempty"`
}
EventID is used to marshall and unmarshall the ID out of a ent mutation
type Eventer ¶ added in v0.5.0
Eventer is a wrapper struct for having a soiree as well as a list of listeners
func NewEventer ¶ added in v0.5.0
func NewEventer(opts ...EventerOpts) *Eventer
NewEventer creates a new Eventer with the provided options
func NewEventerPool ¶ added in v0.5.0
func NewEventerPool(client interface{}) *Eventer
NewEventerPool initializes a new Eventer and takes a client to be used as the client for the soiree pool
type EventerOpts ¶ added in v0.5.0
type EventerOpts (func(*Eventer))
EventerOpts is a functional options wrapper
func WithEventerEmitter ¶ added in v0.5.0
func WithEventerEmitter(emitter *soiree.EventPool) EventerOpts
WithEventerEmitter sets the emitter for the Eventer if there's an existing soiree pool that needs to be passed in
func WithEventerListeners ¶ added in v0.5.0
func WithEventerListeners(topic string, listeners []soiree.Listener) EventerOpts
WithEventerListeners takes a single topic and appends an array of listeners to the Eventer
func WithEventerTopics ¶ added in v0.5.0
func WithEventerTopics(topics map[string]any) EventerOpts
WithEventerTopics sets the topics for the Eventer
type ManagedContextKey ¶ added in v0.6.11
type ManagedContextKey struct{}
ManagedContextKey is the context key name for managed group updates
type MutationMember ¶ added in v0.6.23
type MutationMember interface { UserIDs() []string UserID() (string, bool) ID() (string, bool) IDs(ctx context.Context) ([]string, error) Op() ent.Op Client() *generated.Client }
MutationMember is an interface that can be implemented by a member mutation to get IDs
type MutationWithRevision ¶ added in v0.7.5
type MutationWithRevision interface { Revision() (string, bool) RevisionCleared() bool OldRevision(ctx context.Context) (string, error) SetRevision(s string) utils.GenericMutation }
MutationWithRevision is an interface that defines the methods required for a mutation to be able to handle revisions It includes methods for getting and setting the revision
type OrgMember ¶ added in v0.6.11
type OrgMember struct { // UserID is the user ID of the org member UserID string // Role is the role of the org member Role enums.Role // OrgID is the organization ID of the org member OrgID string }
OrgMember is a struct to hold the org member details
type SlackConfig ¶ added in v0.18.8
type SlackConfig struct { WebhookURL string NewSubscriberMessageFile string NewUserMessageFile string }
SlackConfig holds configuration for Slack notifications
Source Files
¶
- apitoken.go
- authzmutationhelpers.go
- avatar.go
- contact.go
- control.go
- controlimplementation.go
- custom_domain.go
- doc.go
- edges.go
- emailverificationtoken.go
- encryption.go
- entity.go
- errors.go
- event.go
- evidence.go
- export.go
- exportable_generated.go
- file.go
- group.go
- groupmembers.go
- groupvisibility.go
- helpers.go
- hush.go
- invite.go
- job.go
- jobresult.go
- managedgroups.go
- mappedcontrol.go
- memberhelpers.go
- metrics.go
- note.go
- objectownedtuples.go
- onboarding.go
- organization.go
- organizationsetting.go
- orgmembers.go
- orgmodule.go
- orgownedtuples.go
- orgsetting_sso.go
- passwordresettoken.go
- personalaccesstoken.go
- policy.go
- procedure.go
- program.go
- programmembers.go
- revision.go
- scheduledjob.go
- sessions.go
- standard.go
- subcontrol.go
- subprocessor.go
- subscriber.go
- summarize.go
- task.go
- template.go
- tfasettings.go
- trustcenter.go
- trustcenter_compliance.go
- trustcentersetting.go
- tuples.go
- user.go
- usersettings.go
- usertuples.go
- webauthn.go