mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 14:19:11 +03:00
* feat: add documentation and UI integration for Before User Created hook - Added new guide: `before-user-created-hook.mdx`, documenting usage, inputs, outputs, and multiple complete examples for HTTP and SQL. - Updated navigation menu and hook index table to include the new hook. - Hook is now listed as available on Free and Pro plans. Studio changes: - Registered `Before User Created` hook in `hooks.constants.ts` with proper title, slug, and configuration keys. - Enabled Docs button linking to hook guide in both `CreateHookSheet` and `HookCard` components. - Extended hook listing page to support docs access via `secondaryActions`. This hook allows developers to intercept and reject user creation across all flows (email/password, OAuth, SSO, SAML, anonymous) - enabling custom signup logic like domain allowlists, geofencing, or account gating. * fix: add subnet to mdx lint allowed list * fix: incorporate feedback and spelling changes * feat: add allow/deny domain and CIDR examples to before-user-created hook This commit enhances the documentation for the before-user-created auth hook: - Adds production-ready SQL examples for blocking or allowing signups by email domain (signup_email_domains) and IP address or CIDR (signup_networks) - Introduces enum-based classification (allow vs deny) for both domain and network restrictions - Adds full migration-style snippets for easy copy/paste into Supabase SQL Editor - Includes updated HTTP examples that delegate to Postgres functions via Supabase client rpc() - Adds environment setup guidance and edge function scaffolding * fix: pnpm format --------- Co-authored-by: Chris Stockton <chris.stockton@supabase.io>
77 lines
2.8 KiB
TypeScript
77 lines
2.8 KiB
TypeScript
export const HOOKS_DEFINITIONS = [
|
|
{
|
|
title: 'Send SMS hook',
|
|
subtitle: 'Will be called by Supabase Auth each time an SMS message needs to be sent.',
|
|
enabledKey: 'HOOK_SEND_SMS_ENABLED',
|
|
uriKey: 'HOOK_SEND_SMS_URI',
|
|
secretsKey: 'HOOK_SEND_SMS_SECRETS',
|
|
enterprise: false,
|
|
docSlug: 'send-sms-hook',
|
|
},
|
|
{
|
|
title: 'Send Email hook',
|
|
subtitle: 'Will be called by Supabase Auth each time an email message needs to be sent.',
|
|
enabledKey: 'HOOK_SEND_EMAIL_ENABLED',
|
|
uriKey: 'HOOK_SEND_EMAIL_URI',
|
|
secretsKey: 'HOOK_SEND_EMAIL_SECRETS',
|
|
enterprise: false,
|
|
docSlug: 'send-email-hook',
|
|
},
|
|
{
|
|
title: 'Customize Access Token (JWT) Claims hook',
|
|
subtitle:
|
|
'Will be called by Supabase Auth each time a new JWT is created. It should return the claims you wish to be present in the JWT.',
|
|
enabledKey: 'HOOK_CUSTOM_ACCESS_TOKEN_ENABLED',
|
|
uriKey: 'HOOK_CUSTOM_ACCESS_TOKEN_URI',
|
|
secretsKey: 'HOOK_CUSTOM_ACCESS_TOKEN_SECRETS',
|
|
enterprise: false,
|
|
docSlug: 'custom-access-token-hook',
|
|
},
|
|
{
|
|
title: 'MFA Verification Attempt hook',
|
|
subtitle:
|
|
'Will be called by Supabase Auth each time a user tries to verify an MFA factor. Return a decision on whether to reject the attempt and future ones, or to allow the user to keep trying.',
|
|
enabledKey: 'HOOK_MFA_VERIFICATION_ATTEMPT_ENABLED',
|
|
uriKey: 'HOOK_MFA_VERIFICATION_ATTEMPT_URI',
|
|
secretsKey: 'HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS',
|
|
enterprise: true,
|
|
docSlug: 'mfa-verification-hook',
|
|
},
|
|
{
|
|
title: 'Password Verification Attempt hook',
|
|
subtitle:
|
|
'Will be called by Supabase Auth each time a user tries to sign in with a password. Return a decision whether to allow the user to reject the attempt, or to allow the user to keep trying.',
|
|
enabledKey: 'HOOK_PASSWORD_VERIFICATION_ATTEMPT_ENABLED',
|
|
uriKey: 'HOOK_PASSWORD_VERIFICATION_ATTEMPT_URI',
|
|
secretsKey: 'HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS',
|
|
enterprise: true,
|
|
docSlug: 'password-verification-hook',
|
|
},
|
|
{
|
|
title: 'Before User Created hook',
|
|
subtitle:
|
|
'Will be called by Supabase Auth before creating a new user. Returning an error will prevent the user from being created.',
|
|
enabledKey: 'HOOK_BEFORE_USER_CREATED_ENABLED',
|
|
uriKey: 'HOOK_BEFORE_USER_CREATED_URI',
|
|
secretsKey: 'HOOK_BEFORE_USER_CREATED_SECRETS',
|
|
enterprise: false,
|
|
docSlug: 'before-user-created-hook',
|
|
},
|
|
] as const
|
|
|
|
export type HOOK_DEFINITION_TITLE = (typeof HOOKS_DEFINITIONS)[number]['title']
|
|
|
|
export interface Hook {
|
|
title: HOOK_DEFINITION_TITLE
|
|
subtitle: string
|
|
enabled: boolean
|
|
enabledKey: string
|
|
uriKey: string
|
|
secretsKey: string
|
|
docSlug: string
|
|
method:
|
|
| { type: 'postgres'; schema: string; functionName: string }
|
|
| { type: 'https'; url: string; secret: string }
|
|
enterprise: boolean
|
|
}
|