Skip to content

Blocking hooks

A blocking hook asks your server before something happens, and waits for the answer. You can add them under Hooks on the Paid plan.

Event Runs before What it can change
user.pre_create A new account is created The user’s attributes, roles and groups
user.profile.pre_update A profile change is saved The user’s attributes, roles and groups
authentication.pre_authenticated Someone is signed in It can require two-step verification
oidc.jwt.pre_create An access token is issued The token’s claims
oidc.id_token.pre_create An ID token is issued The token’s claims
user.pre_schedule_deletion An account is scheduled for deletion Nothing; it can only allow or refuse
user.pre_schedule_anonymization An account is scheduled for anonymisation Nothing; it can only allow or refuse

Requests to your server are signed in the same way as webhooks. Your server answers with JSON, for example:

{ "is_allowed": true }
{ "is_allowed": false, "title": "Not yet", "reason": "Your company has not finished signing up." }
{ "is_allowed": true, "mutations": { "user": { "roles": ["customer"] } } }
{ "is_allowed": true, "constraints": { "amr": ["mfa"] } }

If you add several hooks for the same event, they run in order, and each one sees any changes made by the hooks before it. Changes to a user’s profile are checked against your attribute rules, just like any other change.

A hook can’t change the token claims that security depends on, such as iss, sub, aud, exp, scope, roles, amr and cnf. Those keep their original values whatever the hook returns.

Each hook has 5 seconds to answer by default, and all of the hooks for one event have 10 seconds between them. If a hook doesn’t answer in time, returns an error, or returns something that can’t be read, the action is refused. That way, a slow or broken server can never be a way around a hook that guards sign-in.

If you need logic in the middle of a sign-in, the Call your API step in a sign-in flow can also show forms before or after the call, and take different paths depending on the answer.