Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add advanced teams / enterprise auth settings (#23418)

Stojan Dimitrovski855a117f5c97
diff --git a/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm/AdvancedAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm/AdvancedAuthSettingsForm.tsx
index 81079e9f98a..abea3607806 100644
--- a/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm/AdvancedAuthSettingsForm.tsx
+++ b/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm/AdvancedAuthSettingsForm.tsx
@@ -22,8 +22,11 @@ import {
FormSectionLabel,
} from 'components/ui/Forms'
import { useAuthConfigQuery } from 'data/auth/auth-config-query'
+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'
-import { useCheckPermissions } from 'hooks'
+import { useCheckPermissions, useSelectedOrganization } from 'hooks'
+import { IS_PLATFORM } from 'lib/constants'
+import UpgradeToPro from 'components/ui/UpgradeToPro'
const schema = object({
JWT_EXP: number()
@@ -35,7 +38,13 @@ const schema = object({
.required('Must have a Reuse Interval value'),
MFA_MAX_ENROLLED_FACTORS: number()
.min(0, 'Must be be a value more than 0')
- .max(30, 'Must be a value less than 30'),
+ .max(30, 'Must be a value no greater than 30'),
+ DB_MAX_POOL_SIZE: number()
+ .min(1, 'Must be 1 or larger')
+ .max(200, 'Must be a value no greater than 200'),
+ API_MAX_REQUEST_DURATION: number()
+ .min(5, 'Must be 5 or larger')
+ .max(30, 'Must be a value no greater than 30'),
})
const AdvancedAuthSettingsForm = () => {
@@ -52,17 +61,33 @@ const AdvancedAuthSettingsForm = () => {
const formId = 'auth-config-advanced-form'
const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue')
+ const organization = useSelectedOrganization()
+ const { data: subscription, isSuccess: isSuccessSubscription } = useOrgSubscriptionQuery({
+ orgSlug: organization?.slug,
+ })
+
+ const isTeamsEnterprisePlan =
+ isSuccessSubscription && subscription.plan.id !== 'free' && subscription.plan.id !== 'pro'
+ const promptTeamsEnterpriseUpgrade = IS_PLATFORM && !isTeamsEnterprisePlan
+
const INITIAL_VALUES = {
SITE_URL: authConfig?.SITE_URL,
JWT_EXP: authConfig?.JWT_EXP,
REFRESH_TOKEN_ROTATION_ENABLED: authConfig?.REFRESH_TOKEN_ROTATION_ENABLED || false,
SECURITY_REFRESH_TOKEN_REUSE_INTERVAL: authConfig?.SECURITY_REFRESH_TOKEN_REUSE_INTERVAL,
MFA_MAX_ENROLLED_FACTORS: authConfig?.MFA_MAX_ENROLLED_FACTORS || 10,
+ DB_MAX_POOL_SIZE: authConfig?.DB_MAX_POOL_SIZE || 10,
+ API_MAX_REQUEST_DURATION: authConfig?.API_MAX_REQUEST_DURATION || 10,
}
const onSubmit = (values: any, { resetForm }: any) => {
const payload = { ...values }
+ if (!isTeamsEnterprisePlan) {
+ delete payload.DB_MAX_POOL_SIZE
+ delete payload.API_MAX_REQUEST_DURATION
+ }
+
updateAuthConfig(
{ projectRef: projectRef!, config: payload },
{
@@ -167,10 +192,59 @@ const AdvancedAuthSettingsForm = () => {
size="small"
label="Maximum number of per-user MFA factors"
descriptionText="How many MFA factors can be enrolled at once per user."
+ actions={<span className="mr-3 text-foreground-lighter">factors</span>}
disabled={!canUpdateConfig}
/>
</FormSectionContent>
</FormSection>
+
+ <FormSection
+ header={<FormSectionLabel>Max Direct Database Connections</FormSectionLabel>}
+ >
+ <FormSectionContent loading={isLoading}>
+ {promptTeamsEnterpriseUpgrade && (
+ <UpgradeToPro
+ primaryText="Upgrade to Teams or Enterprise"
+ secondaryText="Max Direct Database Connections settings are only available on the Teams plan and up."
+ buttonText="Upgrade to Teams"
+ projectRef={projectRef!}
+ organizationSlug={organization!.slug}
+ />
+ )}
+
+ <InputNumber
+ id="DB_MAX_POOL_SIZE"
+ size="small"
+ label="Max direct database connections used by Auth"
+ descriptionText="Auth will take up no more than this number of connections from the total number of available connections to serve requests. These connections are not reserved, so when unused they are released."
+ actions={<span className="mr-3 text-foreground-lighter">connections</span>}
+ disabled={!canUpdateConfig || !isTeamsEnterprisePlan}
+ />
+ </FormSectionContent>
+ </FormSection>
+
+ <FormSection header={<FormSectionLabel>Max Request Duration</FormSectionLabel>}>
+ <FormSectionContent loading={isLoading}>
+ {promptTeamsEnterpriseUpgrade && (
+ <UpgradeToPro
+ primaryText="Upgrade to Teams or Enterprise"
+ secondaryText="Max Request Duration settings are only available on the Teams plan and up."
+ buttonText="Upgrade to Teams"
+ projectRef={projectRef!}
+ organizationSlug={organization!.slug}
+ />
+ )}
+
+ <InputNumber
+ id="API_MAX_REQUEST_DURATION"
+ size="small"
+ label="Maximum time allowed for an Auth request to last"
+ descriptionText="Number of seconds to wait for an Auth request to complete before canceling it. In certain high-load situations setting a larger or smaller value can be used to control load-shedding. Recommended: 10 seconds."
+ actions={<span className="mr-3 text-foreground-lighter">seconds</span>}
+ disabled={!canUpdateConfig || !isTeamsEnterprisePlan}
+ />
+ </FormSectionContent>
+ </FormSection>
</FormPanel>
</>
)
diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.ts
index b338381e479..4181f308eb8 100644
--- a/packages/api-types/types/api.d.ts
+++ b/packages/api-types/types/api.d.ts
@@ -2127,14 +2127,19 @@ export interface components {
SMS_TEST_OTP_VALID_UNTIL: string
HOOK_MFA_VERIFICATION_ATTEMPT_ENABLED: boolean
HOOK_MFA_VERIFICATION_ATTEMPT_URI: string
+ HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS: string
HOOK_PASSWORD_VERIFICATION_ATTEMPT_ENABLED: boolean
HOOK_PASSWORD_VERIFICATION_ATTEMPT_URI: string
+ HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS: string
HOOK_CUSTOM_ACCESS_TOKEN_ENABLED: boolean
HOOK_CUSTOM_ACCESS_TOKEN_URI: string
+ HOOK_CUSTOM_ACCESS_TOKEN_SECRETS: string
HOOK_SEND_SMS_ENABLED: boolean
HOOK_SEND_SMS_URI: string
+ HOOK_SEND_SMS_SECRETS: string
HOOK_SEND_EMAIL_ENABLED: boolean
HOOK_SEND_EMAIL_URI: string
+ HOOK_SEND_EMAIL_SECRETS: string
EXTERNAL_APPLE_ENABLED: boolean
EXTERNAL_APPLE_CLIENT_ID: string
EXTERNAL_APPLE_SECRET: string
@@ -2199,6 +2204,8 @@ export interface components {
EXTERNAL_ZOOM_ENABLED: boolean
EXTERNAL_ZOOM_CLIENT_ID: string
EXTERNAL_ZOOM_SECRET: string
+ DB_MAX_POOL_SIZE: number | null
+ API_MAX_REQUEST_DURATION: number | null
}
UpdateGoTrueConfigBody: {
SITE_URL?: string
@@ -2282,14 +2289,19 @@ export interface components {
SMS_TEMPLATE?: string
HOOK_MFA_VERIFICATION_ATTEMPT_ENABLED?: boolean
HOOK_MFA_VERIFICATION_ATTEMPT_URI?: string
+ HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS?: string
HOOK_PASSWORD_VERIFICATION_ATTEMPT_ENABLED?: boolean
HOOK_PASSWORD_VERIFICATION_ATTEMPT_URI?: string
+ HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS?: string
HOOK_CUSTOM_ACCESS_TOKEN_ENABLED?: boolean
HOOK_CUSTOM_ACCESS_TOKEN_URI?: string
+ HOOK_CUSTOM_ACCESS_TOKEN_SECRETS?: string
HOOK_SEND_SMS_ENABLED?: boolean
HOOK_SEND_SMS_URI?: string
+ HOOK_SEND_SMS_SECRETS?: string
HOOK_SEND_EMAIL_ENABLED?: boolean
HOOK_SEND_EMAIL_URI?: string
+ HOOK_SEND_EMAIL_SECRETS?: string
EXTERNAL_APPLE_ENABLED?: boolean
EXTERNAL_APPLE_CLIENT_ID?: string
EXTERNAL_APPLE_SECRET?: string
@@ -2354,6 +2366,8 @@ export interface components {
EXTERNAL_ZOOM_ENABLED?: boolean
EXTERNAL_ZOOM_CLIENT_ID?: string
EXTERNAL_ZOOM_SECRET?: string
+ DB_MAX_POOL_SIZE?: number
+ API_MAX_REQUEST_DURATION?: number
}
UserBody: {
id?: string
@@ -2679,8 +2693,8 @@ export interface components {
InviteResponse: {
organization_name: string
invite_id: string
- sso_mismatch: boolean
token_does_not_exist: boolean
+ sso_mismatch: boolean
email_match: boolean
authorized_user: boolean
expired_token: boolean
@@ -5138,6 +5152,8 @@ export interface components {
connection_string?: string
}
AuthConfigResponse: {
+ api_max_request_duration: number | null
+ db_max_pool_size: number | null
disable_signup: boolean | null
external_anonymous_users_enabled: boolean | null
external_apple_additional_client_ids: string | null
@@ -5208,10 +5224,19 @@ export interface components {
external_zoom_secret: string | null
hook_custom_access_token_enabled: boolean | null
hook_custom_access_token_uri: string | null
+ hook_custom_access_token_secrets: string | null
hook_mfa_verification_attempt_enabled: boolean | null
hook_mfa_verification_attempt_uri: string | null
+ hook_mfa_verification_attempt_secrets: string | null
hook_password_verification_attempt_enabled: boolean | null
hook_password_verification_attempt_uri: string | null
+ hook_password_verification_attempt_secrets: string | null
+ hook_send_sms_enabled: boolean | null
+ hook_send_sms_uri: string | null
+ hook_send_sms_secrets: string | null
+ hook_send_email_enabled: boolean | null
+ hook_send_email_uri: string | null
+ hook_send_email_secrets: string | null
jwt_exp: number | null
mailer_allow_unverified_email_sign_ins: boolean | null
mailer_autoconfirm: boolean | null
@@ -5222,14 +5247,14 @@ export interface components {
mailer_subjects_email_change: string | null
mailer_subjects_invite: string | null
mailer_subjects_magic_link: string | null
- mailer_subjects_recovery: string | null
mailer_subjects_reauthentication: string | null
+ mailer_subjects_recovery: string | null
mailer_templates_confirmation_content: string | null
mailer_templates_email_change_content: string | null
mailer_templates_invite_content: string | null
mailer_templates_magic_link_content: string | null
- mailer_templates_recovery_content: string | null
mailer_templates_reauthentication_content: string | null
+ mailer_templates_recovery_content: string | null
mfa_max_enrolled_factors: number | null
password_hibp_enabled: boolean | null
password_min_length: number | null
@@ -5365,14 +5390,19 @@ export interface components {
sms_template?: string
hook_mfa_verification_attempt_enabled?: boolean
hook_mfa_verification_attempt_uri?: string
+ hook_mfa_verification_attempt_secrets?: string
hook_password_verification_attempt_enabled?: boolean
hook_password_verification_attempt_uri?: string
+ hook_password_verification_attempt_secrets?: string
hook_custom_access_token_enabled?: boolean
hook_custom_access_token_uri?: string
+ hook_custom_access_token_secrets?: string
hook_send_sms_enabled?: boolean
hook_send_sms_uri?: string
+ hook_send_sms_secrets?: string
hook_send_email_enabled?: boolean
hook_send_email_uri?: string
+ hook_send_email_secrets?: string
external_apple_enabled?: boolean
external_apple_client_id?: string
external_apple_secret?: string
@@ -5437,6 +5467,8 @@ export interface components {
external_zoom_enabled?: boolean
external_zoom_client_id?: string
external_zoom_secret?: string
+ db_max_pool_size?: number
+ api_max_request_duration?: number
}
CreateThirdPartyAuthBody: {
oidc_issuer_url?: string
@@ -9623,6 +9655,7 @@ export interface operations {
startDate: string
endDate: string
interval?: '1m' | '5m' | '10m' | '30m' | '1h' | '1d'
+ databaseIdentifier?: string
}
path: {
/** @description Project ref */