The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Move authentication settings (#33335)
Saxon Fletcherd4e9ea0b315c
diff --git a/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm/AdvancedAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm/AdvancedAuthSettingsForm.tsxindex 1cd50cd0cbb..44a2ef5f487 100644--- a/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm/AdvancedAuthSettingsForm.tsx+++ b/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm/AdvancedAuthSettingsForm.tsx@@ -1,7 +1,6 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-import { useEffect } from 'react'import { toast } from 'sonner'-import { boolean, number, object, string } from 'yup'+import { number, object } from 'yup'import { useParams } from 'common'import { FormActions } from 'components/ui/Forms/FormActions'@@ -16,7 +15,6 @@ import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-queimport { useCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'import { IS_PLATFORM } from 'lib/constants'-import FormField from '../AuthProvidersForm/FormField'import {AlertDescription_Shadcn_,@@ -24,62 +22,15 @@ import {Alert_Shadcn_,Form,InputNumber,- Toggle,WarningIcon,} from 'ui'const schema = object({- JWT_EXP: number()- .max(604800, 'Must be less than 604800')- .required('Must have a JWT expiry value'),- REFRESH_TOKEN_ROTATION_ENABLED: boolean().required(),- SECURITY_REFRESH_TOKEN_REUSE_INTERVAL: number()- .min(0, 'Must be a value more than 0')- .required('Must have a Reuse Interval value'),- MFA_PHONE_OTP_LENGTH: number()- .min(6, 'Must be a value 6 or larger')- .max(30, 'must be a value no greater than 30'),- MFA_PHONE_TEMPLATE: string().required('SMS template is required.'),- MFA_MAX_ENROLLED_FACTORS: number()- .min(0, 'Must be be a value more than 0')- .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'),- MFA_TOTP: string().required(),- MFA_PHONE: string().required(),})-function determineMFAStatus(verifyEnabled: boolean, enrollEnabled: boolean) {- return verifyEnabled ? (enrollEnabled ? 'Enabled' : 'Verify Enabled') : 'Disabled'-}--const MFAFactorSelectionOptions = [- {- label: 'Enabled',- value: 'Enabled',- },- {- label: 'Verify Enabled',- value: 'Verify Enabled',- },- {- label: 'Disabled',- value: 'Disabled',- },-]--const MfaStatusToState = (status: (typeof MFAFactorSelectionOptions)[number]['value']) => {- return status === 'Enabled'- ? { verifyEnabled: true, enrollEnabled: true }- : status === 'Verify Enabled'- ? { verifyEnabled: true, enrollEnabled: false }- : { verifyEnabled: false, enrollEnabled: false }-}-const AdvancedAuthSettingsForm = () => {const { ref: projectRef } = useParams()const {@@ -102,72 +53,16 @@ const AdvancedAuthSettingsForm = () => {const isTeamsEnterprisePlan =isSuccessSubscription && subscription.plan.id !== 'free' && subscription.plan.id !== 'pro'- const isProPlanAndUp = isSuccessSubscription && subscription?.plan?.id !== 'free'- const promptProPlanUpgrade = IS_PLATFORM && !isProPlanAndUp-- const projectAddons = subscription?.project_addons.find((addon) => addon.ref === projectRef)- const hasPurchasedAuthMFAAddOn = projectAddons?.addons.some(- (addon) => addon.type === 'auth_mfa_phone'- )const promptTeamsEnterpriseUpgrade = IS_PLATFORM && !isTeamsEnterprisePlanconst INITIAL_VALUES = {- SITE_URL: authConfig?.SITE_URL,- JWT_EXP: authConfig?.JWT_EXP,- REFRESH_TOKEN_ROTATION_ENABLED: authConfig?.REFRESH_TOKEN_ROTATION_ENABLED || false,- MFA_PHONE_OTP_LENGTH: authConfig?.MFA_PHONE_OTP_LENGTH || 6,- MFA_PHONE_TEMPLATE: authConfig?.MFA_PHONE_TEMPLATE || 'Your code is {{ .Code }}',- 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,- // TOTP is enabled by default. Auth environment variables are distinct from UI state - we use MFA_TOTP and MFA_PHONE to hold the derivedUI state.- // MFA_TOTP_VERIFY_ENABLED and MFA_TOTP_ENROLL_ENABLED -> Enabled- // MFA_TOTP_VERIFY_ENABLED and !MFA_TOTP_ENROLL_ENABLED -> Verify Enabled- // !MFA_TOTP_VERIFY_ENABLED and !MFA_TOTP_ENROLL_ENABLED -> Disabled- MFA_TOTP:- determineMFAStatus(- authConfig?.MFA_TOTP_VERIFY_ENABLED ?? true,- authConfig?.MFA_TOTP_ENROLL_ENABLED ?? true- ) || 'Enabled',- MFA_PHONE:- determineMFAStatus(- authConfig?.MFA_PHONE_VERIFY_ENABLED || false,- authConfig?.MFA_PHONE_ENROLL_ENABLED || false- ) || 'Disabled',}- // For now, we support Twilio and Vonage. Twilio Verify is not supported and the remaining providers are community maintained.- const sendSMSHookIsEnabled =- authConfig?.HOOK_SEND_SMS_URI !== null && authConfig?.HOOK_SEND_SMS_ENABLED === true- const hasValidMFAPhoneProvider = authConfig?.EXTERNAL_PHONE_ENABLED === true- const hasValidMFAProvider = hasValidMFAPhoneProvider || sendSMSHookIsEnabled-const onSubmit = (values: any, { resetForm }: any) => {- let payload = { ...values }- const { verifyEnabled: MFA_TOTP_VERIFY_ENABLED, enrollEnabled: MFA_TOTP_ENROLL_ENABLED } =- MfaStatusToState(values.MFA_TOTP)- // MFA (Phone) is only available on Pro Plans and up. We translate the UI state, MFA_PHONE and MFA_TOTP into the underlying- // Auth config state - MFA_PHONE_*_ENABLED and MFA_TOTP_*_ENABLED.- if (isProPlanAndUp) {- const { verifyEnabled: MFA_PHONE_VERIFY_ENABLED, enrollEnabled: MFA_PHONE_ENROLL_ENABLED } =- MfaStatusToState(values.MFA_PHONE)- payload = {- ...payload,- MFA_PHONE_ENROLL_ENABLED,- MFA_PHONE_VERIFY_ENABLED,- }- }- payload = {- ...payload,- MFA_TOTP_ENROLL_ENABLED,- MFA_TOTP_VERIFY_ENABLED,- }- delete payload.MFA_TOTP- delete payload.MFA_PHONE+ const payload = { ...values }if (!isTeamsEnterprisePlan) {- delete payload.DB_MAX_POOL_SIZEdelete payload.API_MAX_REQUEST_DURATION}@@ -201,27 +96,11 @@ const AdvancedAuthSettingsForm = () => {return (<Form id={formId} initialValues={INITIAL_VALUES} onSubmit={onSubmit} validationSchema={schema}>- {({ handleReset, resetForm, values, initialValues, setFieldValue }: any) => {+ {({ handleReset, values, initialValues }: any) => {const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)- // Form is reset once remote data is loaded in store- // eslint-disable-next-line react-hooks/rules-of-hooks- useEffect(() => {- if (isSuccess) resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })- }, [isSuccess])-- const hasUpgradedPhoneMFA =- INITIAL_VALUES.MFA_PHONE === 'Disabled' && values.MFA_PHONE !== INITIAL_VALUES.MFA_PHONE- const phoneMFAIsEnabled =- values.MFA_PHONE === 'Enabled' || values.MFA_PHONE === 'Verify Enabled'-return (<>- <FormHeader- title="Advanced Settings"- description="These settings rarely need to be changed."- />-<FormPaneldisabled={true}footer={@@ -241,151 +120,6 @@ const AdvancedAuthSettingsForm = () => {</div>}>- <FormSection header={<FormSectionLabel>Access Tokens (JWT)</FormSectionLabel>}>- <FormSectionContent loading={isLoading}>- <InputNumber- id="JWT_EXP"- size="small"- label="Access token (JWT) expiry time"- descriptionText="How long access tokens are valid for before a refresh token has to be used. Recommendation: 3600 (1 hour)."- actions={<span className="mr-3 text-foreground-lighter">seconds</span>}- disabled={!canUpdateConfig}- />- </FormSectionContent>- </FormSection>- <FormSection header={<FormSectionLabel>Refresh Tokens</FormSectionLabel>}>- <FormSectionContent loading={isLoading}>- <Toggle- id="REFRESH_TOKEN_ROTATION_ENABLED"- size="small"- label="Detect and revoke potentially compromised refresh tokens"- layout="flex"- descriptionText="Prevent replay attacks from potentially compromised refresh tokens. Recommendation: ON."- disabled={!canUpdateConfig}- />- {values.REFRESH_TOKEN_ROTATION_ENABLED && (- <InputNumber- id="SECURITY_REFRESH_TOKEN_REUSE_INTERVAL"- size="small"- min={0}- label="Refresh token reuse interval"- descriptionText="Time interval where the same refresh token can be used multiple times to request for an access token. Recommendation: 10 seconds."- actions={<span className="mr-3 text-foreground-lighter">seconds</span>}- disabled={!canUpdateConfig}- />- )}- </FormSectionContent>- </FormSection>- <FormSection- header={<FormSectionLabel>Multi-Factor Authentication (MFA)</FormSectionLabel>}- >- <FormSectionContent loading={isLoading}>- <FormField- name="MFA_TOTP"- properties={{- type: 'select',- title: 'TOTP (App Authenticator)',- description: 'Control use of TOTP (App Authenticator) factors',- enum: MFAFactorSelectionOptions,- }}- formValues={values}- disabled={!canUpdateConfig}- setFieldValue={setFieldValue}- />-- <InputNumber- id="MFA_MAX_ENROLLED_FACTORS"- 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>Advanced MFA</FormSectionLabel>}>- <FormSectionContent loading={isLoading}>- {promptProPlanUpgrade && (- <UpgradeToPro- primaryText="Upgrade to Pro"- secondaryText="Advanced MFA requires the Pro Plan"- />- )}- <FormField- name="MFA_PHONE"- properties={{- type: 'select',- title: 'Phone',- description: 'Control use of phone factors',- enum: MFAFactorSelectionOptions,- }}- formValues={values}- disabled={!canUpdateConfig || !isProPlanAndUp}- setFieldValue={setFieldValue}- />- {!hasValidMFAProvider && phoneMFAIsEnabled && (- <Alert_Shadcn_ variant="warning">- <WarningIcon />- <AlertTitle_Shadcn_>- To use MFA with Phone you should set up a Phone provider or Send SMS Hook.- </AlertTitle_Shadcn_>- </Alert_Shadcn_>- )}-- <InputNumber- id="MFA_PHONE_OTP_LENGTH"- size="small"- label="Phone OTP Length"- descriptionText="Number of digits in OTP"- disabled={!canUpdateConfig || !isProPlanAndUp}- />- <FormField- name="MFA_PHONE_TEMPLATE"- properties={{- title: 'Phone verification message',- type: 'multiline-string',- description: 'To format the OTP code use `{{ .Code }}`',- }}- formValues={values}- disabled={!canUpdateConfig || !isProPlanAndUp}- setFieldValue={setFieldValue}- />- {hasUpgradedPhoneMFA && (- <Alert_Shadcn_ variant="warning">- <WarningIcon />- <AlertTitle_Shadcn_>- Enabling advanced MFA with phone will result in an additional charge of $75- per month for the first project in the organization and an additional $10- per month for additional projects.- </AlertTitle_Shadcn_>- </Alert_Shadcn_>- )}- </FormSectionContent>- </FormSection>-- <FormSection- header={<FormSectionLabel>Max Direct Database Connections</FormSectionLabel>}- >- <FormSectionContent loading={isLoading}>- {promptTeamsEnterpriseUpgrade && (- <UpgradeToPro- primaryText="Upgrade to Team or Enterprise"- secondaryText="Max Direct Database Connections settings are only available on the Team Plan and up."- buttonText="Upgrade to Team"- />- )}-- <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 && (diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersFormValidation.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersFormValidation.tsxindex dcb72820e2a..7b695478ac4 100644--- a/apps/studio/components/interfaces/Auth/AuthProvidersFormValidation.tsx+++ b/apps/studio/components/interfaces/Auth/AuthProvidersFormValidation.tsx@@ -36,6 +36,44 @@ const PROVIDER_EMAIL = {If disabled, a user can change their password at any time.`,type: 'boolean',},+ PASSWORD_HIBP_ENABLED: {+ title: 'Prevent use of leaked passwords',+ description:+ 'Rejects the use of known or easy to guess passwords on sign up or password change. Powered by the HaveIBeenPwned.org Pwned Passwords API.',+ type: 'boolean',+ },+ PASSWORD_MIN_LENGTH: {+ title: 'Minimum password length',+ type: 'number',+ description:+ 'Passwords shorter than this value will be rejected as weak. Minimum 6, recommended 8 or more.',+ units: 'characters',+ },+ PASSWORD_REQUIRED_CHARACTERS: {+ type: 'select',+ title: 'Password Requirements',+ description: 'Passwords that do not have at least one of each will be rejected as weak.',+ enum: [+ {+ label: 'No required characters (default)',+ value: 'NO_REQUIRED_CHARS',+ },+ {+ label: 'Letters and digits',+ value: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:0123456789',+ },+ {+ label: 'Lowercase, uppercase letters and digits',+ value: 'abcdefghijklmnopqrstuvwxyz:ABCDEFGHIJKLMNOPQRSTUVWXYZ:0123456789',+ },+ {+ label: 'Lowercase, uppercase letters, digits and symbols (recommended)',+ value:+ 'abcdefghijklmnopqrstuvwxyz:ABCDEFGHIJKLMNOPQRSTUVWXYZ:0123456789:!@#$%^&*()_+-=[]{};\'\\\\:"|<>?,./`~',+ },+ ],+ },+MAILER_OTP_EXP: {title: 'Email OTP Expiration',type: 'number',@@ -55,6 +93,9 @@ const PROVIDER_EMAIL = {.max(86400, 'Must be no more than 86400').required('This is required'),MAILER_OTP_LENGTH: number().min(6, 'Must be at least 6').max(10, 'Must be no more than 10'),+ PASSWORD_MIN_LENGTH: number()+ .min(6, 'Must be greater or equal to 6.')+ .required('This is required'),}),misc: {iconKey: 'email-icon2',diff --git a/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsxindex 6ddf1eafef7..aee0b0fdd0e 100644--- a/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx+++ b/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx@@ -1,9 +1,9 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-import { ExternalLink, Eye, EyeOff } from 'lucide-react'+import { ExternalLink } from 'lucide-react'import Link from 'next/link'-import { useEffect, useState } from 'react'+import { useEffect } from 'react'import { toast } from 'sonner'-import { boolean, number, object, string } from 'yup'+import { boolean, object, string } from 'yup'import { useParams } from 'common'import { Markdown } from 'components/interfaces/Markdown'@@ -11,67 +11,30 @@ import { FormActions } from 'components/ui/Forms/FormActions'import { FormPanel } from 'components/ui/Forms/FormPanel'import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'import NoPermission from 'components/ui/NoPermission'-import UpgradeToPro from 'components/ui/UpgradeToPro'import { useAuthConfigQuery } from 'data/auth/auth-config-query'import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'-import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'-import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'-import { IS_PLATFORM } from 'lib/constants'import {AlertDescription_Shadcn_,AlertTitle_Shadcn_,Alert_Shadcn_,Button,Form,- Input,- InputNumber,Toggle,WarningIcon,} from 'ui'-import FormField from '../AuthProvidersForm/FormField'+import { FormHeader } from 'components/ui/Forms/FormHeader'// Use a const string to represent no chars option. Represented as empty string on the backend side.const NO_REQUIRED_CHARACTERS = 'NO_REQUIRED_CHARS'-const LETTERS_AND_DIGITS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:0123456789'-const LOWER_UPPER_DIGITS = 'abcdefghijklmnopqrstuvwxyz:ABCDEFGHIJKLMNOPQRSTUVWXYZ:0123456789'-const LOWER_UPPER_DIGITS_SYMBOLS = LOWER_UPPER_DIGITS + ':!@#$%^&*()_+-=[]{};\'\\\\:"|<>?,./`~'const schema = object({DISABLE_SIGNUP: boolean().required(),EXTERNAL_ANONYMOUS_USERS_ENABLED: boolean().required(),SECURITY_MANUAL_LINKING_ENABLED: boolean().required(),SITE_URL: string().required('Must have a Site URL'),- SECURITY_CAPTCHA_ENABLED: boolean().required(),- SECURITY_CAPTCHA_SECRET: string().when('SECURITY_CAPTCHA_ENABLED', {- is: true,- then: (schema) => schema.required('Must have a Captcha secret'),- }),- SECURITY_CAPTCHA_PROVIDER: string().when('SECURITY_CAPTCHA_ENABLED', {- is: true,- then: (schema) =>- schema- .oneOf(['hcaptcha', 'turnstile'])- .required('Captcha provider must be either hcaptcha or turnstile'),- }),- SESSIONS_TIMEBOX: number().min(0, 'Must be a positive number'),- SESSIONS_INACTIVITY_TIMEOUT: number().min(0, 'Must be a positive number'),- SESSIONS_SINGLE_PER_USER: boolean(),- PASSWORD_MIN_LENGTH: number().min(6, 'Must be greater or equal to 6.'),- PASSWORD_REQUIRED_CHARACTERS: string(),- PASSWORD_HIBP_ENABLED: boolean(),})-function HoursOrNeverText({ value }: { value: number }) {- if (value === 0) {- return 'never'- } else if (value === 1) {- return 'hour'- } else {- return 'hours'- }-}-const formId = 'auth-config-basic-settings'const BasicAuthSettingsForm = () => {@@ -85,36 +48,14 @@ const BasicAuthSettingsForm = () => {} = useAuthConfigQuery({ projectRef })const { mutate: updateAuthConfig, isLoading: isUpdatingConfig } = useAuthConfigUpdateMutation()- const [hidden, setHidden] = useState(true)const canReadConfig = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue')- const organization = useSelectedOrganization()- const { data: subscription, isSuccess: isSuccessSubscription } = useOrgSubscriptionQuery(- {- orgSlug: organization?.slug,- },- { enabled: IS_PLATFORM }- )-- const isProPlanAndUp = isSuccessSubscription && subscription?.plan?.id !== 'free'- const promptProPlanUpgrade = IS_PLATFORM && !isProPlanAndUp-const INITIAL_VALUES = {DISABLE_SIGNUP: !authConfig?.DISABLE_SIGNUP,EXTERNAL_ANONYMOUS_USERS_ENABLED: authConfig?.EXTERNAL_ANONYMOUS_USERS_ENABLED,SECURITY_MANUAL_LINKING_ENABLED: authConfig?.SECURITY_MANUAL_LINKING_ENABLED || false,SITE_URL: authConfig?.SITE_URL,- SECURITY_CAPTCHA_ENABLED: authConfig?.SECURITY_CAPTCHA_ENABLED || false,- SECURITY_CAPTCHA_SECRET: authConfig?.SECURITY_CAPTCHA_SECRET || '',- SECURITY_CAPTCHA_PROVIDER: authConfig?.SECURITY_CAPTCHA_PROVIDER || 'hcaptcha',- SESSIONS_TIMEBOX: authConfig?.SESSIONS_TIMEBOX || 0,- SESSIONS_INACTIVITY_TIMEOUT: authConfig?.SESSIONS_INACTIVITY_TIMEOUT || 0,- SESSIONS_SINGLE_PER_USER: authConfig?.SESSIONS_SINGLE_PER_USER || false,- PASSWORD_MIN_LENGTH: authConfig?.PASSWORD_MIN_LENGTH || 6,- PASSWORD_REQUIRED_CHARACTERS:- authConfig?.PASSWORD_REQUIRED_CHARACTERS || NO_REQUIRED_CHARACTERS,- PASSWORD_HIBP_ENABLED: authConfig?.PASSWORD_HIBP_ENABLED || false,}const onSubmit = (values: any, { resetForm }: any) => {@@ -154,114 +95,125 @@ const BasicAuthSettingsForm = () => {}return (- <Form id={formId} initialValues={INITIAL_VALUES} onSubmit={onSubmit} validationSchema={schema}>- {({ handleReset, resetForm, values, initialValues, setFieldValue }: any) => {- const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)- // Form is reset once remote data is loaded in store- // eslint-disable-next-line react-hooks/rules-of-hooks- useEffect(() => {- if (isSuccess) resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })- }, [isSuccess])-- return (- <>- <FormPanel- disabled={true}- footer={- <div className="flex py-4 px-8">- <FormActions- form={formId}- isSubmitting={isUpdatingConfig}- hasChanges={hasChanges}- handleReset={handleReset}- disabled={!canUpdateConfig}- helper={- !canUpdateConfig- ? 'You need additional permissions to update authentication settings'- : undefined- }- />- </div>- }- >- <FormSection header={<FormSectionLabel>User Signups</FormSectionLabel>}>- <FormSectionContent loading={isLoading}>- <Toggle- id="DISABLE_SIGNUP"- size="small"- label="Allow new users to sign up"- layout="flex"- descriptionText="If this is disabled, new users will not be able to sign up to your application."- disabled={!canUpdateConfig}- />- <Toggle- id="SECURITY_MANUAL_LINKING_ENABLED"- size="small"- label="Allow manual linking"- layout="flex"- descriptionText={- <Markdown- extLinks- className="[&>p>a]:text-foreground-light [&>p>a]:transition-all [&>p>a]:hover:text-foreground [&>p>a]:hover:decoration-brand"- content="Enable [manual linking APIs](https://supabase.com/docs/guides/auth/auth-identity-linking#manual-linking-beta) for your project."- />- }- disabled={!canUpdateConfig}- />- <Toggle- id="EXTERNAL_ANONYMOUS_USERS_ENABLED"- size="small"- label="Allow anonymous sign-ins"- layout="flex"- descriptionText={- <Markdown- extLinks- className="[&>p>a]:text-foreground-light [&>p>a]:transition-all [&>p>a]:hover:text-foreground [&>p>a]:hover:decoration-brand"- content="Enable [anonymous sign-ins](https://supabase.com/docs/guides/auth/auth-anonymous) for your project."- />- }- disabled={!canUpdateConfig}- />- {values.EXTERNAL_ANONYMOUS_USERS_ENABLED && (- <div className="flex flex-col gap-y-2">- <Alert_Shadcn_- className="flex w-full items-center justify-between"- variant="warning"- >- <WarningIcon />- <div>- <AlertTitle_Shadcn_>- Anonymous users will use the{' '}- <code className="text-xs">authenticated</code> role when signing in- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_ className="flex flex-col gap-y-3">- <p>- As a result, anonymous users will be subjected to RLS policies that- apply to the <code className="text-xs">public</code> and{' '}- <code className="text-xs">authenticated</code> roles. We strongly- advise{' '}- <Link- href={`/project/${projectRef}/auth/policies`}- className="text-foreground underline"+ <div>+ <FormHeader title="General" />++ <Form+ id={formId}+ initialValues={INITIAL_VALUES}+ onSubmit={onSubmit}+ validationSchema={schema}+ >+ {({ handleReset, resetForm, values, initialValues, setFieldValue }: any) => {+ const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ // Form is reset once remote data is loaded in store+ // eslint-disable-next-line react-hooks/rules-of-hooks+ useEffect(() => {+ if (isSuccess) resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })+ }, [isSuccess])++ return (+ <>+ <FormPanel+ disabled={true}+ footer={+ <div className="flex py-4 px-8">+ <FormActions+ form={formId}+ isSubmitting={isUpdatingConfig}+ hasChanges={hasChanges}+ handleReset={handleReset}+ disabled={!canUpdateConfig}+ helper={+ !canUpdateConfig+ ? 'You need additional permissions to update authentication settings'+ : undefined+ }+ />+ </div>+ }+ >+ <FormSection header={<FormSectionLabel>User Signups</FormSectionLabel>}>+ <FormSectionContent loading={isLoading}>+ <Toggle+ id="DISABLE_SIGNUP"+ size="small"+ label="Allow new users to sign up"+ layout="flex"+ descriptionText="If this is disabled, new users will not be able to sign up to your application."+ disabled={!canUpdateConfig}+ />+ <Toggle+ id="SECURITY_MANUAL_LINKING_ENABLED"+ size="small"+ label="Allow manual linking"+ layout="flex"+ descriptionText={+ <Markdown+ extLinks+ className="[&>p>a]:text-foreground-light [&>p>a]:transition-all [&>p>a]:hover:text-foreground [&>p>a]:hover:decoration-brand"+ content="Enable [manual linking APIs](https://supabase.com/docs/guides/auth/auth-identity-linking#manual-linking-beta) for your project."+ />+ }+ disabled={!canUpdateConfig}+ />+ <Toggle+ id="EXTERNAL_ANONYMOUS_USERS_ENABLED"+ size="small"+ label="Allow anonymous sign-ins"+ layout="flex"+ descriptionText={+ <Markdown+ extLinks+ className="[&>p>a]:text-foreground-light [&>p>a]:transition-all [&>p>a]:hover:text-foreground [&>p>a]:hover:decoration-brand"+ content="Enable [anonymous sign-ins](https://supabase.com/docs/guides/auth/auth-anonymous) for your project."+ />+ }+ disabled={!canUpdateConfig}+ />+ {values.EXTERNAL_ANONYMOUS_USERS_ENABLED && (+ <div className="flex flex-col gap-y-2">+ <Alert_Shadcn_+ className="flex w-full items-center justify-between"+ variant="warning"+ >+ <WarningIcon />+ <div>+ <AlertTitle_Shadcn_>+ Anonymous users will use the{' '}+ <code className="text-xs">authenticated</code> role when signing in+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_ className="flex flex-col gap-y-3">+ <p>+ As a result, anonymous users will be subjected to RLS policies that+ apply to the <code className="text-xs">public</code> and{' '}+ <code className="text-xs">authenticated</code> roles. We strongly+ advise{' '}+ <Link+ href={`/project/${projectRef}/auth/policies`}+ className="text-foreground underline"+ >+ reviewing your RLS policies+ </Link>{' '}+ to ensure that access to your data is restricted where required.+ </p>+ <Button+ asChild+ type="default"+ className="w-min"+ icon={<ExternalLink />}>- reviewing your RLS policies- </Link>{' '}- to ensure that access to your data is restricted where required.- </p>- <Button- asChild- type="default"- className="w-min"- icon={<ExternalLink />}- >- <Link href="https://supabase.com/docs/guides/auth/auth-anonymous#access-control">- View access control docs- </Link>- </Button>- </AlertDescription_Shadcn_>- </div>- </Alert_Shadcn_>- {!values.SECURITY_CAPTCHA_ENABLED && (+ <Link href="https://supabase.com/docs/guides/auth/auth-anonymous#access-control">+ View access control docs+ </Link>+ </Button>+ </AlertDescription_Shadcn_>+ </div>+ </Alert_Shadcn_>+ </div>+ )}+ {!authConfig?.SECURITY_CAPTCHA_ENABLED &&+ values.EXTERNAL_ANONYMOUS_USERS_ENABLED && (<Alert_Shadcn_><WarningIcon /><AlertTitle_Shadcn_>@@ -284,173 +236,14 @@ const BasicAuthSettingsForm = () => {</AlertDescription_Shadcn_></Alert_Shadcn_>)}- </div>- )}- </FormSectionContent>- </FormSection>- <FormSection header={<FormSectionLabel>Passwords</FormSectionLabel>}>- <FormSectionContent loading={isLoading}>- <InputNumber- id="PASSWORD_MIN_LENGTH"- size="small"- label="Minimum password length"- descriptionText="Passwords shorter than this value will be rejected as weak. Minimum 6, recommended 8 or more."- actions={<span className="mr-3 text-foreground-lighter">characters</span>}- disabled={!canUpdateConfig}- />- <FormField- name="PASSWORD_REQUIRED_CHARACTERS"- properties={{- type: 'select',- title: 'Password Requirements',- description:- 'Passwords that do not have at least one of each will be rejected as weak.',- enum: [- {- label: 'No required characters (default)',- value: NO_REQUIRED_CHARACTERS,- },- {- label: 'Letters and digits',- value: LETTERS_AND_DIGITS,- },- {- label: 'Lowercase, uppercase letters and digits',- value: LOWER_UPPER_DIGITS,- },- {- label: 'Lowercase, uppercase letters, digits and symbols (recommended)',- value: LOWER_UPPER_DIGITS_SYMBOLS,- },- ],- }}- formValues={values}- setFieldValue={setFieldValue}- />- {!promptProPlanUpgrade ? (- <></>- ) : (- <UpgradeToPro- primaryText="Upgrade to Pro"- secondaryText="Leaked password protection available on Pro plans and up."- />- )}- <Toggle- id="PASSWORD_HIBP_ENABLED"- size="small"- label="Prevent use of leaked passwords"- afterLabel=" (recommended)"- layout="flex"- descriptionText="Rejects the use of known or easy to guess passwords on sign up or password change. Powered by the HaveIBeenPwned.org Pwned Passwords API."- disabled={!canUpdateConfig || !isProPlanAndUp}- />- </FormSectionContent>- </FormSection>- <FormSection header={<FormSectionLabel>User Sessions</FormSectionLabel>}>- <FormSectionContent loading={isLoading}>- {!promptProPlanUpgrade ? (- <></>- ) : (- <UpgradeToPro- primaryText="Upgrade to Pro"- secondaryText="Configuring user sessions requires the Pro Plan."- />- )}- <Toggle- id="SESSIONS_SINGLE_PER_USER"- size="small"- label="Enforce single session per user"- layout="flex"- descriptionText="If enabled, all but a user's most recently active session will be terminated."- disabled={!canUpdateConfig || !isProPlanAndUp}- />- <InputNumber- id="SESSIONS_TIMEBOX"- size="small"- label="Time-box user sessions"- descriptionText="The amount of time before a user is forced to sign in again. Use 0 for never"- actions={- <span className="mr-3 text-foreground-lighter">- <HoursOrNeverText value={values.SESSIONS_TIMEBOX} />- </span>- }- disabled={!canUpdateConfig || !isProPlanAndUp}- />- <InputNumber- id="SESSIONS_INACTIVITY_TIMEOUT"- size="small"- label="Inactivity timeout"- descriptionText="The amount of time a user needs to be inactive to be forced to sign in again. Use 0 for never."- actions={- <span className="mr-3 text-foreground-lighter">- <HoursOrNeverText value={values.SESSIONS_INACTIVITY_TIMEOUT} />- </span>- }- disabled={!canUpdateConfig || !isProPlanAndUp}- />- </FormSectionContent>- </FormSection>- <FormSection- id="enable-captcha"- header={<FormSectionLabel>Bot and Abuse Protection</FormSectionLabel>}- >- <FormSectionContent loading={isLoading}>- <Toggle- id="SECURITY_CAPTCHA_ENABLED"- size="small"- label="Enable Captcha protection"- layout="flex"- descriptionText="Protect authentication endpoints from bots and abuse."- disabled={!canUpdateConfig}- />- {values.SECURITY_CAPTCHA_ENABLED && (- <>- <FormField- name="SECURITY_CAPTCHA_PROVIDER"- properties={{- type: 'select',- title: 'Choose Captcha Provider',- description: '',- enum: [- {- label: 'hCaptcha',- value: 'hcaptcha',- icon: 'hcaptcha-icon.png',- },- {- label: 'Turnstile by Cloudflare',- value: 'turnstile',- icon: 'cloudflare-icon.png',- },- ],- }}- formValues={values}- setFieldValue={setFieldValue}- />- <Input- id="SECURITY_CAPTCHA_SECRET"- type={hidden ? 'password' : 'text'}- size="small"- label="Captcha secret"- descriptionText="Obtain this secret from the provider."- disabled={!canUpdateConfig}- actions={- <Button- icon={hidden ? <Eye /> : <EyeOff />}- type="default"- onClick={() => setHidden(!hidden)}- />- }- />- </>- )}- </FormSectionContent>- </FormSection>- </FormPanel>- </>- )- }}- </Form>+ </FormSectionContent>+ </FormSection>+ </FormPanel>+ </>+ )+ }}+ </Form>+ </div>)}diff --git a/apps/studio/components/interfaces/Auth/EmailRateLimitsAlert/EmailRateLimitsAlert.tsx b/apps/studio/components/interfaces/Auth/EmailRateLimitsAlert/EmailRateLimitsAlert.tsxindex 4eb4b01e371..e5e4d39fdb7 100644--- a/apps/studio/components/interfaces/Auth/EmailRateLimitsAlert/EmailRateLimitsAlert.tsx+++ b/apps/studio/components/interfaces/Auth/EmailRateLimitsAlert/EmailRateLimitsAlert.tsx@@ -1,6 +1,7 @@import Link from 'next/link'import { useParams } from 'common'+import { InlineLink } from 'components/ui/InlineLink'import {AlertDescription_Shadcn_,AlertTitle_Shadcn_,@@ -19,20 +20,14 @@ export function EmailRateLimitsAlert() {<AlertDescription_Shadcn_>You're using the built-in email service. The service has rate limits and it's not meant tobe used for production apps. Check the{' '}- {/* [Refactor] Swap for InlineLink component once https://github.com/supabase/supabase/pull/30494 is in */}- <a- href="https://supabase.com/docs/guides/platform/going-into-prod#auth-rate-limits"- className="underline"- target="_blank"- rel="noreferrer noopener"- >+ <InlineLink href="https://supabase.com/docs/guides/platform/going-into-prod#auth-rate-limits">documentation- </a>{' '}+ </InlineLink>{' '}for an up-to-date information on the current rate limits.- <Button asChild type="default" className="mt-2">- <Link target="_blank" href={`/project/${ref}/settings/auth#auth-config-smtp-form`}>- Set up custom SMTP server- </Link>+ </AlertDescription_Shadcn_>+ <AlertDescription_Shadcn_ className="mt-2">+ <Button asChild type="default">+ <Link href={`/project/${ref}/auth/smtp`}>Set up custom SMTP server</Link></Button></AlertDescription_Shadcn_></Alert_Shadcn_>diff --git a/apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx b/apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsxindex d7ed428d7cd..e67cb1ca492 100644--- a/apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx+++ b/apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx@@ -33,13 +33,6 @@ const EmailTemplates = () => {return (<div className="w-full">- <div className="w-full flex justify-between items-center">- <FormHeader- title="Email Templates"- description="Customize the emails that will be sent out to your users."- docsUrl="https://supabase.com/docs/guides/auth/auth-email-templates"- />- </div>{isError && (<AlertError error={authConfigError} subject="Failed to retrieve auth configuration" />)}@@ -49,32 +42,35 @@ const EmailTemplates = () => {</div>)}{isSuccess && (- <FormPanel>- <Tabs_Shadcn_ defaultValue={TEMPLATES_SCHEMAS[0].title.trim().replace(/\s+/g, '-')}>- <TabsList_Shadcn_ className="px-4 md:px-8 pt-2 gap-5 overflow-x-scroll no-scrollbar">+ <>+ {builtInSMTP ? (+ <div className="mb-4">+ <EmailRateLimitsAlert />+ </div>+ ) : null}+ <FormPanel>+ <Tabs_Shadcn_ defaultValue={TEMPLATES_SCHEMAS[0].title.trim().replace(/\s+/g, '-')}>+ <TabsList_Shadcn_ className="px-4 md:px-8 pt-2 gap-5 overflow-x-scroll no-scrollbar">+ {TEMPLATES_SCHEMAS.map((template) => {+ return (+ <TabsTrigger_Shadcn_ value={template.title.trim().replace(/\s+/g, '-')}>+ {template.title}+ </TabsTrigger_Shadcn_>+ )+ })}+ </TabsList_Shadcn_>+{TEMPLATES_SCHEMAS.map((template) => {+ const panelId = template.title.trim().replace(/\s+/g, '-')return (- <TabsTrigger_Shadcn_ value={template.title.trim().replace(/\s+/g, '-')}>- {template.title}- </TabsTrigger_Shadcn_>+ <TabsContent_Shadcn_ value={panelId} key={panelId}>+ <TemplateEditor key={template.title} template={template} />+ </TabsContent_Shadcn_>)})}- </TabsList_Shadcn_>- {TEMPLATES_SCHEMAS.map((template) => {- const panelId = template.title.trim().replace(/\s+/g, '-')- return (- <TabsContent_Shadcn_ value={panelId} key={panelId}>- {builtInSMTP ? (- <div className="px-4 md:px-8">- <EmailRateLimitsAlert />- </div>- ) : null}- <TemplateEditor key={template.title} template={template} />- </TabsContent_Shadcn_>- )- })}- </Tabs_Shadcn_>- </FormPanel>+ </Tabs_Shadcn_>+ </FormPanel>+ </>)}</div>)diff --git a/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx b/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsxindex 23b202cc9ba..5e1d5738d1a 100644--- a/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx+++ b/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx@@ -166,7 +166,7 @@ const TemplateEditor = ({ template }: TemplateEditorProps) => {return (<>- <FormSection className="!border-t-0 pb-8 pt-4">+ <FormSection className="!border-t-0 pb-8 !pt-4"><FormSectionContent loading={false}>{Object.keys(properties).map((x: string) => {const property = properties[x]diff --git a/apps/studio/components/interfaces/Auth/Hooks/HooksListing.tsx b/apps/studio/components/interfaces/Auth/Hooks/HooksListing.tsxindex 37c469af4ac..f005bb73987 100644--- a/apps/studio/components/interfaces/Auth/Hooks/HooksListing.tsx+++ b/apps/studio/components/interfaces/Auth/Hooks/HooksListing.tsx@@ -69,11 +69,7 @@ export const HooksListing = () => {return (<div className="pb-4">- <FormHeader- title="Auth Hooks"- description="Use Postgres functions or HTTP endpoints to customize the behavior of Supabase Auth to meet your needs."- actions={<AddHookDropdown onSelectHook={setSelectedHook} />}- />+ <FormHeader title="All hooks" actions={<AddHookDropdown onSelectHook={setSelectedHook} />} />{hooks.filter((h) => isValidHook(h)).length === 0 && (<divdiff --git a/apps/studio/components/interfaces/Auth/MfaAuthSettingsForm/MfaAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/MfaAuthSettingsForm/MfaAuthSettingsForm.tsxnew file mode 100644index 00000000000..973d4358440--- /dev/null+++ b/apps/studio/components/interfaces/Auth/MfaAuthSettingsForm/MfaAuthSettingsForm.tsx@@ -0,0 +1,301 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'+import { useEffect } from 'react'+import { toast } from 'sonner'+import { number, object, string } from 'yup'++import { useParams } from 'common'+import { FormActions } from 'components/ui/Forms/FormActions'+import { FormHeader } from 'components/ui/Forms/FormHeader'+import { FormPanel } from 'components/ui/Forms/FormPanel'+import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'+import NoPermission from 'components/ui/NoPermission'+import UpgradeToPro from 'components/ui/UpgradeToPro'+import { useAuthConfigQuery } from 'data/auth/auth-config-query'+import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'+import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'+import { IS_PLATFORM } from 'lib/constants'+import FormField from '../AuthProvidersForm/FormField'++import {+ AlertDescription_Shadcn_,+ AlertTitle_Shadcn_,+ Alert_Shadcn_,+ Form,+ InputNumber,+ WarningIcon,+} from 'ui'++const schema = object({+ MFA_PHONE_OTP_LENGTH: number()+ .min(6, 'Must be a value 6 or larger')+ .max(30, 'must be a value no greater than 30'),+ MFA_PHONE_TEMPLATE: string().required('SMS template is required.'),+ MFA_MAX_ENROLLED_FACTORS: number()+ .min(0, 'Must be be a value more than 0')+ .max(30, 'Must be a value no greater than 30'),+ MFA_TOTP: string().required(),+ MFA_PHONE: string().required(),+})++function determineMFAStatus(verifyEnabled: boolean, enrollEnabled: boolean) {+ return verifyEnabled ? (enrollEnabled ? 'Enabled' : 'Verify Enabled') : 'Disabled'+}++const MFAFactorSelectionOptions = [+ {+ label: 'Enabled',+ value: 'Enabled',+ },+ {+ label: 'Verify Enabled',+ value: 'Verify Enabled',+ },+ {+ label: 'Disabled',+ value: 'Disabled',+ },+]++const MfaStatusToState = (status: (typeof MFAFactorSelectionOptions)[number]['value']) => {+ return status === 'Enabled'+ ? { verifyEnabled: true, enrollEnabled: true }+ : status === 'Verify Enabled'+ ? { verifyEnabled: true, enrollEnabled: false }+ : { verifyEnabled: false, enrollEnabled: false }+}++const MfaAuthSettingsForm = () => {+ const { ref: projectRef } = useParams()+ const {+ data: authConfig,+ error: authConfigError,+ isLoading,+ isError,+ isSuccess,+ } = useAuthConfigQuery({ projectRef })+ const { mutate: updateAuthConfig, isLoading: isUpdatingConfig } = useAuthConfigUpdateMutation()++ const formId = 'auth-config-advanced-form'+ const canReadConfig = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')+ const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue')++ const organization = useSelectedOrganization()+ const { data: subscription, isSuccess: isSuccessSubscription } = useOrgSubscriptionQuery({+ orgSlug: organization?.slug,+ })++ const isProPlanAndUp = isSuccessSubscription && subscription?.plan?.id !== 'free'+ const promptProPlanUpgrade = IS_PLATFORM && !isProPlanAndUp++ const projectAddons = subscription?.project_addons.find((addon) => addon.ref === projectRef)+ const hasPurchasedAuthMFAAddOn = projectAddons?.addons.some(+ (addon) => addon.type === 'auth_mfa_phone'+ )++ const INITIAL_VALUES = {+ MFA_PHONE_OTP_LENGTH: authConfig?.MFA_PHONE_OTP_LENGTH || 6,+ MFA_PHONE_TEMPLATE: authConfig?.MFA_PHONE_TEMPLATE || 'Your code is {{ .Code }}',+ MFA_MAX_ENROLLED_FACTORS: authConfig?.MFA_MAX_ENROLLED_FACTORS || 10,+ MFA_TOTP:+ determineMFAStatus(+ authConfig?.MFA_TOTP_VERIFY_ENABLED ?? true,+ authConfig?.MFA_TOTP_ENROLL_ENABLED ?? true+ ) || 'Enabled',+ MFA_PHONE:+ determineMFAStatus(+ authConfig?.MFA_PHONE_VERIFY_ENABLED || false,+ authConfig?.MFA_PHONE_ENROLL_ENABLED || false+ ) || 'Disabled',+ }++ // For now, we support Twilio and Vonage. Twilio Verify is not supported and the remaining providers are community maintained.+ const sendSMSHookIsEnabled =+ authConfig?.HOOK_SEND_SMS_URI !== null && authConfig?.HOOK_SEND_SMS_ENABLED === true+ const hasValidMFAPhoneProvider = authConfig?.EXTERNAL_PHONE_ENABLED === true+ const hasValidMFAProvider = hasValidMFAPhoneProvider || sendSMSHookIsEnabled++ const onSubmit = (values: any, { resetForm }: any) => {+ let payload = { ...values }+ const { verifyEnabled: MFA_TOTP_VERIFY_ENABLED, enrollEnabled: MFA_TOTP_ENROLL_ENABLED } =+ MfaStatusToState(values.MFA_TOTP)+ // MFA (Phone) is only available on Pro Plans and up. We translate the UI state, MFA_PHONE and MFA_TOTP into the underlying+ // Auth config state - MFA_PHONE_*_ENABLED and MFA_TOTP_*_ENABLED.+ if (isProPlanAndUp) {+ const { verifyEnabled: MFA_PHONE_VERIFY_ENABLED, enrollEnabled: MFA_PHONE_ENROLL_ENABLED } =+ MfaStatusToState(values.MFA_PHONE)+ payload = {+ ...payload,+ MFA_PHONE_ENROLL_ENABLED,+ MFA_PHONE_VERIFY_ENABLED,+ }+ }+ payload = {+ ...payload,+ MFA_TOTP_ENROLL_ENABLED,+ MFA_TOTP_VERIFY_ENABLED,+ }+ delete payload.MFA_TOTP+ delete payload.MFA_PHONE++ updateAuthConfig(+ { projectRef: projectRef!, config: payload },+ {+ onError: (error) => {+ toast.error(`Failed to update settings: ${error?.message}`)+ },+ onSuccess: () => {+ toast.success('Successfully updated settings')+ resetForm({ values: values, initialValues: values })+ },+ }+ )+ }++ if (isError) {+ return (+ <Alert_Shadcn_ variant="destructive">+ <WarningIcon />+ <AlertTitle_Shadcn_>Failed to retrieve auth configuration</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>{authConfigError.message}</AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ )+ }++ if (!canReadConfig) {+ return <NoPermission resourceText="view auth configuration settings" />+ }++ return (+ <Form id={formId} initialValues={INITIAL_VALUES} onSubmit={onSubmit} validationSchema={schema}>+ {({ handleReset, resetForm, values, initialValues, setFieldValue }: any) => {+ const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)++ // Form is reset once remote data is loaded in store+ // eslint-disable-next-line react-hooks/rules-of-hooks+ useEffect(() => {+ if (isSuccess) resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })+ }, [isSuccess])++ const hasUpgradedPhoneMFA =+ INITIAL_VALUES.MFA_PHONE === 'Disabled' && values.MFA_PHONE !== INITIAL_VALUES.MFA_PHONE+ const phoneMFAIsEnabled =+ values.MFA_PHONE === 'Enabled' || values.MFA_PHONE === 'Verify Enabled'++ return (+ <>+ <FormPanel+ disabled={true}+ footer={+ <div className="flex py-4 px-8">+ <FormActions+ form={formId}+ isSubmitting={isUpdatingConfig}+ hasChanges={hasChanges}+ handleReset={handleReset}+ disabled={!canUpdateConfig}+ helper={+ !canUpdateConfig+ ? 'You need additional permissions to update authentication settings'+ : undefined+ }+ />+ </div>+ }+ >+ <FormSection+ header={<FormSectionLabel>Multi-Factor Authentication (MFA)</FormSectionLabel>}+ >+ <FormSectionContent loading={isLoading}>+ <FormField+ name="MFA_TOTP"+ properties={{+ type: 'select',+ title: 'TOTP (App Authenticator)',+ description: 'Control use of TOTP (App Authenticator) factors',+ enum: MFAFactorSelectionOptions,+ }}+ formValues={values}+ disabled={!canUpdateConfig}+ setFieldValue={setFieldValue}+ />++ <InputNumber+ id="MFA_MAX_ENROLLED_FACTORS"+ 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>SMS MFA</FormSectionLabel>}>+ <FormSectionContent loading={isLoading}>+ {promptProPlanUpgrade && (+ <UpgradeToPro+ primaryText="Upgrade to Pro"+ secondaryText="Advanced MFA requires the Pro Plan"+ />+ )}+ <FormField+ name="MFA_PHONE"+ properties={{+ type: 'select',+ title: 'Phone',+ description: 'Control use of phone factors',+ enum: MFAFactorSelectionOptions,+ }}+ formValues={values}+ disabled={!canUpdateConfig || !isProPlanAndUp}+ setFieldValue={setFieldValue}+ />+ {!hasValidMFAProvider && phoneMFAIsEnabled && (+ <Alert_Shadcn_ variant="warning">+ <WarningIcon />+ <AlertTitle_Shadcn_>+ To use MFA with Phone you should set up a Phone provider or Send SMS Hook.+ </AlertTitle_Shadcn_>+ </Alert_Shadcn_>+ )}++ <InputNumber+ id="MFA_PHONE_OTP_LENGTH"+ size="small"+ label="Phone OTP Length"+ descriptionText="Number of digits in OTP"+ disabled={!canUpdateConfig || !isProPlanAndUp}+ />+ <FormField+ name="MFA_PHONE_TEMPLATE"+ properties={{+ title: 'Phone verification message',+ type: 'multiline-string',+ description: 'To format the OTP code use `{{ .Code }}`',+ }}+ formValues={values}+ disabled={!canUpdateConfig || !isProPlanAndUp}+ setFieldValue={setFieldValue}+ />+ {hasUpgradedPhoneMFA && (+ <Alert_Shadcn_ variant="warning">+ <WarningIcon />+ <AlertTitle_Shadcn_>+ Enabling advanced MFA with phone will result in an additional charge of $75+ per month for the first project in the organization and an additional $10+ per month for additional projects.+ </AlertTitle_Shadcn_>+ </Alert_Shadcn_>+ )}+ </FormSectionContent>+ </FormSection>+ </FormPanel>+ </>+ )+ }}+ </Form>+ )+}++export default MfaAuthSettingsFormdiff --git a/apps/studio/components/interfaces/Auth/ProtectionAuthSettingsForm/ProtectionAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/ProtectionAuthSettingsForm/ProtectionAuthSettingsForm.tsxnew file mode 100644index 00000000000..a53f0d0d08a--- /dev/null+++ b/apps/studio/components/interfaces/Auth/ProtectionAuthSettingsForm/ProtectionAuthSettingsForm.tsx@@ -0,0 +1,233 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'+import { Eye, EyeOff } from 'lucide-react'+import { useEffect, useState } from 'react'+import { toast } from 'sonner'+import { boolean, number, object, string } from 'yup'++import { useParams } from 'common'+import { FormActions } from 'components/ui/Forms/FormActions'+import { FormPanel } from 'components/ui/Forms/FormPanel'+import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'+import NoPermission from 'components/ui/NoPermission'+import { useAuthConfigQuery } from 'data/auth/auth-config-query'+import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'+import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'+import { IS_PLATFORM } from 'lib/constants'+import {+ AlertDescription_Shadcn_,+ AlertTitle_Shadcn_,+ Alert_Shadcn_,+ Button,+ Form,+ Input,+ Toggle,+ WarningIcon,+} from 'ui'+import FormField from '../AuthProvidersForm/FormField'+import { FormHeader } from 'components/ui/Forms/FormHeader'++// Use a const string to represent no chars option. Represented as empty string on the backend side.+const NO_REQUIRED_CHARACTERS = 'NO_REQUIRED_CHARS'++const schema = object({+ DISABLE_SIGNUP: boolean().required(),+ EXTERNAL_ANONYMOUS_USERS_ENABLED: boolean().required(),+ SECURITY_MANUAL_LINKING_ENABLED: boolean().required(),+ SITE_URL: string().required('Must have a Site URL'),+ SECURITY_CAPTCHA_ENABLED: boolean().required(),+ SECURITY_CAPTCHA_SECRET: string().when('SECURITY_CAPTCHA_ENABLED', {+ is: true,+ then: (schema) => schema.required('Must have a Captcha secret'),+ }),+ SECURITY_CAPTCHA_PROVIDER: string().when('SECURITY_CAPTCHA_ENABLED', {+ is: true,+ then: (schema) =>+ schema+ .oneOf(['hcaptcha', 'turnstile'])+ .required('Captcha provider must be either hcaptcha or turnstile'),+ }),+ SESSIONS_TIMEBOX: number().min(0, 'Must be a positive number'),+ SESSIONS_INACTIVITY_TIMEOUT: number().min(0, 'Must be a positive number'),+ SESSIONS_SINGLE_PER_USER: boolean(),+ PASSWORD_MIN_LENGTH: number().min(6, 'Must be greater or equal to 6.'),+ PASSWORD_REQUIRED_CHARACTERS: string(),+ PASSWORD_HIBP_ENABLED: boolean(),+})++const formId = 'auth-config-protection-settings'++const ProtectionAuthSettingsForm = () => {+ const { ref: projectRef } = useParams()+ const {+ data: authConfig,+ error: authConfigError,+ isLoading,+ isError,+ isSuccess,+ } = useAuthConfigQuery({ projectRef })+ const { mutate: updateAuthConfig, isLoading: isUpdatingConfig } = useAuthConfigUpdateMutation()++ const [hidden, setHidden] = useState(true)+ const canReadConfig = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')+ const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue')++ const INITIAL_VALUES = {+ DISABLE_SIGNUP: !authConfig?.DISABLE_SIGNUP,+ EXTERNAL_ANONYMOUS_USERS_ENABLED: authConfig?.EXTERNAL_ANONYMOUS_USERS_ENABLED,+ SECURITY_MANUAL_LINKING_ENABLED: authConfig?.SECURITY_MANUAL_LINKING_ENABLED || false,+ SITE_URL: authConfig?.SITE_URL,+ SECURITY_CAPTCHA_ENABLED: authConfig?.SECURITY_CAPTCHA_ENABLED || false,+ SECURITY_CAPTCHA_SECRET: authConfig?.SECURITY_CAPTCHA_SECRET || '',+ SECURITY_CAPTCHA_PROVIDER: authConfig?.SECURITY_CAPTCHA_PROVIDER || 'hcaptcha',+ SESSIONS_TIMEBOX: authConfig?.SESSIONS_TIMEBOX || 0,+ SESSIONS_INACTIVITY_TIMEOUT: authConfig?.SESSIONS_INACTIVITY_TIMEOUT || 0,+ SESSIONS_SINGLE_PER_USER: authConfig?.SESSIONS_SINGLE_PER_USER || false,+ PASSWORD_MIN_LENGTH: authConfig?.PASSWORD_MIN_LENGTH || 6,+ PASSWORD_REQUIRED_CHARACTERS:+ authConfig?.PASSWORD_REQUIRED_CHARACTERS || NO_REQUIRED_CHARACTERS,+ PASSWORD_HIBP_ENABLED: authConfig?.PASSWORD_HIBP_ENABLED || false,+ }++ const onSubmit = (values: any, { resetForm }: any) => {+ const payload = { ...values }+ payload.DISABLE_SIGNUP = !values.DISABLE_SIGNUP+ // The backend uses empty string to represent no required characters in the password+ if (payload.PASSWORD_REQUIRED_CHARACTERS === NO_REQUIRED_CHARACTERS) {+ payload.PASSWORD_REQUIRED_CHARACTERS = ''+ }++ updateAuthConfig(+ { projectRef: projectRef!, config: payload },+ {+ onError: (error) => {+ toast.error(`Failed to update settings: ${error?.message}`)+ },+ onSuccess: () => {+ toast.success(`Successfully updated settings`)+ resetForm({ values: values, initialValues: values })+ },+ }+ )+ }++ if (isError) {+ return (+ <Alert_Shadcn_ variant="destructive">+ <WarningIcon />+ <AlertTitle_Shadcn_>Failed to retrieve auth configuration</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>{authConfigError.message}</AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ )+ }++ if (!canReadConfig) {+ return <NoPermission resourceText="view auth configuration settings" />+ }++ return (+ <div>+ <FormHeader+ title="Bot and Abuse Protection"+ description="Configure protection settings for your application."+ />++ <Form+ id={formId}+ initialValues={INITIAL_VALUES}+ onSubmit={onSubmit}+ validationSchema={schema}+ >+ {({ handleReset, resetForm, values, initialValues, setFieldValue }: any) => {+ const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ // Form is reset once remote data is loaded in store+ // eslint-disable-next-line react-hooks/rules-of-hooks+ useEffect(() => {+ if (isSuccess) resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })+ }, [isSuccess])++ return (+ <>+ <FormPanel+ disabled={true}+ footer={+ <div className="flex py-4 px-8">+ <FormActions+ form={formId}+ isSubmitting={isUpdatingConfig}+ hasChanges={hasChanges}+ handleReset={handleReset}+ disabled={!canUpdateConfig}+ helper={+ !canUpdateConfig+ ? 'You need additional permissions to update authentication settings'+ : undefined+ }+ />+ </div>+ }+ >+ <FormSection header={<FormSectionLabel>Bot and Abuse Protection</FormSectionLabel>}>+ <FormSectionContent loading={isLoading}>+ <Toggle+ id="SECURITY_CAPTCHA_ENABLED"+ size="small"+ label="Enable Captcha protection"+ layout="flex"+ descriptionText="Protect authentication endpoints from bots and abuse."+ disabled={!canUpdateConfig}+ />+ {values.SECURITY_CAPTCHA_ENABLED && (+ <>+ <FormField+ name="SECURITY_CAPTCHA_PROVIDER"+ properties={{+ type: 'select',+ title: 'Choose Captcha Provider',+ description: '',+ enum: [+ {+ label: 'hCaptcha',+ value: 'hcaptcha',+ icon: 'hcaptcha-icon.png',+ },+ {+ label: 'Turnstile by Cloudflare',+ value: 'turnstile',+ icon: 'cloudflare-icon.png',+ },+ ],+ }}+ formValues={values}+ setFieldValue={setFieldValue}+ />+ <Input+ id="SECURITY_CAPTCHA_SECRET"+ type={hidden ? 'password' : 'text'}+ size="small"+ label="Captcha secret"+ descriptionText="Obtain this secret from the provider."+ disabled={!canUpdateConfig}+ actions={+ <Button+ icon={hidden ? <Eye /> : <EyeOff />}+ type="default"+ onClick={() => setHidden(!hidden)}+ />+ }+ />+ </>+ )}+ </FormSectionContent>+ </FormSection>+ </FormPanel>+ </>+ )+ }}+ </Form>+ </div>+ )+}++export default ProtectionAuthSettingsFormdiff --git a/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx b/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsxindex bbb3210480f..eb22382e5e5 100644--- a/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx+++ b/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx@@ -129,12 +129,6 @@ const RateLimits = () => {return (<div>- <FormHeader- title="Rate Limits"- description="Safeguard against bursts of incoming traffic to prevent abuse and maximize stability"- docsUrl="https://supabase.com/docs/guides/platform/going-into-prod#rate-limiting-resource-allocation--abuse-prevention"- />-{isError && <AlertError subject="Failed to retrieve auth config rate limits" error={error} />}{isLoading && <GenericSkeletonLoader />}diff --git a/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsxnew file mode 100644index 00000000000..d7c7a9dbf20--- /dev/null+++ b/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx@@ -0,0 +1,218 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'+import { useEffect } from 'react'+import { toast } from 'sonner'+import { boolean, number, object } from 'yup'++import { useParams } from 'common'+import { FormActions } from 'components/ui/Forms/FormActions'+import { FormHeader } from 'components/ui/Forms/FormHeader'+import { FormPanel } from 'components/ui/Forms/FormPanel'+import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'+import NoPermission from 'components/ui/NoPermission'+import UpgradeToPro from 'components/ui/UpgradeToPro'+import { useAuthConfigQuery } from 'data/auth/auth-config-query'+import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'+import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'+import { IS_PLATFORM } from 'lib/constants'++import {+ AlertDescription_Shadcn_,+ AlertTitle_Shadcn_,+ Alert_Shadcn_,+ Form,+ InputNumber,+ Toggle,+ WarningIcon,+} from 'ui'++function HoursOrNeverText({ value }: { value: number }) {+ if (value === 0) {+ return 'never'+ } else if (value === 1) {+ return 'hour'+ } else {+ return 'hours'+ }+}++const schema = object({+ REFRESH_TOKEN_ROTATION_ENABLED: boolean().required(),+ SECURITY_REFRESH_TOKEN_REUSE_INTERVAL: number()+ .min(0, 'Must be a value more than 0')+ .required('Must have a Reuse Interval value'),+ SESSIONS_TIMEBOX: number().min(0, 'Must be a positive number'),+ SESSIONS_INACTIVITY_TIMEOUT: number().min(0, 'Must be a positive number'),+ SESSIONS_SINGLE_PER_USER: boolean(),+})++const SessionsAuthSettingsForm = () => {+ const { ref: projectRef } = useParams()+ const {+ data: authConfig,+ error: authConfigError,+ isLoading,+ isError,+ isSuccess,+ } = useAuthConfigQuery({ projectRef })+ const { mutate: updateAuthConfig, isLoading: isUpdatingConfig } = useAuthConfigUpdateMutation()++ const formId = 'auth-config-sessions-form'+ const canReadConfig = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')+ const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue')++ const organization = useSelectedOrganization()+ const { data: subscription, isSuccess: isSuccessSubscription } = useOrgSubscriptionQuery({+ orgSlug: organization?.slug,+ })++ const isProPlanAndUp = isSuccessSubscription && subscription?.plan?.id !== 'free'+ const promptProPlanUpgrade = IS_PLATFORM && !isProPlanAndUp++ const INITIAL_VALUES = {+ REFRESH_TOKEN_ROTATION_ENABLED: authConfig?.REFRESH_TOKEN_ROTATION_ENABLED || false,+ SECURITY_REFRESH_TOKEN_REUSE_INTERVAL: authConfig?.SECURITY_REFRESH_TOKEN_REUSE_INTERVAL,+ SESSIONS_TIMEBOX: authConfig?.SESSIONS_TIMEBOX || 0,+ SESSIONS_INACTIVITY_TIMEOUT: authConfig?.SESSIONS_INACTIVITY_TIMEOUT || 0,+ SESSIONS_SINGLE_PER_USER: authConfig?.SESSIONS_SINGLE_PER_USER || false,+ }++ const onSubmit = (values: any, { resetForm }: any) => {+ const payload = { ...values }++ updateAuthConfig(+ { projectRef: projectRef!, config: payload },+ {+ onError: (error) => {+ toast.error(`Failed to update settings: ${error?.message}`)+ },+ onSuccess: () => {+ toast.success('Successfully updated settings')+ resetForm({ values: values, initialValues: values })+ },+ }+ )+ }++ if (isError) {+ return (+ <Alert_Shadcn_ variant="destructive">+ <WarningIcon />+ <AlertTitle_Shadcn_>Failed to retrieve auth configuration</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>{authConfigError.message}</AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ )+ }++ if (!canReadConfig) {+ return <NoPermission resourceText="view auth configuration settings" />+ }++ return (+ <Form id={formId} initialValues={INITIAL_VALUES} onSubmit={onSubmit} validationSchema={schema}>+ {({ handleReset, resetForm, values, initialValues }: any) => {+ const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)++ // Form is reset once remote data is loaded in store+ // eslint-disable-next-line react-hooks/rules-of-hooks+ useEffect(() => {+ if (isSuccess) resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })+ }, [isSuccess])++ return (+ <>+ <FormPanel+ disabled={true}+ footer={+ <div className="flex py-4 px-8">+ <FormActions+ form={formId}+ isSubmitting={isUpdatingConfig}+ hasChanges={hasChanges}+ handleReset={handleReset}+ disabled={!canUpdateConfig}+ helper={+ !canUpdateConfig+ ? 'You need additional permissions to update authentication settings'+ : undefined+ }+ />+ </div>+ }+ >+ <FormSection header={<FormSectionLabel>Refresh Tokens</FormSectionLabel>}>+ <FormSectionContent loading={isLoading}>+ <Toggle+ id="REFRESH_TOKEN_ROTATION_ENABLED"+ size="small"+ label="Detect and revoke potentially compromised refresh tokens"+ layout="flex"+ descriptionText="Prevent replay attacks from potentially compromised refresh tokens."+ disabled={!canUpdateConfig}+ />+ {values.REFRESH_TOKEN_ROTATION_ENABLED && (+ <InputNumber+ id="SECURITY_REFRESH_TOKEN_REUSE_INTERVAL"+ size="small"+ min={0}+ label="Refresh token reuse interval"+ descriptionText="Time interval where the same refresh token can be used multiple times to request for an access token. Recommendation: 10 seconds."+ actions={<span className="mr-3 text-foreground-lighter">seconds</span>}+ disabled={!canUpdateConfig}+ />+ )}+ </FormSectionContent>+ </FormSection>++ <FormSection header={<FormSectionLabel>User Sessions</FormSectionLabel>}>+ <FormSectionContent loading={isLoading}>+ {promptProPlanUpgrade && (+ <UpgradeToPro+ primaryText="Upgrade to Pro"+ secondaryText="Configuring user sessions requires the Pro Plan."+ />+ )}+ <Toggle+ id="SESSIONS_SINGLE_PER_USER"+ size="small"+ label="Enforce single session per user"+ layout="flex"+ descriptionText="If enabled, all but a user's most recently active session will be terminated."+ disabled={!canUpdateConfig || !isProPlanAndUp}+ />+ <InputNumber+ id="SESSIONS_TIMEBOX"+ size="small"+ label="Time-box user sessions"+ descriptionText="The amount of time before a user is forced to sign in again. Use 0 for never"+ actions={+ <span className="mr-3 text-foreground-lighter">+ <HoursOrNeverText value={values.SESSIONS_TIMEBOX} />+ </span>+ }+ disabled={!canUpdateConfig || !isProPlanAndUp}+ />+ <InputNumber+ id="SESSIONS_INACTIVITY_TIMEOUT"+ size="small"+ label="Inactivity timeout"+ descriptionText="The amount of time a user needs to be inactive to be forced to sign in again. Use 0 for never."+ actions={+ <span className="mr-3 text-foreground-lighter">+ <HoursOrNeverText value={values.SESSIONS_INACTIVITY_TIMEOUT} />+ </span>+ }+ disabled={!canUpdateConfig || !isProPlanAndUp}+ />+ </FormSectionContent>+ </FormSection>+ </FormPanel>+ </>+ )+ }}+ </Form>+ )+}++export default SessionsAuthSettingsFormdiff --git a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsxindex 91dac8155f2..f099a80fa74 100644--- a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx+++ b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx@@ -185,10 +185,6 @@ const SmtpForm = () => {return (<>- <FormHeader- title="SMTP Settings"- description="You can use your own SMTP server instead of the built-in email service."- /><FormPanelfooter={<div className="flex py-4 px-8">@@ -232,22 +228,16 @@ const SmtpForm = () => {</p>}/>- {enableSmtp ? (- !isValidSmtpConfig && (- <div className="">- <Alert_Shadcn_ variant="warning">- <AlertTriangle strokeWidth={2} />- <AlertTitle_Shadcn_>All fields below must be filled</AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- The following fields must be filled before custom SMTP can be properly- enabled- </AlertDescription_Shadcn_>- </Alert_Shadcn_>- </div>- )- ) : (+ {enableSmtp && !isValidSmtpConfig && !isValidSmtpConfig && (<div className="">- <EmailRateLimitsAlert />+ <Alert_Shadcn_ variant="warning">+ <AlertTriangle strokeWidth={2} />+ <AlertTitle_Shadcn_>All fields below must be filled</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ The following fields must be filled before custom SMTP can be properly+ enabled+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_></div>)}</FormSectionContent>diff --git a/apps/studio/components/interfaces/Auth/index.tsx b/apps/studio/components/interfaces/Auth/index.tsxindex 1c63343165a..0e4fe8f9d3e 100644--- a/apps/studio/components/interfaces/Auth/index.tsx+++ b/apps/studio/components/interfaces/Auth/index.tsx@@ -2,5 +2,8 @@ export { default as AdvancedAuthSettingsForm } from './AdvancedAuthSettingsForm/export { default as AuthProvidersForm } from './AuthProvidersForm/AuthProvidersForm'export { default as BasicAuthSettingsForm } from './BasicAuthSettingsForm/BasicAuthSettingsForm'export { default as EmailTemplates } from './EmailTemplates/EmailTemplates'+export { default as MfaAuthSettingsForm } from './MfaAuthSettingsForm/MfaAuthSettingsForm'+export { default as SessionsAuthSettingsForm } from './SessionsAuthSettingsForm/SessionsAuthSettingsForm'+export { default as ProtectionAuthSettingsForm } from './ProtectionAuthSettingsForm/ProtectionAuthSettingsForm'export { default as SmtpForm } from './SmtpForm/SmtpForm'export { ThirdPartyAuthForm } from './ThirdPartyAuthForm'diff --git a/apps/studio/components/interfaces/Settings/API/JWTSettings.tsx b/apps/studio/components/interfaces/Settings/API/JWTSettings.tsxindex e73f464d5f7..deafd573c5e 100644--- a/apps/studio/components/interfaces/Settings/API/JWTSettings.tsx+++ b/apps/studio/components/interfaces/Settings/API/JWTSettings.tsx@@ -16,6 +16,7 @@ import {} from 'lucide-react'import { Dispatch, SetStateAction, useState } from 'react'import { toast } from 'sonner'+import { number, object } from 'yup'import { useParams } from 'common'import { ButtonTooltip } from 'components/ui/ButtonTooltip'@@ -23,6 +24,8 @@ import Panel from 'components/ui/Panel'import { useJwtSecretUpdateMutation } from 'data/config/jwt-secret-update-mutation'import { useJwtSecretUpdatingStatusQuery } from 'data/config/jwt-secret-updating-status-query'import { useProjectPostgrestConfigQuery } from 'data/config/project-postgrest-config-query'+import { useAuthConfigQuery } from 'data/auth/auth-config-query'+import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'import { uuidv4 } from 'lib/helpers'import {@@ -36,8 +39,10 @@ import {DropdownMenuSeparator,DropdownMenuTrigger,Input,+ InputNumber,Modal,WarningIcon,+ Form,} from 'ui'import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'import {@@ -45,6 +50,15 @@ import {JWT_SECRET_UPDATE_PROGRESS_MESSAGES,} from './API.constants'import { Admonition } from 'ui-patterns'+import { FormActions } from 'components/ui/Forms/FormActions'+import { FormPanel } from 'components/ui/Forms/FormPanel'+import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'++const schema = object({+ JWT_EXP: number()+ .max(604800, 'Must be less than 604800')+ .required('Must have a JWT expiry value'),+})const JWTSettings = () => {const { ref: projectRef } = useParams()@@ -59,12 +73,22 @@ const JWTSettings = () => {PermissionAction.INFRA_EXECUTE,'queue_job.projects.update_jwt')+ const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue')const { data } = useJwtSecretUpdatingStatusQuery({ projectRef })const { data: config, isError } = useProjectPostgrestConfigQuery({ projectRef })const { mutateAsync: updateJwt, isLoading: isSubmittingJwtSecretUpdateRequest } =useJwtSecretUpdateMutation()+ const {+ data: authConfig,+ error: authConfigError,+ isLoading: isLoadingAuthConfig,+ isSuccess: isSuccessAuthConfig,+ } = useAuthConfigQuery({ projectRef })+ const { mutate: updateAuthConfig, isLoading: isUpdatingAuthConfig } =+ useAuthConfigUpdateMutation()+const { Failed, Updated, Updating } = JwtSecretUpdateStatusconst isJwtSecretUpdateFailed = data?.jwtSecretUpdateStatus === Failed@@ -76,6 +100,27 @@ const JWTSettings = () => {const jwtSecretUpdateProgressMessage =JWT_SECRET_UPDATE_PROGRESS_MESSAGES[data?.jwtSecretUpdateProgress as JwtSecretUpdateProgress]+ const INITIAL_VALUES = {+ JWT_EXP: authConfig?.JWT_EXP ?? 3600,+ }++ const onUpdateJwtExp = async (values: any, { resetForm }: any) => {+ if (!projectRef) return console.error('Project ref is required')++ updateAuthConfig(+ { projectRef, config: values },+ {+ onError: (error) => {+ toast.error(`Failed to update JWT expiry: ${error?.message}`)+ },+ onSuccess: () => {+ toast.success('Successfully updated JWT expiry')+ resetForm({ values, initialValues: values })+ },+ }+ )+ }+async function handleJwtSecretUpdate(jwt_secret: string,setModalVisibility: Dispatch<SetStateAction<boolean>>@@ -93,117 +138,161 @@ const JWTSettings = () => {return (<>- <Panel title={<h5 className="mb-0">JWT Settings</h5>}>- <Panel.Content className="space-y-6 border-t border-panel-border-interior-light [[data-theme*=dark]_&]:border-panel-border-interior-dark">- {isError ? (- <div className="flex items-center justify-center py-8 space-x-2">- <AlertCircle size={16} strokeWidth={1.5} />- <p className="text-sm text-foreground-light">Failed to retrieve JWT settings</p>- </div>- ) : (- <>- <Input- label="JWT Secret"- readOnly- copy={canReadJWTSecret && isNotUpdatingJwtSecret}- reveal={canReadJWTSecret && isNotUpdatingJwtSecret}- disabled- value={- !canReadJWTSecret- ? 'You need additional permissions to view the JWT secret'- : isJwtSecretUpdateFailed- ? 'JWT secret update failed'- : isUpdatingJwtSecret- ? 'Updating JWT secret...'- : config?.jwt_secret || ''- }- className="input-mono"- descriptionText={- 'Used to decode your JWTs. You can also use this to mint your own JWTs.'- }- layout="horizontal"- />- <div className="space-y-3">- <div className="p-3 px-6 border rounded-md shadow-sm bg-studio">- {isUpdatingJwtSecret ? (- <div className="flex items-center space-x-2">- <Loader2 className="animate-spin" size={14} />- <p className="text-sm">- Updating JWT secret: {jwtSecretUpdateProgressMessage}- </p>- </div>- ) : (- <div className="w-full space-y-2">- <div className="flex items-center justify-between w-full">- <div className="flex flex-col space-y-1">- <p className="text-sm">Generate a new JWT secret</p>- <p className="text-sm opacity-50">- A random secret will be created, or you can create your own.- </p>- </div>- <div className="flex flex-col items-end">- {isUpdatingJwtSecret ? (- <Button loading type="secondary">- Updating JWT secret...- </Button>- ) : !canGenerateNewJWTSecret ? (- <ButtonTooltip- disabled- type="default"- iconRight={<ChevronDown size={14} />}- tooltip={{- content: {- side: 'bottom',- text: 'You need additional permissions to generate a new JWT secret',- },- }}- >- Generate a new secret- </ButtonTooltip>- ) : (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button type="default" iconRight={<ChevronDown size={14} />}>- <span>Generate a new secret</span>- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end" side="bottom">- <DropdownMenuItem- className="space-x-2"- onClick={() => setIsGeneratingKey(true)}- >- <RefreshCw size={16} />- <p>Generate a random secret</p>- </DropdownMenuItem>- <DropdownMenuSeparator />- <DropdownMenuItem- className="space-x-2"- onClick={() => setIsCreatingKey(true)}- >- <PenTool size={16} />- <p>Create my own secret</p>- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- )}- </div>+ <Form+ id="jwt-exp-form"+ initialValues={INITIAL_VALUES}+ onSubmit={onUpdateJwtExp}+ validationSchema={schema}+ key={authConfig?.JWT_EXP}+ >+ {({ handleReset, values, initialValues }: any) => {+ const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)++ return (+ <Panel+ title={<h5 className="mb-0">JWT Settings</h5>}+ footer={+ <div className="flex py-4 w-full">+ <FormActions+ form="jwt-exp-form"+ isSubmitting={isUpdatingAuthConfig}+ hasChanges={hasChanges}+ handleReset={handleReset}+ disabled={!canUpdateConfig}+ helper={+ !canUpdateConfig+ ? 'You need additional permissions to update JWT settings'+ : undefined+ }+ />+ </div>+ }+ >+ <Panel.Content className="space-y-6 border-t border-panel-border-interior-light [[data-theme*=dark]_&]:border-panel-border-interior-dark">+ {isError ? (+ <div className="flex items-center justify-center py-8 space-x-2">+ <AlertCircle size={16} strokeWidth={1.5} />+ <p className="text-sm text-foreground-light">Failed to retrieve JWT settings</p>+ </div>+ ) : (+ <>+ <Input+ label="JWT Secret"+ readOnly+ copy={canReadJWTSecret && isNotUpdatingJwtSecret}+ reveal={canReadJWTSecret && isNotUpdatingJwtSecret}+ disabled+ value={+ !canReadJWTSecret+ ? 'You need additional permissions to view the JWT secret'+ : isJwtSecretUpdateFailed+ ? 'JWT secret update failed'+ : isUpdatingJwtSecret+ ? 'Updating JWT secret...'+ : config?.jwt_secret || ''+ }+ className="input-mono"+ descriptionText={+ 'Used to decode your JWTs. You can also use this to mint your own JWTs.'+ }+ layout="horizontal"+ />++ <InputNumber+ id="JWT_EXP"+ name="JWT_EXP"+ size="small"+ label="Access token expiry time"+ descriptionText="How long access tokens are valid for before a refresh token has to be used. Recommendation: 3600 (1 hour)."+ layout="horizontal"+ actions={<span className="mr-3 text-foreground-lighter">seconds</span>}+ disabled={!canUpdateConfig || isLoadingAuthConfig}+ />++ <div className="space-y-3">+ <div className="p-3 px-6 border rounded-md shadow-sm bg-studio">+ {isUpdatingJwtSecret ? (+ <div className="flex items-center space-x-2">+ <Loader2 className="animate-spin" size={14} />+ <p className="text-sm">+ Updating JWT secret: {jwtSecretUpdateProgressMessage}+ </p>+ </div>+ ) : (+ <div className="w-full space-y-2">+ <div className="flex items-center justify-between w-full">+ <div className="flex flex-col space-y-1">+ <p className="text-sm">Generate a new JWT secret</p>+ <p className="text-sm opacity-50">+ A random secret will be created, or you can create your own.+ </p>+ </div>+ <div className="flex flex-col items-end">+ {isUpdatingJwtSecret ? (+ <Button loading type="secondary">+ Updating JWT secret...+ </Button>+ ) : !canGenerateNewJWTSecret ? (+ <ButtonTooltip+ disabled+ type="default"+ iconRight={<ChevronDown size={14} />}+ tooltip={{+ content: {+ side: 'bottom',+ text: 'You need additional permissions to generate a new JWT secret',+ },+ }}+ >+ Generate a new secret+ </ButtonTooltip>+ ) : (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button type="default" iconRight={<ChevronDown size={14} />}>+ <span>Generate a new secret</span>+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" side="bottom">+ <DropdownMenuItem+ className="space-x-2"+ onClick={() => setIsGeneratingKey(true)}+ >+ <RefreshCw size={16} />+ <p>Generate a random secret</p>+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ className="space-x-2"+ onClick={() => setIsCreatingKey(true)}+ >+ <PenTool size={16} />+ <p>Create my own secret</p>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ </div>+ </div>+ </div>+ )}</div>+ {isJwtSecretUpdateFailed ? (+ <Admonition type="warning" title="Failed to update JWT secret">+ Please try again. If the failures persist, please contact Supabase support+ with the following details: <br />+ Change tracking ID: {data?.changeTrackingId} <br />+ Error message: {jwtSecretUpdateErrorMessage}+ </Admonition>+ ) : null}</div>- )}- </div>- {isJwtSecretUpdateFailed ? (- <Admonition type="warning" title="Failed to update JWT secret">- Please try again. If the failures persist, please contact Supabase support with- the following details: <br />- Change tracking ID: {data?.changeTrackingId} <br />- Error message: {jwtSecretUpdateErrorMessage}- </Admonition>- ) : null}- </div>- </>- )}- </Panel.Content>- </Panel>+ </>+ )}+ </Panel.Content>+ </Panel>+ )+ }}+ </Form><ConfirmationModalvariant={'destructive'}diff --git a/apps/studio/components/interfaces/Settings/API/ServiceList.tsx b/apps/studio/components/interfaces/Settings/API/ServiceList.tsxindex ae1f0c621c3..71ba7a2e70a 100644--- a/apps/studio/components/interfaces/Settings/API/ServiceList.tsx+++ b/apps/studio/components/interfaces/Settings/API/ServiceList.tsx@@ -147,7 +147,7 @@ const ServiceList = () => {<DisplayApiSettings key="DisplayAPISettings" /></section>- <section>+ <section id="jwt-settings"><JWTSettings /></section>diff --git a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsxindex a5b6073f66d..379691b2bab 100644--- a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx+++ b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx@@ -13,6 +13,7 @@ import { DocsButton } from 'components/ui/DocsButton'import { FormActions } from 'components/ui/Forms/FormActions'import Panel from 'components/ui/Panel'import ShimmeringLoader from 'components/ui/ShimmeringLoader'+import UpgradeToPro from 'components/ui/UpgradeToPro'import { useMaxConnectionsQuery } from 'data/database/max-connections-query'import { usePoolingConfigurationQuery } from 'data/database/pooling-configuration-query'import { usePoolingConfigurationUpdateMutation } from 'data/database/pooling-configuration-update-mutation'@@ -37,6 +38,11 @@ import {} from 'ui'import { SESSION_MODE_DESCRIPTION, TRANSACTION_MODE_DESCRIPTION } from '../Database.constants'import { POOLING_OPTIMIZATIONS } from './ConnectionPooling.constants'+import { useAuthConfigQuery } from 'data/auth/auth-config-query'+import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'+import { IS_PLATFORM } from 'lib/constants'const formId = 'connection-pooling-form'@@ -58,12 +64,21 @@ const FormSchema = z.object({default_pool_size: StringToPositiveNumber,pool_mode: z.union([z.literal('transaction'), z.literal('session')]),max_client_conn: StringToPositiveNumber,+ DB_MAX_POOL_SIZE: StringToPositiveNumber,})export const ConnectionPooling = () => {const { ref: projectRef } = useParams()const { project } = useProjectContext()const snap = useDatabaseSettingsStateSnapshot()+ 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 && !isTeamsEnterprisePlanconst { data: addons } = useProjectAddonsQuery({ projectRef })const computeInstance = addons?.selected_addons.find((addon) => addon.type === 'compute_instance')@@ -85,6 +100,8 @@ export const ConnectionPooling = () => {isSuccess,} = usePoolingConfigurationQuery({ projectRef: projectRef })+ const { data: authConfig } = useAuthConfigQuery({ projectRef })+const { data: maxConnData } = useMaxConnectionsQuery({projectRef: project?.ref,connectionString: project?.connectionString,@@ -103,12 +120,15 @@ export const ConnectionPooling = () => {})+ const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue')+const form = useForm<z.infer<typeof FormSchema>>({resolver: zodResolver(FormSchema),defaultValues: {pool_mode: poolingConfiguration?.pool_mode as 'transaction' | 'session',default_pool_size: poolingConfiguration?.default_pool_size as number | undefined,max_client_conn: poolingConfiguration?.max_client_conn as number | undefined,+ DB_MAX_POOL_SIZE: authConfig?.DB_MAX_POOL_SIZE ?? null,},})@@ -120,12 +140,15 @@ export const ConnectionPooling = () => {pool_mode: data.pool_mode,default_pool_size: data.default_pool_size,max_client_conn: poolingConfiguration?.max_client_conn,+ DB_MAX_POOL_SIZE: authConfig?.DB_MAX_POOL_SIZE ?? null,})}toast.success('Successfully saved settings')},})+ const { mutate: updateAuthConfig } = useAuthConfigUpdateMutation()+const onSubmit: SubmitHandler<z.infer<typeof FormSchema>> = async (data) => {if (!projectRef) return console.error('Project ref is required')if (!poolingInfo) return console.error('Pooling info required')@@ -135,6 +158,20 @@ export const ConnectionPooling = () => {default_pool_size: data.default_pool_size as number | undefined,pool_mode: data.pool_mode,})++ if (data.DB_MAX_POOL_SIZE !== authConfig?.DB_MAX_POOL_SIZE) {+ updateAuthConfig(+ { projectRef, config: { DB_MAX_POOL_SIZE: data.DB_MAX_POOL_SIZE ?? undefined } },+ {+ onError: (error: Error) => {+ toast.error(`Failed to update auth max direct connections: ${error?.message}`)+ },+ onSuccess: () => {+ toast.success('Successfully updated auth max direct connections')+ },+ }+ )+ }}useEffect(() => {@@ -143,9 +180,10 @@ export const ConnectionPooling = () => {pool_mode: poolingConfiguration?.pool_mode as 'transaction' | 'session',default_pool_size: poolingConfiguration?.default_pool_size as number | undefined,max_client_conn: poolingConfiguration?.max_client_conn as number | undefined,+ DB_MAX_POOL_SIZE: authConfig?.DB_MAX_POOL_SIZE ?? null,})}- }, [isSuccess])+ }, [isSuccess, authConfig])return (<section id="connection-pooler">@@ -397,6 +435,45 @@ export const ConnectionPooling = () => {</FormItem_Shadcn_>)}/>+ <FormField_Shadcn_+ control={form.control}+ name="DB_MAX_POOL_SIZE"+ render={({ field }) => (+ <FormItem_Shadcn_ className="grid gap-2 md:grid md:grid-cols-12 space-y-0">+ <FormLabel_Shadcn_ className="col-span-4 text-sm text-foreground-light">+ Max Direct Auth Connections+ </FormLabel_Shadcn_>+ <div className="col-span-8 space-y-2">+ {promptTeamsEnterpriseUpgrade && (+ <div className="mb-4">+ <UpgradeToPro+ primaryText="Upgrade to Team or Enterprise"+ secondaryText="Max Direct Auth Connections settings are only available on the Team Plan and up."+ buttonText="Upgrade to Team"+ />+ </div>+ )}+ <FormControl_Shadcn_ className="col-span-8">+ <Input_Shadcn_+ {...field}+ type="number"+ className="w-full"+ value={field.value || undefined}+ placeholder={field.value === null ? '10' : ''}+ disabled={!canUpdateConfig || isTeamsEnterprisePlan}+ />+ </FormControl_Shadcn_>+ <FormDescription_Shadcn_>+ 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. Defaults to 10+ connections.+ </FormDescription_Shadcn_>+ <FormMessage_Shadcn_ />+ </div>+ </FormItem_Shadcn_>+ )}+ /></form></Form_Shadcn_><div className="border-muted border-t"></div>diff --git a/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts b/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.tsindex 731fba6a04a..5619301379f 100644--- a/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts+++ b/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts@@ -19,11 +19,18 @@ export const generateAuthMenu = (ref: string): ProductMenuGroup[] => {...(IS_PLATFORM? [{- name: 'Providers',- key: 'providers',+ name: 'Sign In / Up',+ key: 'sign-in-up',+ pages: ['providers', 'third-party'],url: `/project/${ref}/auth/providers`,items: [],},+ {+ name: 'Sessions',+ key: 'sessions',+ url: `/project/${ref}/auth/sessions`,+ items: [],+ },{name: 'Rate Limits',key: 'rate-limits',@@ -31,11 +38,18 @@ export const generateAuthMenu = (ref: string): ProductMenuGroup[] => {items: [],},{- name: 'Email Templates',- key: 'templates',+ name: 'Emails',+ key: 'emails',+ pages: ['templates', 'smtp'],url: `/project/${ref}/auth/templates`,items: [],},+ {+ name: 'Multi-Factor',+ key: 'mfa',+ url: `/project/${ref}/auth/mfa`,+ items: [],+ },{name: 'URL Configuration',key: 'url-configuration',@@ -43,12 +57,24 @@ export const generateAuthMenu = (ref: string): ProductMenuGroup[] => {items: [],},{- name: 'Hooks',+ name: 'Attack Protection',+ key: 'protection',+ url: `/project/${ref}/auth/protection`,+ items: [],+ },+ {+ name: 'Auth Hooks',key: 'hooks',url: `/project/${ref}/auth/hooks`,items: [],label: 'BETA',},+ {+ name: 'Advanced',+ key: 'advanced',+ url: `/project/${ref}/auth/advanced`,+ items: [],+ },]: []),],diff --git a/apps/studio/components/ui/ProductMenu/ProductMenu.tsx b/apps/studio/components/ui/ProductMenu/ProductMenu.tsxindex 798118f10c3..67cc2c49e39 100644--- a/apps/studio/components/ui/ProductMenu/ProductMenu.tsx+++ b/apps/studio/components/ui/ProductMenu/ProductMenu.tsx@@ -27,19 +27,25 @@ const ProductMenu = ({ page, menu }: ProductMenuProps) => {}/><div>- {group.items.map((item) => (- <ProductMenuItem- key={item.key}- url={item.url}- name={item.name}- icon={item.icon}- rightIcon={item.rightIcon}- isActive={page === item.key}- isExternal={item.isExternal}- target={item.isExternal ? '_blank' : '_self'}- label={item.label}- />- ))}+ {group.items.map((item) => {+ const isActive = !!item.pages+ ? item.pages.includes(page ?? '')+ : page === item.key++ return (+ <ProductMenuItem+ key={item.key}+ url={item.url}+ name={item.name}+ icon={item.icon}+ rightIcon={item.rightIcon}+ isActive={isActive}+ isExternal={item.isExternal}+ target={item.isExternal ? '_blank' : '_self'}+ label={item.label}+ />+ )+ })}</div></div></div>diff --git a/apps/studio/components/ui/ProductMenu/ProductMenu.types.ts b/apps/studio/components/ui/ProductMenu/ProductMenu.types.tsindex d0a6d31523b..3bfb2cb77f9 100644--- a/apps/studio/components/ui/ProductMenu/ProductMenu.types.ts+++ b/apps/studio/components/ui/ProductMenu/ProductMenu.types.ts@@ -17,4 +17,5 @@ export interface ProductMenuGroupItem {isExternal?: booleandisabled?: booleanlabel?: string+ pages?: string[]}diff --git a/apps/studio/pages/project/[ref]/auth/advanced.tsx b/apps/studio/pages/project/[ref]/auth/advanced.tsxnew file mode 100644index 00000000000..a270d960910--- /dev/null+++ b/apps/studio/pages/project/[ref]/auth/advanced.tsx@@ -0,0 +1,46 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'++import { AdvancedAuthSettingsForm, SmtpForm, ThirdPartyAuthForm } from 'components/interfaces/Auth'+import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'+import {+ ScaffoldContainer,+ ScaffoldDescription,+ ScaffoldHeader,+ ScaffoldTitle,+} from 'components/layouts/Scaffold'+import NoPermission from 'components/ui/NoPermission'+import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'+import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'+import type { NextPageWithLayout } from 'types'++const AdvancedAuthSettings: NextPageWithLayout = () => {+ const isPermissionsLoaded = usePermissionsLoaded()+ // TODO: check if these permissions cover third party auth as well+ const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')++ return (+ <>+ <ScaffoldContainer>+ <ScaffoldHeader>+ <ScaffoldTitle>Advanced</ScaffoldTitle>+ </ScaffoldHeader>+ </ScaffoldContainer>+ <ScaffoldContainer className="flex flex-col gap-10" bottomPadding>+ {!isPermissionsLoaded ? (+ <GenericSkeletonLoader />+ ) : !canReadAuthSettings ? (+ <NoPermission isFullPage resourceText="access your project's authentication settings" />+ ) : (+ <>+ <AdvancedAuthSettingsForm />+ </>+ )}+ </ScaffoldContainer>+ </>+ )+}++AdvancedAuthSettings.getLayout = (page) => {+ return <AuthLayout>{page}</AuthLayout>+}+export default AdvancedAuthSettingsdiff --git a/apps/studio/pages/project/[ref]/auth/hooks.tsx b/apps/studio/pages/project/[ref]/auth/hooks.tsxindex 51b3f1f414f..b1cb3e10d0a 100644--- a/apps/studio/pages/project/[ref]/auth/hooks.tsx+++ b/apps/studio/pages/project/[ref]/auth/hooks.tsx@@ -2,7 +2,12 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { HooksListing } from 'components/interfaces/Auth/Hooks/HooksListing'import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'-import { FormsContainer } from 'components/ui/Forms/FormsContainer'+import {+ ScaffoldHeader,+ ScaffoldContainer,+ ScaffoldTitle,+ ScaffoldDescription,+} from 'components/layouts/Scaffold'import NoPermission from 'components/ui/NoPermission'import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'import type { NextPageWithLayout } from 'types'@@ -15,9 +20,21 @@ const Hooks: NextPageWithLayout = () => {return <NoPermission isFullPage resourceText="access your project's auth hooks" />} else {return (- <FormsContainer>- <HooksListing />- </FormsContainer>+ <div>+ <ScaffoldHeader className="pb-0">+ <ScaffoldContainer id="auth-page-top">+ <ScaffoldTitle>Auth Hooks</ScaffoldTitle>+ <ScaffoldDescription>+ Use Postgres functions or HTTP endpoints to customize the behavior of Supabase Auth to+ meet your needs+ </ScaffoldDescription>+ </ScaffoldContainer>+ </ScaffoldHeader>++ <ScaffoldContainer className="my-8 space-y-8">+ <HooksListing />+ </ScaffoldContainer>+ </div>)}}diff --git a/apps/studio/pages/project/[ref]/auth/mfa.tsx b/apps/studio/pages/project/[ref]/auth/mfa.tsxnew file mode 100644index 00000000000..d56932a49a4--- /dev/null+++ b/apps/studio/pages/project/[ref]/auth/mfa.tsx@@ -0,0 +1,49 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'++import { MfaAuthSettingsForm } from 'components/interfaces/Auth'+import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'+import {+ ScaffoldContainer,+ ScaffoldDescription,+ ScaffoldHeader,+ ScaffoldTitle,+} from 'components/layouts/Scaffold'+import NoPermission from 'components/ui/NoPermission'+import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'+import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'+import type { NextPageWithLayout } from 'types'++const AuthSettings: NextPageWithLayout = () => {+ const isPermissionsLoaded = usePermissionsLoaded()+ // TODO: check if these permissions cover third party auth as well+ const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')++ return (+ <>+ <ScaffoldContainer>+ <ScaffoldHeader>+ <ScaffoldTitle>Multi-Factor Authentication (MFA)</ScaffoldTitle>+ <ScaffoldDescription>+ Requires users to provide additional verification factors to authenticate+ </ScaffoldDescription>+ </ScaffoldHeader>+ </ScaffoldContainer>+ <ScaffoldContainer className="flex flex-col gap-10" bottomPadding>+ {!isPermissionsLoaded ? (+ <GenericSkeletonLoader />+ ) : !canReadAuthSettings ? (+ <NoPermission isFullPage resourceText="access your project's authentication settings" />+ ) : (+ <>+ <MfaAuthSettingsForm />+ </>+ )}+ </ScaffoldContainer>+ </>+ )+}++AuthSettings.getLayout = (page) => {+ return <AuthLayout>{page}</AuthLayout>+}+export default AuthSettingsdiff --git a/apps/studio/pages/project/[ref]/auth/protection.tsx b/apps/studio/pages/project/[ref]/auth/protection.tsxnew file mode 100644index 00000000000..e0651326bb3--- /dev/null+++ b/apps/studio/pages/project/[ref]/auth/protection.tsx@@ -0,0 +1,41 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'++import {+ AuthProvidersForm,+ ProtectionAuthSettingsForm,+ ThirdPartyAuthForm,+} from 'components/interfaces/Auth'+import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'+import { ScaffoldHeader, ScaffoldContainer, ScaffoldTitle } from 'components/layouts/Scaffold'+import NoPermission from 'components/ui/NoPermission'+import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'+import type { NextPageWithLayout } from 'types'++const PageLayout: NextPageWithLayout = () => {+ const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')+ const isPermissionsLoaded = usePermissionsLoaded()++ if (isPermissionsLoaded && !canReadAuthSettings) {+ return <NoPermission isFullPage resourceText="access your project's auth provider settings" />+ } else {+ return (+ <div>+ <ScaffoldHeader className="pb-0">+ <ScaffoldContainer id="auth-page-top">+ <ScaffoldTitle>Attack Protection</ScaffoldTitle>+ </ScaffoldContainer>+ </ScaffoldHeader>++ <ScaffoldContainer className="my-8 space-y-8">+ <ProtectionAuthSettingsForm />+ </ScaffoldContainer>+ </div>+ )+ }+}++PageLayout.getLayout = (page) => {+ return <AuthLayout>{page}</AuthLayout>+}++export default PageLayoutdiff --git a/apps/studio/pages/project/[ref]/auth/providers.tsx b/apps/studio/pages/project/[ref]/auth/providers.tsxindex 0d43687ae8e..63b0f7e83fb 100644--- a/apps/studio/pages/project/[ref]/auth/providers.tsx+++ b/apps/studio/pages/project/[ref]/auth/providers.tsx@@ -1,25 +1,72 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-import { AuthProvidersForm } from 'components/interfaces/Auth'+import { AuthProvidersForm, BasicAuthSettingsForm } from 'components/interfaces/Auth'import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'-import { FormsContainer } from 'components/ui/Forms/FormsContainer'-import NoPermission from 'components/ui/NoPermission'import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'+import { useParams } from 'common'+import { useCurrentPath } from 'hooks/misc/useCurrentPath'+import Link from 'next/link'+import { NavMenu, NavMenuItem } from 'ui'+import {+ ScaffoldContainer,+ ScaffoldDescription,+ ScaffoldDivider,+ ScaffoldHeader,+ ScaffoldTitle,+} from 'components/layouts/Scaffold'+import NoPermission from 'components/ui/NoPermission'import type { NextPageWithLayout } from 'types'const PageLayout: NextPageWithLayout = () => {const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')const isPermissionsLoaded = usePermissionsLoaded()+ const { ref } = useParams()+ const currentPath = useCurrentPath()++ const navMenuItems = [+ {+ label: 'Supabase Auth',+ href: `/project/${ref}/auth/providers`,+ },+ {+ label: 'Third Party Auth',+ href: `/project/${ref}/auth/third-party`,+ },+ ]if (isPermissionsLoaded && !canReadAuthSettings) {return <NoPermission isFullPage resourceText="access your project's auth provider settings" />- } else {- return (- <FormsContainer className="w-full">- <AuthProvidersForm />- </FormsContainer>- )}++ return (+ <div>+ <ScaffoldHeader className="pb-0">+ <ScaffoldContainer id="auth-page-top">+ <ScaffoldTitle>Sign In / Up</ScaffoldTitle>+ <ScaffoldDescription>+ Configure authentication providers and login methods for your users+ </ScaffoldDescription>+ <NavMenu+ className="border-none max-w-full overflow-y-hidden overflow-x-auto mt-4"+ aria-label="Auth provider settings navigation"+ >+ {navMenuItems.map((item) => (+ <NavMenuItem key={item.label} active={currentPath === item.href}>+ <Link href={item.href}>{item.label}</Link>+ </NavMenuItem>+ ))}+ </NavMenu>+ </ScaffoldContainer>+ </ScaffoldHeader>++ <ScaffoldDivider />++ <ScaffoldContainer className="my-8 space-y-8">+ <BasicAuthSettingsForm />+ <AuthProvidersForm />+ </ScaffoldContainer>+ </div>+ )}PageLayout.getLayout = (page) => {diff --git a/apps/studio/pages/project/[ref]/auth/rate-limits.tsx b/apps/studio/pages/project/[ref]/auth/rate-limits.tsxindex adbe75a115f..8629026f85e 100644--- a/apps/studio/pages/project/[ref]/auth/rate-limits.tsx+++ b/apps/studio/pages/project/[ref]/auth/rate-limits.tsx@@ -2,7 +2,13 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import RateLimits from 'components/interfaces/Auth/RateLimits/RateLimits'import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'-import { FormsContainer } from 'components/ui/Forms/FormsContainer'+import {+ ScaffoldHeader,+ ScaffoldContainer,+ ScaffoldDescription,+ ScaffoldTitle,+} from 'components/layouts/Scaffold'+import { DocsButton } from 'components/ui/DocsButton'import NoPermission from 'components/ui/NoPermission'import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'import type { NextPageWithLayout } from 'types'@@ -15,9 +21,23 @@ const PageLayout: NextPageWithLayout = () => {return <NoPermission isFullPage resourceText="access your project's auth rate limit settings" />} else {return (- <FormsContainer>- <RateLimits />- </FormsContainer>+ <div>+ <ScaffoldHeader className="pb-0">+ <ScaffoldContainer id="auth-page-top" className="flex items-center justify-between">+ <div>+ <ScaffoldTitle>Rate Limits</ScaffoldTitle>+ <ScaffoldDescription>+ Safeguard against bursts of incoming traffic to prevent abuse and maximize stability+ </ScaffoldDescription>+ </div>+ <DocsButton href="https://supabase.com/docs/guides/platform/going-into-prod#rate-limiting-resource-allocation--abuse-prevention" />+ </ScaffoldContainer>+ </ScaffoldHeader>++ <ScaffoldContainer className="my-8 space-y-8">+ <RateLimits />+ </ScaffoldContainer>+ </div>)}}diff --git a/apps/studio/pages/project/[ref]/auth/sessions.tsx b/apps/studio/pages/project/[ref]/auth/sessions.tsxnew file mode 100644index 00000000000..2835de7767c--- /dev/null+++ b/apps/studio/pages/project/[ref]/auth/sessions.tsx@@ -0,0 +1,39 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'++import { SessionsAuthSettingsForm, SmtpForm, ThirdPartyAuthForm } from 'components/interfaces/Auth'+import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'+import { ScaffoldContainer, ScaffoldHeader, ScaffoldTitle } from 'components/layouts/Scaffold'+import NoPermission from 'components/ui/NoPermission'+import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'+import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'+import type { NextPageWithLayout } from 'types'++const AuthSettings: NextPageWithLayout = () => {+ const isPermissionsLoaded = usePermissionsLoaded()+ // TODO: check if these permissions cover third party auth as well+ const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')++ return (+ <>+ <ScaffoldContainer>+ <ScaffoldHeader>+ <ScaffoldTitle>Sessions</ScaffoldTitle>+ </ScaffoldHeader>+ </ScaffoldContainer>+ <ScaffoldContainer className="flex flex-col gap-10" bottomPadding>+ {!isPermissionsLoaded ? (+ <GenericSkeletonLoader />+ ) : !canReadAuthSettings ? (+ <NoPermission isFullPage resourceText="access your project's authentication settings" />+ ) : (+ <SessionsAuthSettingsForm />+ )}+ </ScaffoldContainer>+ </>+ )+}++AuthSettings.getLayout = (page) => {+ return <AuthLayout>{page}</AuthLayout>+}+export default AuthSettingsdiff --git a/apps/studio/pages/project/[ref]/auth/smtp.tsx b/apps/studio/pages/project/[ref]/auth/smtp.tsxnew file mode 100644index 00000000000..9db26e4661e--- /dev/null+++ b/apps/studio/pages/project/[ref]/auth/smtp.tsx@@ -0,0 +1,75 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'++import { SmtpForm } from 'components/interfaces/Auth'+import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'+import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'+import { useParams } from 'common'+import { useCurrentPath } from 'hooks/misc/useCurrentPath'+import Link from 'next/link'+import { NavMenu, NavMenuItem } from 'ui'+import {+ ScaffoldContainer,+ ScaffoldDescription,+ ScaffoldDivider,+ ScaffoldHeader,+ ScaffoldTitle,+} from 'components/layouts/Scaffold'+import NoPermission from 'components/ui/NoPermission'+import type { NextPageWithLayout } from 'types'++const PageLayout: NextPageWithLayout = () => {+ const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')+ const isPermissionsLoaded = usePermissionsLoaded()+ const { ref } = useParams()+ const currentPath = useCurrentPath()++ const navMenuItems = [+ {+ label: 'Templates',+ href: `/project/${ref}/auth/templates`,+ },+ {+ label: 'SMTP Settings',+ href: `/project/${ref}/auth/smtp`,+ },+ ]++ if (isPermissionsLoaded && !canReadAuthSettings) {+ return <NoPermission isFullPage resourceText="access your project's email settings" />+ }++ return (+ <div>+ <ScaffoldHeader className="pb-0">+ <ScaffoldContainer id="auth-page-top">+ <ScaffoldTitle>Emails</ScaffoldTitle>+ <ScaffoldDescription>+ Configure what emails your users receive and how they are sent+ </ScaffoldDescription>+ <NavMenu+ className="border-none max-w-full overflow-y-hidden overflow-x-auto mt-4"+ aria-label="Auth email settings navigation"+ >+ {navMenuItems.map((item) => (+ <NavMenuItem key={item.label} active={currentPath === item.href}>+ <Link href={item.href}>{item.label}</Link>+ </NavMenuItem>+ ))}+ </NavMenu>+ </ScaffoldContainer>+ </ScaffoldHeader>++ <ScaffoldDivider />++ <ScaffoldContainer className="my-8 space-y-8">+ <SmtpForm />+ </ScaffoldContainer>+ </div>+ )+}++PageLayout.getLayout = (page) => {+ return <AuthLayout>{page}</AuthLayout>+}++export default PageLayoutdiff --git a/apps/studio/pages/project/[ref]/auth/templates.tsx b/apps/studio/pages/project/[ref]/auth/templates.tsxindex 2ea86a103fe..51f4bbaeb9a 100644--- a/apps/studio/pages/project/[ref]/auth/templates.tsx+++ b/apps/studio/pages/project/[ref]/auth/templates.tsx@@ -1,25 +1,70 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-+import { useParams } from 'common'import { EmailTemplates } from 'components/interfaces/Auth'import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'-import { FormsContainer } from 'components/ui/Forms/FormsContainer'-import NoPermission from 'components/ui/NoPermission'import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'+import { useCurrentPath } from 'hooks/misc/useCurrentPath'+import Link from 'next/link'+import { NavMenu, NavMenuItem } from 'ui'+import {+ ScaffoldContainer,+ ScaffoldDescription,+ ScaffoldDivider,+ ScaffoldHeader,+ ScaffoldTitle,+} from 'components/layouts/Scaffold'+import NoPermission from 'components/ui/NoPermission'import type { NextPageWithLayout } from 'types'const PageLayout: NextPageWithLayout = () => {const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')const isPermissionsLoaded = usePermissionsLoaded()+ const { ref } = useParams()+ const currentPath = useCurrentPath()++ const navMenuItems = [+ {+ label: 'Templates',+ href: `/project/${ref}/auth/templates`,+ },+ {+ label: 'SMTP Settings',+ href: `/project/${ref}/auth/smtp`,+ },+ ]if (isPermissionsLoaded && !canReadAuthSettings) {return <NoPermission isFullPage resourceText="access your project's email settings" />- } else {- return (- <FormsContainer>- <EmailTemplates />- </FormsContainer>- )}++ return (+ <div>+ <ScaffoldHeader className="pb-0">+ <ScaffoldContainer id="auth-page-top">+ <ScaffoldTitle>Emails</ScaffoldTitle>+ <ScaffoldDescription>+ Configure what emails your users receive and how they are sent+ </ScaffoldDescription>+ <NavMenu+ className="border-none max-w-full overflow-y-hidden overflow-x-auto mt-4"+ aria-label="Auth email settings navigation"+ >+ {navMenuItems.map((item) => (+ <NavMenuItem key={item.label} active={currentPath === item.href}>+ <Link href={item.href}>{item.label}</Link>+ </NavMenuItem>+ ))}+ </NavMenu>+ </ScaffoldContainer>+ </ScaffoldHeader>++ <ScaffoldDivider />++ <ScaffoldContainer className="my-8 space-y-8">+ <EmailTemplates />+ </ScaffoldContainer>+ </div>+ )}PageLayout.getLayout = (page) => {diff --git a/apps/studio/pages/project/[ref]/auth/third-party.tsx b/apps/studio/pages/project/[ref]/auth/third-party.tsxnew file mode 100644index 00000000000..c9782a0d636--- /dev/null+++ b/apps/studio/pages/project/[ref]/auth/third-party.tsx@@ -0,0 +1,75 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'++import { ThirdPartyAuthForm } from 'components/interfaces/Auth'+import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'+import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'+import { useParams } from 'common'+import { useCurrentPath } from 'hooks/misc/useCurrentPath'+import Link from 'next/link'+import { NavMenu, NavMenuItem } from 'ui'+import {+ ScaffoldContainer,+ ScaffoldDescription,+ ScaffoldDivider,+ ScaffoldHeader,+ ScaffoldTitle,+} from 'components/layouts/Scaffold'+import NoPermission from 'components/ui/NoPermission'+import type { NextPageWithLayout } from 'types'++const PageLayout: NextPageWithLayout = () => {+ const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')+ const isPermissionsLoaded = usePermissionsLoaded()+ const { ref } = useParams()+ const currentPath = useCurrentPath()++ const navMenuItems = [+ {+ label: 'Supabase auth',+ href: `/project/${ref}/auth/providers`,+ },+ {+ label: 'Third Party auth',+ href: `/project/${ref}/auth/third-party`,+ },+ ]++ if (isPermissionsLoaded && !canReadAuthSettings) {+ return <NoPermission isFullPage resourceText="access your project's auth provider settings" />+ }++ return (+ <>+ <ScaffoldHeader className="pb-0">+ <ScaffoldContainer id="auth-page-top">+ <ScaffoldTitle>Sign in / up</ScaffoldTitle>+ <ScaffoldDescription>+ Configure authentication providers and login methods for your users+ </ScaffoldDescription>+ <NavMenu+ className="border-none max-w-full overflow-y-hidden overflow-x-auto mt-4"+ aria-label="Auth provider settings navigation"+ >+ {navMenuItems.map((item) => (+ <NavMenuItem key={item.label} active={currentPath === item.href}>+ <Link href={item.href}>{item.label}</Link>+ </NavMenuItem>+ ))}+ </NavMenu>+ </ScaffoldContainer>+ </ScaffoldHeader>++ <ScaffoldDivider />++ <ScaffoldContainer className="my-8">+ <ThirdPartyAuthForm />+ </ScaffoldContainer>+ </>+ )+}++PageLayout.getLayout = (page) => {+ return <AuthLayout>{page}</AuthLayout>+}++export default PageLayoutdiff --git a/apps/studio/pages/project/[ref]/auth/url-configuration.tsx b/apps/studio/pages/project/[ref]/auth/url-configuration.tsxindex 36aae336e66..d611b93aa5a 100644--- a/apps/studio/pages/project/[ref]/auth/url-configuration.tsx+++ b/apps/studio/pages/project/[ref]/auth/url-configuration.tsx@@ -3,6 +3,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { RedirectUrls } from 'components/interfaces/Auth/RedirectUrls/RedirectUrls'import SiteUrl from 'components/interfaces/Auth/SiteUrl/SiteUrl'import AuthLayout from 'components/layouts/AuthLayout/AuthLayout'+import { ScaffoldContainer, ScaffoldHeader, ScaffoldTitle } from 'components/layouts/Scaffold'import { FormsContainer } from 'components/ui/Forms/FormsContainer'import NoPermission from 'components/ui/NoPermission'import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'@@ -16,10 +17,18 @@ const URLConfiguration: NextPageWithLayout = () => {return <NoPermission isFullPage resourceText="access your project's email settings" />} else {return (- <FormsContainer>- <SiteUrl />- <RedirectUrls />- </FormsContainer>+ <div>+ <ScaffoldHeader className="pb-0">+ <ScaffoldContainer id="auth-page-top">+ <ScaffoldTitle>URL Configuration</ScaffoldTitle>+ </ScaffoldContainer>+ </ScaffoldHeader>++ <ScaffoldContainer className="my-8 space-y-8">+ <SiteUrl />+ <RedirectUrls />+ </ScaffoldContainer>+ </div>)}}diff --git a/apps/studio/pages/project/[ref]/settings/auth.tsx b/apps/studio/pages/project/[ref]/settings/auth.tsxindex 4426c483d7a..6976328b857 100644--- a/apps/studio/pages/project/[ref]/settings/auth.tsx+++ b/apps/studio/pages/project/[ref]/settings/auth.tsx@@ -1,53 +1,102 @@-import { PermissionAction } from '@supabase/shared-types/out/constants'--import {- AdvancedAuthSettingsForm,- BasicAuthSettingsForm,- SmtpForm,- ThirdPartyAuthForm,-} from 'components/interfaces/Auth'+import { useParams } from 'common'import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'-import {- ScaffoldContainer,- ScaffoldDescription,- ScaffoldHeader,- ScaffoldTitle,-} from 'components/layouts/Scaffold'-import NoPermission from 'components/ui/NoPermission'-import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'-import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions'+import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'+import { ChevronRight } from 'lucide-react'+import Link from 'next/link'import type { NextPageWithLayout } from 'types'-const AuthSettings: NextPageWithLayout = () => {- const isPermissionsLoaded = usePermissionsLoaded()- // TODO: check if these permissions cover third party auth as well- const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue')+const ProjectSettings: NextPageWithLayout = () => {+ const { ref } = useParams() as { ref: string }return (- <>- <ScaffoldContainer>- <ScaffoldHeader>- <ScaffoldTitle>Auth settings</ScaffoldTitle>- <ScaffoldDescription>Configure security and user session settings</ScaffoldDescription>- </ScaffoldHeader>- </ScaffoldContainer>- <ScaffoldContainer className="flex flex-col gap-10" bottomPadding>- {!isPermissionsLoaded ? (- <GenericSkeletonLoader />- ) : !canReadAuthSettings ? (- <NoPermission isFullPage resourceText="access your project's authentication settings" />- ) : (- <>- <BasicAuthSettingsForm />- <SmtpForm />- <AdvancedAuthSettingsForm />- <ThirdPartyAuthForm />- </>- )}- </ScaffoldContainer>- </>+ <ProductEmptyState title="Authentication settings have moved">+ <div className="text-sm">+ <p className="text-foreground-light mb-4">+ All settings are now under configuration within the Authentication page. All other product+ settings will follow in the coming weeks.+ </p>+ <Link+ href={`/project/${ref}/auth/providers`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ General user signup+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/auth/providers`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ Password settings in email provider+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/auth/sessions`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ User sessions+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/auth/sessions`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ Refresh tokens+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/auth/protection`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ Bot and abuse protection+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/auth/smtp`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ SMTP settings+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/settings/api#jwt-settings`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ Access token expiry+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/auth/mfa`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ Multifactor authentication+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/auth/third-party`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ Third party authentication+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/auth/advanced`}+ className="block py-2 hover:text-foreground border-b flex items-center justify-between"+ >+ Max request duration+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ <Link+ href={`/project/${ref}/settings/database#connection-pooler`}+ className="block py-2 hover:text-foreground flex items-center justify-between"+ >+ Max direct database connections+ <ChevronRight strokeWidth={1.5} size={16} />+ </Link>+ </div>+ </ProductEmptyState>)}-AuthSettings.getLayout = (page) => <SettingsLayout>{page}</SettingsLayout>-export default AuthSettings+ProjectSettings.getLayout = (page) => <SettingsLayout title="Authentication">{page}</SettingsLayout>++export default ProjectSettings