The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix auth settings pages and clean up
Joshen Lima561305ba35e
diff --git a/studio/components/interfaces/Auth/Auth.types.ts b/studio/components/interfaces/Auth/Auth.types.tsnew file mode 100644index 00000000000..9837f672b7e--- /dev/null+++ b/studio/components/interfaces/Auth/Auth.types.ts@@ -0,0 +1,151 @@+// [Joshen] Maybe shift this into shared-types repo or something?+// This isn't typed completely properly as I'm not too sure myself+export interface AuthConfig {+ id: number+ project_id: number+ updated_at: string++ DISABLE_SIGNUP: boolean+ EXTERNAL_EMAIL_ENABLED: boolean+ EXTERNAL_PHONE_ENABLED: boolean++ EXTERNAL_APPLE_ENABLED: boolean+ EXTERNAL_APPLE_CLIENT_ID: string | null+ EXTERNAL_APPLE_SECRET: string | null++ EXTERNAL_AZURE_ENABLED: boolean+ EXTERNAL_AZURE_URL: string | null+ EXTERNAL_AZURE_CLIENT_ID: string | null+ EXTERNAL_AZURE_SECRET: string | null++ EXTERNAL_BITBUCKET_ENABLED: boolean+ EXTERNAL_BITBUCKET_CLIENT_ID: string | null+ EXTERNAL_BITBUCKET_SECRET: string | null++ EXTERNAL_DISCORD_ENABLED: boolean+ EXTERNAL_DISCORD_CLIENT_ID: string | null+ EXTERNAL_DISCORD_SECRET: string | null++ EXTERNAL_FACEBOOK_ENABLED: boolean+ EXTERNAL_FACEBOOK_CLIENT_ID: string | null+ EXTERNAL_FACEBOOK_SECRET: string | null++ EXTERNAL_GITHUB_ENABLED: false+ EXTERNAL_GITHUB_CLIENT_ID: string | null+ EXTERNAL_GITHUB_SECRET: string | null++ EXTERNAL_GITLAB_ENABLED: boolean+ EXTERNAL_GITLAB_CLIENT_ID: string | null+ EXTERNAL_GITLAB_REDIRECT_URI: string | null+ EXTERNAL_GITLAB_SECRET: string | null++ EXTERNAL_GOOGLE_ENABLED: boolean+ EXTERNAL_GOOGLE_CLIENT_ID: string | null+ EXTERNAL_GOOGLE_SECRET: string | null++ EXTERNAL_KEYCLOAK_ENABLED: boolean+ EXTERNAL_KEYCLOAK_CLIENT_ID: string | null+ EXTERNAL_KEYCLOAK_SECRET: string | null+ EXTERNAL_KEYCLOAK_URL: string | null++ EXTERNAL_LINKEDIN_ENABLED: boolean+ EXTERNAL_LINKEDIN_CLIENT_ID: string | null+ EXTERNAL_LINKEDIN_SECRET: string | null++ EXTERNAL_NOTION_ENABLED: boolean+ EXTERNAL_NOTION_CLIENT_ID: string | null+ EXTERNAL_NOTION_SECRET: string | null++ EXTERNAL_SLACK_ENABLED: boolean+ EXTERNAL_SLACK_CLIENT_ID: string | null+ EXTERNAL_SLACK_SECRET: string | null++ EXTERNAL_SPOTIFY_ENABLED: boolean+ EXTERNAL_SPOTIFY_CLIENT_ID: string | null+ EXTERNAL_SPOTIFY_SECRET: string | null++ EXTERNAL_TWITCH_ENABLED: boolean+ EXTERNAL_TWITCH_CLIENT_ID: string | null+ EXTERNAL_TWITCH_SECRET: string | null++ EXTERNAL_TWITTER_ENABLED: boolean+ EXTERNAL_TWITTER_CLIENT_ID: string | null+ EXTERNAL_TWITTER_SECRET: string | null++ EXTERNAL_WORKOS_ENABLED: boolean+ EXTERNAL_WORKOS_CLIENT_ID: string | null+ EXTERNAL_WORKOS_SECRET: string | null+ EXTERNAL_WORKOS_URL: string | null++ EXTERNAL_ZOOM_ENABLED: boolean+ EXTERNAL_ZOOM_CLIENT_ID: string | null+ EXTERNAL_ZOOM_SECRET: string | null++ JWT_AUD: 'authenticated' | string+ JWT_DEFAULT_GROUP_NAME: 'authenticated' | string+ JWT_EXP: number++ MAILER_AUTOCONFIRM: boolean+ MAILER_OTP_EXP: number+ MAILER_SECURE_EMAIL_CHANGE_ENABLED: boolean+ MAILER_SUBJECTS_CONFIRMATION: string+ MAILER_SUBJECTS_EMAIL_CHANGE: string+ MAILER_SUBJECTS_INVITE: string+ MAILER_SUBJECTS_MAGIC_LINK: string+ MAILER_SUBJECTS_RECOVERY: string+ MAILER_TEMPLATES_CONFIRMATION: string | null+ MAILER_TEMPLATES_CONFIRMATION_CONTENT: string+ MAILER_TEMPLATES_EMAIL_CHANGE: string | null+ MAILER_TEMPLATES_EMAIL_CHANGE_CONTENT: string+ MAILER_TEMPLATES_INVITE: string | null+ MAILER_TEMPLATES_INVITE_CONTENT: string+ MAILER_TEMPLATES_MAGIC_LINK: string | null+ MAILER_TEMPLATES_MAGIC_LINK_CONTENT: string+ MAILER_TEMPLATES_RECOVERY: string | null+ MAILER_TEMPLATES_RECOVERY_CONTENT: string+ MAILER_URLPATHS_CONFIRMATION: string+ MAILER_URLPATHS_EMAIL_CHANGE: string+ MAILER_URLPATHS_INVITE: string+ MAILER_URLPATHS_RECOVERY: string++ OPERATOR_TOKEN: string | null+ PASSWORD_MIN_LENGTH: number+ RATE_LIMIT_EMAIL_SENT: number+ RATE_LIMIT_HEADER: string | null+ RATE_LIMIT_TOKEN_REFRESH: number+ RATE_LIMIT_VERIFY: number+ REFRESH_TOKEN_ROTATION_ENABLED: boolean++ SECURITY_CAPTCHA_ENABLED: boolean+ SECURITY_CAPTCHA_PROVIDER: 'hcaptcha' | string+ SECURITY_CAPTCHA_SECRET: string+ SECURITY_REFRESH_TOKEN_REUSE_INTERVAL: number+ SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION: boolean++ SITE_URL: string+ SMS_AUTOCONFIRM: boolean+ SMS_MAX_FREQUENCY: number+ SMS_MESSAGEBIRD_ACCESS_KEY: string+ SMS_MESSAGEBIRD_ORIGINATOR: string+ SMS_OTP_EXP: number+ SMS_OTP_LENGTH: number+ SMS_PROVIDER: 'twilio' | string+ SMS_TEMPLATE: string+ SMS_TEXTLOCAL_API_KEY: string+ SMS_TEXTLOCAL_SENDER: string+ SMS_TWILIO_ACCOUNT_SID: string+ SMS_TWILIO_AUTH_TOKEN: string+ SMS_TWILIO_MESSAGE_SERVICE_SID: string+ SMS_VONAGE_API_KEY: string+ SMS_VONAGE_API_SECRET: string+ SMS_VONAGE_FROM: string+ SMTP_ADMIN_EMAIL: string | null+ SMTP_HOST: string | null+ SMTP_MAX_FREQUENCY: number+ SMTP_PASS: string | null+ SMTP_PASS_ENCRYPTED: string | null+ SMTP_PORT: number | string | null+ SMTP_SENDER_NAME: string | null+ SMTP_USER: string | null+ URI_ALLOW_LIST: string+}diff --git a/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.constants.ts b/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.constants.tsnew file mode 100644index 00000000000..be099a7cb1a--- /dev/null+++ b/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.constants.ts@@ -0,0 +1,17 @@+export const ProviderCollapsibleClasses = [+ 'bg-scale-100 dark:bg-scale-300 ',+ 'hover:bg-scale-200 dark:hover:bg-scale-500',+ 'data-open:bg-scale-200 dark:data-open:bg-scale-500 ',+ 'border-scale-300 ',+ 'dark:border-scale-500 hover:border-scale-500 ',+ 'dark:hover:border-scale-700 data-open:border-scale-700',+ 'data-open:pb-px col-span-12 mx-auto',+ '-space-y-px overflow-hidden',+ 'border shadow',+ 'transition',+ 'first:rounded-tl',+ 'first:rounded-tr',+ 'last:rounded-bl',+ 'last:rounded-br',+ 'hover:z-50',+]diff --git a/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx b/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsxnew file mode 100644index 00000000000..138d1711c28--- /dev/null+++ b/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx@@ -0,0 +1,39 @@+import { observer } from 'mobx-react-lite'+import { useStore } from 'hooks'+import { PROVIDERS_SCHEMAS } from 'stores/authConfig/schema'+import { FormHeader } from 'components/ui/Forms'+import { HorizontalShimmerWithIcon } from 'components/ui/Shimmers'+import ProviderForm from './ProviderForm'+import { ProviderCollapsibleClasses } from './AuthProvidersForm.constants'++const AuthProvidersForm = () => {+ const { authConfig } = useStore()+ const providers = PROVIDERS_SCHEMAS++ return (+ <div>+ <FormHeader+ title="Auth Providers"+ description="Authenticate your users through a suite of providers and login methods"+ />++ <div className="-space-y-px">+ {!authConfig.isLoaded+ ? providers.map((provider) => (+ <div+ key={`provider_${provider.title}`}+ className={[...ProviderCollapsibleClasses, 'px-6 py-3'].join(' ')}+ >+ <HorizontalShimmerWithIcon />+ </div>+ ))+ : providers.map((provider) => {+ // @ts-expect-error: Fix type to be dynamic+ return <ProviderForm key={`provider_${provider.title}`} provider={provider} />+ })}+ </div>+ </div>+ )+}++export default observer(AuthProvidersForm)diff --git a/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.types.ts b/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.types.tsnew file mode 100644index 00000000000..848cb29b8de--- /dev/null+++ b/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.types.ts@@ -0,0 +1,34 @@+export interface Enum {+ label: string+ value: string+ icon: string+}++export interface Provider {+ $schema: string+ type: 'object'+ title: string+ properties: {+ [x: string]: {+ title: string+ type: 'boolean' | 'string' | 'select' | 'number'+ description?: string+ descriptionOptional?: string+ enum: Enum[]+ show: {+ key: string+ matches: string+ }+ }+ }+ validationSchema: any // todo: use Yup type+ misc: {+ iconKey: 'gitlab-icon'+ requiresRedirect: true+ helper: string+ alert: {+ title: string+ description: string+ }+ }+}diff --git a/studio/components/interfaces/Auth/AuthProvidersForm.tsx b/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsxsimilarity index 67%rename from studio/components/interfaces/Auth/AuthProvidersForm.tsxrename to studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsxindex f02e248e79e..31959a95bbf 100644--- a/studio/components/interfaces/Auth/AuthProvidersForm.tsx+++ b/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx@@ -1,3 +1,5 @@+import { FC, useEffect, useState } from 'react'+import ReactMarkdown from 'react-markdown'import {Alert,Button,@@ -10,110 +12,42 @@ import {Listbox,Toggle,} from '@supabase/ui'-import { FormHeader } from 'components/ui/Forms'-import { HorizontalShimmerWithIcon } from 'components/ui/Shimmers'-import { useStore } from 'hooks'-import { observer } from 'mobx-react-lite'-import { useState } from 'react'-import ReactMarkdown from 'react-markdown'-import { PROVIDERS_SCHEMAS } from 'stores/authConfig/schema'--interface Enum {- label: string- value: string- icon: string-}-interface Provider {- $schema: string- type: 'object'- title: string- properties: {- [x: string]: {- title: string- type: 'boolean' | 'string' | 'select' | 'number'- description?: string- descriptionOptional?: string- enum: Enum[]- show: {- key: string- matches: string- }- }- }- validationSchema: any // todo: use Yup type- misc: {- iconKey: 'gitlab-icon'- requiresRedirect: true- helper: string- alert: {- title: string- description: string- }- }-}-const ProviderCollapsibleClasses = [- 'bg-scale-100 dark:bg-scale-300 ',- 'hover:bg-scale-200 dark:hover:bg-scale-500',- 'data-open:bg-scale-200 dark:data-open:bg-scale-500 ',- 'border-scale-300 ',- 'dark:border-scale-500 hover:border-scale-500 ',- 'dark:hover:border-scale-700 data-open:border-scale-700',- 'data-open:pb-px col-span-12 mx-auto',- '-space-y-px overflow-hidden',- 'border shadow',- 'transition',- 'first:rounded-tl',- 'first:rounded-tr',- 'last:rounded-bl',- 'last:rounded-br',- 'hover:z-50',-]--const AuthProvidersForm = () => {- const providers = PROVIDERS_SCHEMAS- const { authConfig } = useStore()-- return (- <div>- <FormHeader- title="Auth Providers"- description={`URLs that auth providers are permitted to redirect to post authentication`}- />+import { useStore } from 'hooks'+import { Enum, Provider } from './AuthProvidersForm.types'+import { ProviderCollapsibleClasses } from './AuthProvidersForm.constants'- <div className="-space-y-px">- {!authConfig.isLoaded- ? // true- providers.map((i) => (- <div className={[...ProviderCollapsibleClasses, 'px-6 py-3'].join(' ')}>- <HorizontalShimmerWithIcon />- </div>- ))- : // @ts-expect-error- // to do: fix type error, needs to be dynamic- providers.map((provider: Provider, i) => {- return <ProviderForm provider={provider} key={i} />- })}- </div>- </div>- )+interface Props {+ provider: Provider}-const ProviderForm = ({ provider }: { provider: Provider }) => {+const ProviderForm: FC<Props> = ({ provider }) => {const [open, setOpen] = useState(false)const { authConfig, ui } = useStore()- const active = authConfig.config[`EXTERNAL_${provider?.title?.toUpperCase()}_ENABLED`]++ const isActive = authConfig.config[`EXTERNAL_${provider?.title?.toUpperCase()}_ENABLED`]const INITIAL_VALUES: { [x: string]: string } = {}- /**- * construct values for INITIAL_VALUES- *- * return empty string `""` rather than `null`- * as it breaks form. null is not a valid value.- */- Object.keys(provider.properties).forEach((key) => {- INITIAL_VALUES[key] = authConfig.config[key] ?? ''- })+ useEffect(() => {+ /**+ * Construct values for INITIAL_VALUES+ * Return empty string `""` rather than `null`+ * as it breaks form. null is not a valid value.+ */+ Object.keys(provider.properties).forEach((key) => {+ INITIAL_VALUES[key] = authConfig.config[key] ?? ''+ })+ }, [provider])++ const onSubmit = async (values: any, { setSubmitting }: any) => {+ try {+ await authConfig.update(values)+ setSubmitting(false)+ setOpen(false)+ } catch (error) {+ console.error(error)+ }+ }return (<Collapsible@@ -124,12 +58,7 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {<Collapsible.Trigger asChild><buttontype="button"- className="- text-scale-1200- group- flex- w-full items-center justify-between rounded- py-3 px-6"+ className="text-scale-1200 group flex w-full items-center justify-between rounded py-3 px-6"><div className="flex items-center gap-3"><IconChevronUp@@ -137,17 +66,15 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {strokeWidth={2}width={14}/>-<imgsrc={`/img/icons/${provider.misc.iconKey}.svg`}width={18}alt={`${provider.title} auth icon`}/>-<span className="text-sm">{provider.title}</span></div><div className="flex items-center gap-3">- {active ? (+ {isActive ? (<div className="bg-brand-200 border-brand-700 text-brand-900 flex items-center gap-1 rounded-full border py-1 px-1 text-xs"><span className="bg-brand-900 text-brand-200 rounded-full p-0.5 text-xs"><IconCheck strokeWidth={2} size={12} />@@ -166,23 +93,10 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {name={`provider-${provider.title}-form`}initialValues={INITIAL_VALUES}validationSchema={provider.validationSchema}- onSubmit={async (values: any, { setSubmitting }: any) => {- try {- await authConfig.update(values)- setSubmitting(false)- setOpen(false)- } catch (error) {- console.error(error)- }- }}+ onSubmit={onSubmit}>{({ isSubmitting, handleReset, values }: any) => {const noChanges = JSON.stringify(INITIAL_VALUES) === JSON.stringify(values)-- // if (open) {- // handleReset()- // }-return (<Collapsible.Content><div@@ -193,21 +107,14 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {><div className="mx-auto my-6 max-w-md space-y-6">{Object.keys(provider.properties).map((x: string) => {- /**- * Properties of the form- */const properties = provider.properties[x]-- /**- * Conditionally hide properties based on value of key- */+ // Conditionally hide properties based on value of keyif (properties.show &&values[properties.show.key] !== properties.show.matches) {return null}-switch (properties.type) {case 'string':return (@@ -225,11 +132,6 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {</ReactMarkdown>) : null}- //- // @ts-expect-error- //- // to do: change to "string" | React.ReactNode | undefined- //labelOptional={properties.descriptionOptional ? (<ReactMarkdown unwrapDisallowed disallowedElements={['p']}>@@ -239,7 +141,6 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {}/>)- breakcase 'number':return (@@ -249,9 +150,7 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {id={x}key={x}name={x}- // style={{ width: '50%' }}label={properties.title}- // @ts-expect-errordescriptionText={properties.description ? (<ReactMarkdown unwrapDisallowed disallowedElements={['p']}>@@ -259,11 +158,6 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {</ReactMarkdown>) : null}- //- // @ts-expect-error- //- // to do: change to "string" | React.ReactNode | undefined- //labelOptional={properties.descriptionOptional ? (<ReactMarkdown unwrapDisallowed disallowedElements={['p']}>@@ -273,20 +167,17 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {}/>)- breakcase 'boolean':return (<Togglesize="small"- // layout="horizontal"key={x}name={x}label={properties.title}descriptionText={properties.description}/>)- breakcase 'select':return (@@ -314,7 +205,6 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {})}</Listbox>)- breakdefault:break@@ -331,11 +221,11 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {{provider.misc.helper}</ReactMarkdown><Input- label="Redirect url"- readOnly- value={`https://${ui.selectedProjectRef}.supabase.co/auth/v1/callback`}copy+ readOnlydisabled+ label="Redirect url"+ value={`https://${ui.selectedProjectRef}.supabase.co/auth/v1/callback`}/></>)}@@ -364,4 +254,4 @@ const ProviderForm = ({ provider }: { provider: Provider }) => {)}-export default observer(AuthProvidersForm)+export default ProviderFormdiff --git a/studio/components/interfaces/Auth/AutoSchemaForm.tsx b/studio/components/interfaces/Auth/AutoSchemaForm.tsxindex a6f6b489a5a..65a2b6a4d42 100644--- a/studio/components/interfaces/Auth/AutoSchemaForm.tsx+++ b/studio/components/interfaces/Auth/AutoSchemaForm.tsx@@ -1,8 +1,9 @@import { Form, Input, InputNumber, Toggle } from '@supabase/ui'-import { useStore } from 'hooks'-import { observer } from 'mobx-react-lite'import { useEffect } from 'react'+import { observer } from 'mobx-react-lite'import { boolean, number, object, string } from 'yup'++import { useStore } from 'hooks'import {FormActions,FormHeader,@@ -10,12 +11,13 @@ import {FormSection,FormSectionContent,FormSectionLabel,-} from '../../ui/Forms'+} from 'components/ui/Forms'const AutoSchemaForm = observer(() => {const { authConfig, ui } = useStore()+ const { isLoaded } = authConfig- // const [isLoaded, setIsLoaded] = useState(false)+ const formId = 'auth-config-general-form'const INITIAL_VALUES = {DISABLE_SIGNUP: !authConfig.config.DISABLE_SIGNUP,@@ -39,140 +41,122 @@ const AutoSchemaForm = observer(() => {SECURITY_CAPTCHA_SECRET: string(),})- const isLoaded = authConfig.isLoaded- const formId = 'auth-config-general-form'-return (- <>- <Form- id={formId}- initialValues={INITIAL_VALUES}- onSubmit={async (values: any, { setSubmitting, resetForm }: any) => {- const payload = { ...values }- payload.DISABLE_SIGNUP = !values.DISABLE_SIGNUP- payload.SECURITY_CAPTCHA_PROVIDER = 'hcaptcha'- try {- setSubmitting(true)- await authConfig.update(payload)- setSubmitting(false)- ui.setNotification({- category: 'success',- message: `Updated settings`,- })- resetForm({ values: values, initialValues: values })- } catch (error) {- ui.setNotification({- category: 'error',- message: `Failed to update settings`,- })- setSubmitting(false)- }- }}- validationSchema={schema}- >- {({ isSubmitting, handleReset, resetForm, values, initialValues }: any) => {- /**- * Tracks changes in form- */- const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)+ <Form+ id={formId}+ initialValues={INITIAL_VALUES}+ onSubmit={async (values: any, { setSubmitting, resetForm }: any) => {+ const payload = { ...values }+ payload.DISABLE_SIGNUP = !values.DISABLE_SIGNUP+ payload.SECURITY_CAPTCHA_PROVIDER = 'hcaptcha'+ try {+ setSubmitting(true)+ await authConfig.update(payload)+ setSubmitting(false)+ ui.setNotification({+ category: 'success',+ message: `Updated settings`,+ })+ resetForm({ values: values, initialValues: values })+ } catch (error) {+ ui.setNotification({+ category: 'error',+ message: `Failed to update settings`,+ })+ setSubmitting(false)+ }+ }}+ validationSchema={schema}+ >+ {({ isSubmitting, handleReset, resetForm, values, initialValues }: any) => {+ const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)- /**- * Form is reset once remote data is loaded in store- */- useEffect(() => {- resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })- }, [authConfig.isLoaded])+ // Form is reset once remote data is loaded in store+ useEffect(() => {+ resetForm({ values: INITIAL_VALUES, initialValues: INITIAL_VALUES })+ }, [authConfig.isLoaded])- return (- <>- <FormHeader- title="General settings"- description={`URLs that auth providers are permitted to redirect to post authentication`}- />- <FormPanel- disabled={true}- footer={- <div className="flex justify-between py-4 px-8">- <FormActions- handleReset={handleReset}- isSubmitting={isSubmitting}- hasChanges={hasChanges}- helper={'Learn more about global Auth settings'}- form={formId}- />- </div>- }- >- <FormSection header={<FormSectionLabel>User Signups</FormSectionLabel>}>- <FormSectionContent loading={!isLoaded}>- <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."- />- </FormSectionContent>- </FormSection>- <div className="border-scale-400 border-t"></div>- <FormSection header={<FormSectionLabel>User Sessions</FormSectionLabel>}>- <FormSectionContent loading={!isLoaded}>- {/**- *- * permitted redirects- * for anything on that domain- *- * check with @kangming about this- *- */}+ return (+ <>+ <FormHeader+ title="General settings"+ description={`URLs that auth providers are permitted to redirect to post authentication`}+ />+ <FormPanel+ disabled={true}+ footer={+ <div className="flex justify-between py-4 px-8">+ <FormActions+ form={formId}+ isSubmitting={isSubmitting}+ hasChanges={hasChanges}+ handleReset={handleReset}+ />+ </div>+ }+ >+ <FormSection header={<FormSectionLabel>User Signups</FormSectionLabel>}>+ <FormSectionContent loading={!isLoaded}>+ <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."+ />+ </FormSectionContent>+ </FormSection>+ <div className="border-scale-400 border-t"></div>+ <FormSection header={<FormSectionLabel>User Sessions</FormSectionLabel>}>+ <FormSectionContent loading={!isLoaded}>+ {/* Permitted redirects for anything on that domain */}+ {/* Check with @kangming about this */}+ <Input+ id="SITE_URL"+ size="small"+ label="Site URL"+ descriptionText="The base URL of your website. Used as an allow-list for redirects and for constructing URLs used in emails."+ />+ <InputNumber+ id="JWT_EXP"+ size="small"+ label="JWT expiry limit"+ descriptionText="How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one week)."+ />+ <InputNumber+ id="SECURITY_REFRESH_TOKEN_REUSE_INTERVAL"+ size="small"+ min={0}+ label="Reuse Interval"+ descriptionText="Time interval where the same refresh token can be used to request for an access token."+ />+ </FormSectionContent>+ </FormSection>+ <FormSection header={<FormSectionLabel>Security and Protection</FormSectionLabel>}>+ <FormSectionContent loading={!isLoaded}>+ <Toggle+ id="SECURITY_CAPTCHA_ENABLED"+ size="small"+ label="hCaptcha protection"+ layout="flex"+ descriptionText="If enabled, protects auth endpoints from abuse."+ />+ {values.SECURITY_CAPTCHA_ENABLED && (<Input- id="SITE_URL"- size="small"- label="Site URL"- descriptionText="The base URL of your website. Used as an allow-list for redirects and for constructing URLs used in emails."- />- <InputNumber- id="JWT_EXP"- size="small"- label="JWT expiry limit"- descriptionText="How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one week)."- />- {/* // min 0 */}- <InputNumber- id="SECURITY_REFRESH_TOKEN_REUSE_INTERVAL"- size="small"- min={0}- label="Reuse Interval"- descriptionText="Time interval where the same refresh token can be used to request for an access token."- />- </FormSectionContent>- </FormSection>- <FormSection header={<FormSectionLabel>Security and Protection</FormSectionLabel>}>- <FormSectionContent loading={!isLoaded}>- <Toggle- id="SECURITY_CAPTCHA_ENABLED"+ id="SECURITY_CAPTCHA_SECRET"size="small"- label="hCaptcha protection"- layout="flex"- descriptionText="If enabled, protects auth endpoints from abuse."+ label="hCaptcha sitekey"+ descriptionText="hCaptcha secret (sitekey)"/>- {values.SECURITY_CAPTCHA_ENABLED && (- <Input- id="SECURITY_CAPTCHA_SECRET"- size="small"- label="hCaptcha sitekey"- descriptionText="hCaptcha secret (sitekey)"- />- )}- </FormSectionContent>- </FormSection>- </FormPanel>- </>- )- }}- </Form>- </>+ )}+ </FormSectionContent>+ </FormSection>+ </FormPanel>+ </>+ )+ }}+ </Form>)})-export { AutoSchemaForm }+export default AutoSchemaFormdiff --git a/studio/components/interfaces/Auth/EmailTemplates.tsx b/studio/components/interfaces/Auth/EmailTemplates.tsxdeleted file mode 100644index 67eb6005e1b..00000000000--- a/studio/components/interfaces/Auth/EmailTemplates.tsx+++ /dev/null@@ -1,266 +0,0 @@-import { Form, Input, Tabs } from '@supabase/ui'-import CodeEditor from 'components/ui/CodeEditor'-import InformationBox from 'components/ui/InformationBox'-import { useStore } from 'hooks'-import { observer } from 'mobx-react-lite'-import { useEffect, useState } from 'react'-import ReactMarkdown from 'react-markdown'-import { TEMPLATES_SCHEMAS } from 'stores/authConfig/schema'-import {- FormActions,- FormHeader,- FormPanel,- FormSection,- FormSectionContent,- FormSectionLabel,-} from '../../ui/Forms'--const EmailTemplates = observer(() => {- const { authConfig, ui } = useStore()-- const isLoaded = authConfig.isLoaded-- return (- <div>- <FormHeader- title="Email Templates"- description={`You can use your own SMTP server instead of the built-in email service.`}- />- <FormPanel>- <Tabs- defaultActiveId={TEMPLATES_SCHEMAS[0].title.trim().replace(/\s+/g, '-')}- type="underlined"- listClassNames="px-8 pt-4"- size="small"- scrollable- >- {TEMPLATES_SCHEMAS.map((template, i) => {- const [bodyValue, setBodyValue] = useState('')-- const INITIAL_VALUES: { [x: string]: string } = {}-- // console.log('template.properties', template.properties)-- /**- * construct values for INITIAL_VALUES- *- * return empty string `""` rather than `null`- * as it breaks form. null is not a valid value.- */- Object.keys(template.properties).forEach((key) => {- INITIAL_VALUES[key] = authConfig.config[key] ?? ''- })-- console.log(`INITIAL_VALUES for ${template.id}`, INITIAL_VALUES)-- const messageSlug = `MAILER_TEMPLATES_${template.id}_CONTENT`- const messageProperty = template.properties[messageSlug]-- const panelId = template.title.trim().replace(/\s+/g, '-')- const formId = `auth-config-email-templates--${template.id}`-- delete INITIAL_VALUES[messageSlug]-- return (- <Tabs.Panel id={panelId} label={template.title} key={panelId}>- <Form- id={formId}- className="!border-t-0"- initialValues={INITIAL_VALUES}- onSubmit={async (values: any, { setSubmitting, resetForm }: any) => {- console.log('hello world')-- const payload = { ...values }-- // remove rendundant value- delete payload[messageSlug]-- if (messageProperty) {- payload[messageSlug] = bodyValue- }-- console.log('payload', payload)-- try {- setSubmitting(true)- await authConfig.update(payload)- setSubmitting(false)-- ui.setNotification({- category: 'success',- message: `Updated settings`,- })-- resetForm({- values: values,- initialValues: values,- })- setBodyValue(authConfig?.config?.[messageSlug])- } catch (error) {- ui.setNotification({- category: 'error',- message: `Failed to update settings`,- })- setSubmitting(false)- }- }}- >- {({ isSubmitting, resetForm, values, initialValues }: any) => {- /**- * Tracks changes in form- */- const hasChanges = () => {- if (JSON.stringify(values) !== JSON.stringify(initialValues)) return true-- if (authConfig?.config?.[messageSlug]) {- if (- authConfig?.config?.[messageSlug] &&- authConfig?.config?.[messageSlug] !== bodyValue- )- return true- }-- return false- }-- /**- * Form is reset once remote data is loaded in store- */- useEffect(() => {- resetForm({- values: INITIAL_VALUES,- initialValues: INITIAL_VALUES,- })- setBodyValue(authConfig?.config?.[messageSlug])- }, [authConfig.isLoaded])-- return (- <>- <FormSection- className="!border-t-0"- header={- <FormSectionLabel>- <span>SMTP Provider Settings</span>- <p className="text-scale-900 my-4">- Your SMTP Credentials will always be encrypted in our database.- </p>- </FormSectionLabel>- }- >- <FormSectionContent loading={!isLoaded}>- {Object.keys(template.properties).map((x: string) => {- /**- * Properties of the form- */- const properties = template.properties[x]-- /**- * Conditionally hide properties based on value of key- */- if (properties.type === 'code') {- return null- }-- switch (properties.type) {- case 'string':- return (- <Input- size="small"- layout="vertical"- id={x}- key={x}- name={x}- label={properties.title}- descriptionText={- properties.description ? (- <ReactMarkdown- unwrapDisallowed- disallowedElements={['p']}- >- {properties.description}- </ReactMarkdown>- ) : null- }- //- // @ts-expect-error- //- // to do: change to "string" | React.ReactNode | undefined- //- labelOptional={- properties.descriptionOptional ? (- <ReactMarkdown- unwrapDisallowed- disallowedElements={['p']}- >- {properties.descriptionOptional}- </ReactMarkdown>- ) : null- }- />- )- break- }- })}- </FormSectionContent>- </FormSection>- <FormSection className="!mt-0 grid-cols-12 !border-t-0 !pt-0">- <FormSectionContent loading={!isLoaded} fullWidth>- {messageProperty && (- <>- <FormSectionLabel>- <span>{messageProperty.title}</span>- </FormSectionLabel>- <InformationBox- title={'Message variables'}- hideCollapse={false}- defaultVisibility={true}- description={- messageProperty.description && (- <ReactMarkdown>{messageProperty.description}</ReactMarkdown>- )- }- />- <div className="relative">- <CodeEditor- id="code-id"- loading={!isLoaded}- language="html"- className="!mb-0 h-96 overflow-hidden rounded border"- // defaultValue={bodyValue}- onInputChange={(e: string | undefined) => setBodyValue(e ?? '')}- options={{ wordWrap: 'off', contextmenu: false }}- value={bodyValue}- />- </div>- </>- )}- <div className="col-span-12 flex w-full justify-between">- <FormActions- handleReset={() => {- resetForm({- values: authConfig.config,- initialValues: authConfig.config,- })- setBodyValue(authConfig?.config?.[messageSlug])- }}- form={formId}- isSubmitting={isSubmitting}- hasChanges={hasChanges()}- />- </div>- </FormSectionContent>- </FormSection>- </>- )- }}- </Form>- </Tabs.Panel>- )- })}- </Tabs>- </FormPanel>- </div>- )-})--export { EmailTemplates }diff --git a/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx b/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsxnew file mode 100644index 00000000000..032764429e5--- /dev/null+++ b/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx@@ -0,0 +1,37 @@+import { Tabs } from '@supabase/ui'+import { observer } from 'mobx-react-lite'++import { TEMPLATES_SCHEMAS } from 'stores/authConfig/schema'+import { FormHeader, FormPanel } from 'components/ui/Forms'+import TemplateEditor from './TemplateEditor'++const EmailTemplates = observer(() => {+ return (+ <div>+ <FormHeader+ title="Email Templates"+ description="You can use your own SMTP server instead of the built-in email service."+ />+ <FormPanel>+ <Tabs+ scrollable+ size="small"+ type="underlined"+ listClassNames="px-8 pt-4"+ defaultActiveId={TEMPLATES_SCHEMAS[0].title.trim().replace(/\s+/g, '-')}+ >+ {TEMPLATES_SCHEMAS.map((template) => {+ const panelId = template.title.trim().replace(/\s+/g, '-')+ return (+ <Tabs.Panel id={panelId} label={template.title} key={panelId}>+ <TemplateEditor key={template.title} template={template} />+ </Tabs.Panel>+ )+ })}+ </Tabs>+ </FormPanel>+ </div>+ )+})++export default EmailTemplatesdiff --git a/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx b/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsxnew file mode 100644index 00000000000..0bf3f9bea9d--- /dev/null+++ b/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx@@ -0,0 +1,175 @@+import ReactMarkdown from 'react-markdown'+import { FC, useState, useEffect } from 'react'+import { observer } from 'mobx-react-lite'+import { Input, Form } from '@supabase/ui'++import { useStore } from 'hooks'+import { FormSchema } from 'types'+import { FormActions, FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms'+import CodeEditor from 'components/ui/CodeEditor'+import InformationBox from 'components/ui/InformationBox'++interface Props {+ template: FormSchema+}++const TemplateEditor: FC<Props> = ({ template }) => {+ const { ui, authConfig } = useStore()+ const [bodyValue, setBodyValue] = useState('')++ const { isLoaded } = authConfig+ const { id, properties } = template++ const formId = `auth-config-email-templates-${id}`+ const INITIAL_VALUES: { [x: string]: string } = {}++ useEffect(() => {+ if (isLoaded) {+ Object.keys(properties).forEach((key) => {+ INITIAL_VALUES[key] = authConfig.config[key] ?? ''+ })+ }+ }, [isLoaded])++ const messageSlug = `MAILER_TEMPLATES_${id}_CONTENT`+ const messageProperty = properties[messageSlug]++ const onSubmit = async (values: any, { setSubmitting, resetForm }: any) => {+ const payload = { ...values }++ // Because the template content uses the code editor which is not a form component+ // its state is kept separately from the form state, hence why we manually inject it here+ delete payload[messageSlug]+ if (messageProperty) payload[messageSlug] = bodyValue++ try {+ setSubmitting(true)+ await authConfig.update(payload)+ ui.setNotification({ category: 'success', message: 'Successfully updated settings' })+ resetForm({+ values: values,+ initialValues: values,+ })+ setBodyValue(authConfig?.config?.[messageSlug])+ } catch (error) {+ ui.setNotification({ category: 'error', message: 'Failed to update settings' })+ } finally {+ setSubmitting(false)+ }+ }++ return (+ <Form id={formId} className="!border-t-0" initialValues={INITIAL_VALUES} onSubmit={onSubmit}>+ {({ isSubmitting, resetForm, values, initialValues }: any) => {+ useEffect(() => {+ // Form is reset once remote data is loaded in store+ resetForm({+ values: INITIAL_VALUES,+ initialValues: INITIAL_VALUES,+ })+ setBodyValue(authConfig?.config?.[messageSlug])+ }, [authConfig.isLoaded])++ const hasChanges =+ JSON.stringify(values) !== JSON.stringify(initialValues) ||+ (authConfig?.config?.[messageSlug] && authConfig?.config?.[messageSlug] !== bodyValue)++ return (+ <>+ <FormSection+ className="!border-t-0"+ header={+ <FormSectionLabel>+ <span>SMTP Provider Settings</span>+ <p className="text-scale-900 my-4">+ Your SMTP Credentials will always be encrypted in our database.+ </p>+ </FormSectionLabel>+ }+ >+ <FormSectionContent loading={!isLoaded}>+ {Object.keys(properties).map((x: string) => {+ const property = properties[x]+ if (property.type === 'string') {+ return (+ <Input+ size="small"+ layout="vertical"+ id={x}+ key={x}+ name={x}+ label={property.title}+ descriptionText={+ property.description ? (+ <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>+ {property.description}+ </ReactMarkdown>+ ) : null+ }+ labelOptional={+ property.descriptionOptional ? (+ <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>+ {property.descriptionOptional}+ </ReactMarkdown>+ ) : null+ }+ />+ )+ }+ })}+ </FormSectionContent>+ </FormSection>+ <FormSection className="!mt-0 grid-cols-12 !border-t-0 !pt-0">+ <FormSectionContent loading={!isLoaded} fullWidth>+ {messageProperty && (+ <>+ <FormSectionLabel>+ <span>{messageProperty.title}</span>+ </FormSectionLabel>+ <InformationBox+ title={'Message variables'}+ hideCollapse={false}+ defaultVisibility={true}+ description={+ messageProperty.description && (+ <ReactMarkdown>{messageProperty.description}</ReactMarkdown>+ )+ }+ />+ <div className="relative h-96">+ <CodeEditor+ id="code-id"+ loading={!isLoaded}+ language="html"+ className="!mb-0 h-96 overflow-hidden rounded border"+ onInputChange={(e: string | undefined) => setBodyValue(e ?? '')}+ options={{ wordWrap: 'off', contextmenu: false }}+ value={bodyValue}+ />+ </div>+ </>+ )}+ <div className="col-span-12 flex w-full justify-between">+ <FormActions+ handleReset={() => {+ resetForm({+ values: authConfig.config,+ initialValues: authConfig.config,+ })+ setBodyValue(authConfig?.config?.[messageSlug])+ }}+ form={formId}+ isSubmitting={isSubmitting}+ hasChanges={hasChanges}+ />+ </div>+ </FormSectionContent>+ </FormSection>+ </>+ )+ }}+ </Form>+ )+}++export default observer(TemplateEditor)diff --git a/studio/components/interfaces/Auth/RedirectDomains.tsx b/studio/components/interfaces/Auth/RedirectDomains.tsxdeleted file mode 100644index 5f1720a1f16..00000000000--- a/studio/components/interfaces/Auth/RedirectDomains.tsx+++ /dev/null@@ -1,249 +0,0 @@-import { Button, Form, IconGlobe, IconTrash, Input, Modal } from '@supabase/ui'-import { FormHeader } from 'components/ui/Forms'-import { HorizontalShimmerWithIcon } from 'components/ui/Shimmers'-import { EmptyListState } from 'components/ui/States'-import { useStore } from 'hooks'-import { observer } from 'mobx-react-lite'-import { useState } from 'react'-import { object, string } from 'yup'--const RedirectDomains = () => {- const { authConfig, ui } = useStore()-- const URI_ALLOW_LIST_ARRAY = authConfig.config.URI_ALLOW_LIST- ? authConfig.config.URI_ALLOW_LIST.split(',')- : []-- const [deleteOpen, setDeleteOpen] = useState(false)- const [deleteLoading, setDeleteLoading] = useState(false)- const [selectedDomain, setSelected] = useState('')-- /**- *- * regex from: https://stackoverflow.com/a/68002755/4807782- *- * examples of matches:- *- * "vercel.com"- * "www.vercel.com"- * "uptime-monitor-fe.vercel.app"- * "https://uptime-monitor-fe.vercel.app/"- *- */- const domainRegex =- /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/gm-- let newDomainSchema = object({- domain: string().matches(domainRegex, 'URL is not valid').required(),- })-- const Main = () => {- const [open, setOpen] = useState(false)-- return (- <>- <div className="flex items-center justify-between">- <FormHeader- title="Redirect URLs"- description={`URLs that auth providers are permitted to redirect to post authentication`}- />- <Button onClick={() => setOpen(true)}>Add domain</Button>- <Modal- size="small"- visible={open}- onCancel={() => setOpen(!open)}- header={<h3 className="text-sm">Add a new domain</h3>}- hideFooter- >- <Form- id="new-domain-form"- initialValues={{- domain: '',- }}- validateOnBlur- validationSchema={newDomainSchema}- onSubmit={async (values: any, { setSubmitting }: any) => {- setSubmitting(true)- try {- const payload = URI_ALLOW_LIST_ARRAY- await payload.push(values.domain)- // convert payload to comma seperated string- // and update- authConfig.update({ URI_ALLOW_LIST: payload.toString() })- setSubmitting(false)- setOpen(false)- } catch (error: any) {- setSubmitting(false)- ui.notification?.error('Failed to update domain: ', error?.message)- }- }}- >- {({ isSubmitting }: any) => {- return (- <div className="mb-4 space-y-4 pt-4">- <div className="px-5">- <p className="text-scale-1100 text-sm">- This will add a domain to a list of allowed domains that can interact with- your Authenticaton services for this project.- </p>- </div>- <div className="border-overlay-border border-t"></div>- <div className="px-5">- <Input- id="domain"- name="domain"- label="Domain"- placeholder="https://mydomain.com"- />- </div>- <div className="border-overlay-border border-t"></div>- <div className="px-5">- <Button- form="new-domain-form"- htmlType="submit"- block- size="medium"- loading={isSubmitting}- >- Add domain- </Button>- </div>- </div>- )- }}- </Form>- </Modal>- </div>- </>- )- }-- const ValueContainer = ({ children }: { children: React.ReactNode }) => (- <div- className="- bg-scale-100 dark:bg-scale-300 border-scale-500 text-scale-1200 flex items-center- justify-between gap-2- border px-6- py-4 text-sm- first:rounded-tr first:rounded-tl last:rounded-br last:rounded-bl- "- >- {children}- </div>- )-- return (- <div>- <Main />- <div className="-space-y-px">- {!authConfig.isLoaded ? (- <>- <ValueContainer>- <HorizontalShimmerWithIcon />- </ValueContainer>- <ValueContainer>- <HorizontalShimmerWithIcon />- </ValueContainer>- </>- ) : URI_ALLOW_LIST_ARRAY.length > 0 ? (- URI_ALLOW_LIST_ARRAY.map((domain: string) => {- return (- <>- <ValueContainer>- <div className="flex items-center gap-2 font-mono">- <span className="text-scale-900">- <IconGlobe strokeWidth={2} size={14} />- </span>- {domain}- </div>- <Button- type="default"- icon={<IconTrash />}- onClick={() => {- setSelected(domain)- setDeleteOpen(true)- }}- >- Remove- </Button>- </ValueContainer>- </>- )- })- ) : (- <div- className="- bg-scale-200 border-scale-400 text-scale-1200 flex items-center- justify-center- gap-2 rounded- border- px-6 py-8- text-sm- "- >- <EmptyListState- title="No Redirect URLs"- description="Auth providers may need a URL to redirect back to"- />- </div>- )}- </div>- <Modal- size="small"- visible={deleteOpen}- onCancel={() => setDeleteOpen(!open)}- header={<h3 className="text-sm">Remove domain</h3>}- hideFooter- >- <div className="mb-4 space-y-4 pt-4">- <div className="px-5">- <p className="text-scale-1100 mb-2 text-sm">- Are you sure you want to remove{' '}- <span className="text-scale-1200">{selectedDomain}</span>?- </p>- <p className="text-scale-900 text-sm">- This domain will no longer work with your Authentication configuration.- </p>- </div>- <div className="border-overlay-border border-t"></div>- <div className="flex gap-3 px-5">- <Button- type="default"- block- size="medium"- onClick={() => {- // setOpen(!open)- }}- >- Cancel- </Button>- <Button- block- size="medium"- type="warning"- loading={deleteLoading}- onClick={async () => {- setDeleteLoading(true)- try {- // remove selectedDomain from array- const payload = URI_ALLOW_LIST_ARRAY.filter((e: string) => e !== selectedDomain)- // and update- await authConfig.update({ URI_ALLOW_LIST: payload.toString() })- setDeleteLoading(false)- setDeleteOpen(false)- } catch (error: any) {- setDeleteLoading(false)- ui.notification?.error('Failed to remove domain: ', error?.message)- }- }}- >- {deleteLoading ? 'Removing...' : 'Remove domain'}- </Button>- </div>- </div>- </Modal>- </div>- )-}--export default observer(RedirectDomains)diff --git a/studio/components/interfaces/Auth/RedirectDomains/DomainList.tsx b/studio/components/interfaces/Auth/RedirectDomains/DomainList.tsxnew file mode 100644index 00000000000..622d87f4dbb--- /dev/null+++ b/studio/components/interfaces/Auth/RedirectDomains/DomainList.tsx@@ -0,0 +1,71 @@+import { FC } from 'react'+import { observer } from 'mobx-react-lite'+import { Button, IconGlobe, IconTrash } from '@supabase/ui'++import { useStore } from 'hooks'+import ValueContainer from './ValueContainer'+import { EmptyListState } from 'components/ui/States'+import { HorizontalShimmerWithIcon } from 'components/ui/Shimmers'++interface Props {+ onSelectDomainToDelete: (domain: string) => void+}++const DomainList: FC<Props> = ({ onSelectDomainToDelete }) => {+ const { authConfig } = useStore()++ const URI_ALLOW_LIST_ARRAY = authConfig.config.URI_ALLOW_LIST+ ? authConfig.config.URI_ALLOW_LIST.split(',')+ : []++ return (+ <div className="-space-y-px">+ {!authConfig.isLoaded ? (+ <>+ <ValueContainer>+ <HorizontalShimmerWithIcon />+ </ValueContainer>+ <ValueContainer>+ <HorizontalShimmerWithIcon />+ </ValueContainer>+ </>+ ) : URI_ALLOW_LIST_ARRAY.length > 0 ? (+ URI_ALLOW_LIST_ARRAY.map((domain: string) => {+ return (+ <>+ <ValueContainer>+ <div className="flex items-center gap-2 font-mono">+ <span className="text-scale-900">+ <IconGlobe strokeWidth={2} size={14} />+ </span>+ {domain}+ </div>+ <Button+ type="default"+ icon={<IconTrash />}+ onClick={() => onSelectDomainToDelete(domain)}+ >+ Remove+ </Button>+ </ValueContainer>+ </>+ )+ })+ ) : (+ <div+ className={[+ 'bg-scale-200 border-scale-400 text-scale-1200 flex items-center',+ 'justify-center gap-2 rounded border px-6 py-8 text-sm',+ ].join(' ')}+ >+ <EmptyListState+ title="No Redirect URLs"+ description="Auth providers may need a URL to redirect back to"+ />+ </div>+ )}+ </div>+ )+}++export default observer(DomainList)diff --git a/studio/components/interfaces/Auth/RedirectDomains/RedirectDomains.constants.ts b/studio/components/interfaces/Auth/RedirectDomains/RedirectDomains.constants.tsnew file mode 100644index 00000000000..dd603bd2fc1--- /dev/null+++ b/studio/components/interfaces/Auth/RedirectDomains/RedirectDomains.constants.ts@@ -0,0 +1,13 @@+// [Joshen] Currently using the latter regex as the former is too strict, doesn't support+// localhost - if we can combine these 2 together that'll be great but my regex-foo isn't too strong++// Regex from: https://stackoverflow.com/a/68002755/4807782+// examples of matches:+// "vercel.com"+// "www.vercel.com"+// "uptime-monitor-fe.vercel.app"+// "https://uptime-monitor-fe.vercel.app/"+export const domainRegexStrict =+ /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/gm++export const domainRegex = /^(ftp|http|https):\/\/\w+(\.\w+)*(:[0-9]+)?\/?(\/[.\w]*)*$/gdiff --git a/studio/components/interfaces/Auth/RedirectDomains/RedirectDomains.tsx b/studio/components/interfaces/Auth/RedirectDomains/RedirectDomains.tsxnew file mode 100644index 00000000000..dacaa4ca341--- /dev/null+++ b/studio/components/interfaces/Auth/RedirectDomains/RedirectDomains.tsx@@ -0,0 +1,159 @@+import { useState } from 'react'+import { object, string } from 'yup'+import { observer } from 'mobx-react-lite'+import { Button, Form, Input, Modal } from '@supabase/ui'++import { useStore } from 'hooks'+import { FormHeader } from 'components/ui/Forms'+import { domainRegex } from './RedirectDomains.constants'+import DomainList from './DomainList'++const RedirectDomains = () => {+ const { authConfig, ui } = useStore()++ const URI_ALLOW_LIST_ARRAY = authConfig.config.URI_ALLOW_LIST+ ? authConfig.config.URI_ALLOW_LIST.split(',')+ : []++ const [open, setOpen] = useState(false)+ const [isDeleting, setIsDeleting] = useState(false)+ const [selectedDomainToDelete, setSelectedDomainToDelete] = useState<string>()++ const newDomainSchema = object({+ domain: string().matches(domainRegex, 'URL is not valid').required(),+ })++ const onAddNewDomain = async (values: any, { setSubmitting }: any) => {+ setSubmitting(true)+ try {+ const payload = URI_ALLOW_LIST_ARRAY+ await payload.push(values.domain)+ // convert payload to comma seperated string and update+ authConfig.update({ URI_ALLOW_LIST: payload.toString() })+ setSubmitting(false)+ setOpen(false)+ } catch (error: any) {+ setSubmitting(false)+ ui.notification?.error('Failed to update domain: ', error?.message)+ }+ }++ const onConfirmDeleteDomain = async (domain?: string) => {+ if (!domain) return++ setIsDeleting(true)+ try {+ // Remove selectedDomain from array and update+ const payload = URI_ALLOW_LIST_ARRAY.filter((e: string) => e !== domain)+ await authConfig.update({ URI_ALLOW_LIST: payload.toString() })+ setIsDeleting(false)+ setSelectedDomainToDelete(undefined)+ } catch (error: any) {+ setIsDeleting(false)+ ui.notification?.error('Failed to remove domain: ', error?.message)+ }+ }++ return (+ <div>+ <div className="flex items-center justify-between">+ <FormHeader+ title="Redirect URLs"+ description="URLs that auth providers are permitted to redirect to post authentication"+ />+ <Button onClick={() => setOpen(true)}>Add domain</Button>+ </div>+ <DomainList onSelectDomainToDelete={setSelectedDomainToDelete} />+ <Modal+ hideFooter+ size="small"+ visible={open}+ onCancel={() => setOpen(!open)}+ header={<h3 className="text-sm">Add a new domain</h3>}+ >+ <Form+ validateOnBlur+ id="new-domain-form"+ initialValues={{ domain: '' }}+ validationSchema={newDomainSchema}+ onSubmit={onAddNewDomain}+ >+ {({ isSubmitting }: { isSubmitting: boolean }) => {+ return (+ <div className="mb-4 space-y-4 pt-4">+ <div className="px-5">+ <p className="text-scale-1100 text-sm">+ This will add a domain to a list of allowed domains that can interact with your+ Authenticaton services for this project.+ </p>+ </div>+ <div className="border-overlay-border border-t" />+ <div className="px-5">+ <Input+ id="domain"+ name="domain"+ label="Domain"+ placeholder="https://mydomain.com"+ />+ </div>+ <div className="border-overlay-border border-t" />+ <div className="px-5">+ <Button+ block+ form="new-domain-form"+ htmlType="submit"+ size="medium"+ loading={isSubmitting}+ >+ Add domain+ </Button>+ </div>+ </div>+ )+ }}+ </Form>+ </Modal>+ <Modal+ hideFooter+ size="small"+ visible={selectedDomainToDelete !== undefined}+ header={<h3 className="text-sm">Remove domain</h3>}+ onCancel={() => setSelectedDomainToDelete(undefined)}+ >+ <div className="mb-4 space-y-4 pt-4">+ <div className="px-5">+ <p className="text-scale-1100 mb-2 text-sm">+ Are you sure you want to remove{' '}+ <span className="text-scale-1200">{selectedDomainToDelete}</span>?+ </p>+ <p className="text-scale-1100 text-sm">+ This domain will no longer work with your authentication configuration.+ </p>+ </div>+ <div className="border-overlay-border border-t"></div>+ <div className="flex gap-3 px-5">+ <Button+ block+ type="default"+ size="medium"+ onClick={() => setSelectedDomainToDelete(undefined)}+ >+ Cancel+ </Button>+ <Button+ block+ size="medium"+ type="warning"+ loading={isDeleting}+ onClick={() => onConfirmDeleteDomain(selectedDomainToDelete)}+ >+ {isDeleting ? 'Removing...' : 'Remove domain'}+ </Button>+ </div>+ </div>+ </Modal>+ </div>+ )+}++export default observer(RedirectDomains)diff --git a/studio/components/interfaces/Auth/RedirectDomains/ValueContainer.tsx b/studio/components/interfaces/Auth/RedirectDomains/ValueContainer.tsxnew file mode 100644index 00000000000..c7dd41fb552--- /dev/null+++ b/studio/components/interfaces/Auth/RedirectDomains/ValueContainer.tsx@@ -0,0 +1,21 @@+import { FC, ReactNode } from 'react'++interface Props {+ children: ReactNode+}++const ValueContainer: FC<Props> = ({ children }) => (+ <div+ className="+ bg-scale-100 dark:bg-scale-300 border-scale-500 text-scale-1200 flex items-center+ justify-between gap-2+ border px-6+ py-4 text-sm+ first:rounded-tr first:rounded-tl last:rounded-br last:rounded-bl+ "+ >+ {children}+ </div>+)++export default ValueContainerdiff --git a/studio/components/interfaces/Auth/SmtpForm.tsx b/studio/components/interfaces/Auth/SmtpForm.tsxdeleted file mode 100644index cb588c58ebb..00000000000--- a/studio/components/interfaces/Auth/SmtpForm.tsx+++ /dev/null@@ -1,338 +0,0 @@-import { Form, Input, Toggle } from '@supabase/ui'-import { useStore } from 'hooks'-import { observer } from 'mobx-react-lite'-import { useEffect, useState } from 'react'-import { number, object, string } from 'yup'-import {- FormActions,- FormHeader,- FormPanel,- FormSection,- FormSectionContent,- FormSectionLabel,-} from '../../ui/Forms'--const SmtpForm = observer(() => {- const { authConfig, ui } = useStore()- const [enableSmtp, setEnableSmtp] = useState(false)-- function generateInitialValues(config: any) {- return {- ENABLE_SMTP: enableSmtp,- SMTP_ADMIN_EMAIL: config.SMTP_ADMIN_EMAIL ?? '',- SMTP_SENDER_NAME: config.SMTP_SENDER_NAME ?? '',- SMTP_USER: config.SMTP_USER ?? '',- SMTP_HOST: config.SMTP_HOST ?? '',- SMTP_PASS: config.SMTP_PASS ?? '',- SMTP_PORT: config.SMTP_PORT ?? 465,- SMTP_MAX_FREQUENCY: config.SMTP_MAX_FREQUENCY ?? undefined,- }- }-- function checkSmtpState(config: any, resetForm: () => void) {- if (- config.SMTP_ADMIN_EMAIL &&- config.SMTP_SENDER_NAME &&- config.SMTP_USER &&- config.SMTP_HOST &&- config.SMTP_PASS &&- config.SMTP_PORT &&- config.SMTP_MAX_FREQUENCY > 0- ) {- setEnableSmtp(true)- return resetForm- } else {- setEnableSmtp(false)- return resetForm- }- }-- /**- * domain and IP address regex- *- * example of matches:- *- * "vercel.com"- * "www.vercel.com"- * "uptime-monitor-fe.vercel.app"- * "https://uptime-monitor-fe.vercel.app/"- * "127.0.0.0"- *- */- const domainRegex =- /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$|^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.){3}(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)$/gm-- const schema = object({- SMTP_ADMIN_EMAIL: string().when([], {- is: () => {- return enableSmtp- },- then: (schema) => schema.email('Must be a valid email').required('Sender email is required'),- otherwise: (schema) => schema,- }),- SMTP_SENDER_NAME: string().when([], {- is: () => {- return enableSmtp- },- then: (schema) => schema.required('Sender name is required'),- otherwise: (schema) => schema,- }),- SMTP_HOST: string().when([], {- is: () => {- return enableSmtp- },- then: (schema) =>- schema- .matches(domainRegex, 'Must be a valid URL or IP address')- .required('Host URL is required.'),- otherwise: (schema) => schema,- }),- SMTP_PORT: number().when([], {- is: () => {- return enableSmtp- },- then: (schema) =>- schema- .required('Port number is required.')- .min(1, 'Must be a valid port number more than 0')- .max(65535, 'Must be a valid port number no more than 65535'),- otherwise: (schema) => schema,- }),- SMTP_MAX_FREQUENCY: number().when([], {- is: () => {- return enableSmtp- },- then: (schema) =>- schema- .required('Rate limit is required.')- .min(1, 'Must be more than 0')- .max(32767, 'Must not be more than 32,767 an hour'),- otherwise: (schema) => schema,- }),- SMTP_USER: string().when([], {- is: () => {- return enableSmtp- },- then: (schema) => schema.required('SMTP Username is required'),- otherwise: (schema) => schema,- }),- SMTP_PASS: string().when([], {- is: () => {- return enableSmtp- },- then: (schema) => schema.required('SMTP password is required'),- otherwise: (schema) => schema,- }),- })-- const isLoaded = authConfig.isLoaded- const formId = 'auth-config-smtp-form'-- return (- <>- <Form- id={formId}- initialValues={generateInitialValues(authConfig.config)}- onSubmit={async (values: any, { setSubmitting, resetForm }: any) => {- const payload = { ...values }- payload.SMTP_PORT = values.SMTP_PORT.toString()-- // remove rendundant value- delete payload.ENABLE_SMTP-- if (!enableSmtp) {- payload.SMTP_ADMIN_EMAIL = null- payload.SMTP_SENDER_NAME = null- payload.SMTP_USER = null- payload.SMTP_HOST = null- payload.SMTP_PASS = null- payload.SMTP_PORT = null- payload.SMTP_MAX_FREQUENCY = 60- }-- try {- setSubmitting(true)- await authConfig.update(payload)- setSubmitting(false)- ui.setNotification({- category: 'success',- message: `Updated settings`,- })-- checkSmtpState(- payload,- resetForm({- values: !enableSmtp ? generateInitialValues(payload) : payload,- initialValues: generateInitialValues(payload),- })- )- } catch (error) {- ui.setNotification({- category: 'error',- message: `Failed to update settings`,- })- setSubmitting(false)- }- }}- validationSchema={schema}- >- {({ isSubmitting, resetForm, values, initialValues }: any) => {- /**- * Tracks changes in form- */- const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)-- /**- * Form is reset once remote data is loaded in store- */- useEffect(() => {- checkSmtpState(authConfig.config, () =>- resetForm({- values: generateInitialValues(authConfig.config),- initialValues: generateInitialValues(authConfig.config),- })- )- }, [authConfig.isLoaded])-- return (- <>- <FormHeader- title="SMTP Settings"- description={`You can use your own SMTP server instead of the built-in email service.`}- />- <FormPanel- footer={- <div className="flex justify-between py-4 px-8">- <FormActions- handleReset={() => {- checkSmtpState(authConfig.config, () =>- resetForm({- values: generateInitialValues(authConfig.config),- initialValues: generateInitialValues(authConfig.config),- })- )- }}- form={formId}- isSubmitting={isSubmitting}- hasChanges={hasChanges}- helper={'Learn more about global Auth settings'}- />- </div>- }- >- <FormSection>- <FormSectionContent loading={!isLoaded}>- <Toggle- name="ENABLE_SMTP"- size="small"- label="Enable Custom SMTP"- layout="flex"- checked={enableSmtp}- onChange={() => {- resetForm({- values: generateInitialValues(authConfig.config),- initialValues: generateInitialValues(authConfig.config),- })- setEnableSmtp(!enableSmtp)- }}- descriptionText="Emails will be sent using your custom SMTP provider"- />- </FormSectionContent>- </FormSection>-- <FormSection- visible={enableSmtp}- header={<FormSectionLabel>Sender details</FormSectionLabel>}- disabled={!enableSmtp}- >- <FormSectionContent loading={!isLoaded}>- <Input- name="SMTP_ADMIN_EMAIL"- id="SMTP_ADMIN_EMAIL"- label="Sender email"- descriptionText="This is the email address the emails are sent from"- placeholder="[email protected]"- />- <Input- name="SMTP_SENDER_NAME"- id="SMTP_SENDER_NAME"- label="Sender name"- descriptionText="Name displayed in the recipient's inbox"- placeholder="The name shown on the email"- />- </FormSectionContent>- </FormSection>-- <FormSection- visible={enableSmtp}- disabled={!enableSmtp}- header={- <FormSectionLabel>- <span>SMTP Provider Settings</span>- <p className="text-scale-900 my-4">- Your SMTP Credentials will always be encrypted in our database.- </p>- </FormSectionLabel>- }- >- <FormSectionContent loading={!isLoaded}>- <Input- name="SMTP_HOST"- placeholder="your.smtp.host.com"- id="SMTP_HOST"- label="Host"- descriptionText="Hostname or IP address of your SMTP server."- />- <Input- type="number"- name="SMTP_PORT"- placeholder="587"- id="SMTP_PORT"- label="Port number"- // @ts-ignore- descriptionText={- <>- <span className="block">- Port used by your SMTP server. Common ports include 25, 465, and 587.{' '}- </span>- <span className="mt-2 block">- Avoid using port 25 as modern SMTP email clients shouldn't use this- port, it is traditionally blocked by residential ISPs and Cloud Hosting- Providers, to curb the amount of spam.- </span>- </>- }- />- <Input- type="number"- name="SMTP_MAX_FREQUENCY"- id="SMTP_MAX_FREQUENCY"- min={0}- label="Rate limit"- descriptionText="Maximum number of emails sent per hour"- actions={<span className="text-scale-900 mr-3">emails per hour</span>}- />- <Input- name="SMTP_USER"- id="SMTP_USER"- label="Username"- placeholder="SMTP Username"- />- <Input- name="SMTP_PASS"- id="SMTP_PASS"- label="Password"- placeholder="SMTP Password"- />- </FormSectionContent>- </FormSection>- </FormPanel>- </>- )- }}- </Form>- </>- )-})--export { SmtpForm }diff --git a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.constants.ts b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.constants.tsnew file mode 100644index 00000000000..75ac33df702--- /dev/null+++ b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.constants.ts@@ -0,0 +1,24 @@+/**+ * domain and IP address regex+ *+ * example of matches:+ *+ * "vercel.com"+ * "www.vercel.com"+ * "uptime-monitor-fe.vercel.app"+ * "https://uptime-monitor-fe.vercel.app/"+ * "127.0.0.0"+ *+ */+export const domainRegex =+ /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$|^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.){3}(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)$/gm++export const defaultDisabledSmtpFormValues = {+ SMTP_ADMIN_EMAIL: null,+ SMTP_SENDER_NAME: null,+ SMTP_USER: null,+ SMTP_HOST: null,+ SMTP_PASS: null,+ SMTP_PORT: null,+ SMTP_MAX_FREQUENCY: 60,+}diff --git a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsxnew file mode 100644index 00000000000..1b2e8ed0119--- /dev/null+++ b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx@@ -0,0 +1,268 @@+import { useEffect, useState } from 'react'+import { number, object, string } from 'yup'+import { observer } from 'mobx-react-lite'+import { Form, Input, Toggle, Alert } from '@supabase/ui'++import { useStore } from 'hooks'+import {+ FormActions,+ FormHeader,+ FormPanel,+ FormSection,+ FormSectionContent,+ FormSectionLabel,+} from 'components/ui/Forms'+import { domainRegex, defaultDisabledSmtpFormValues } from './SmtpForm.constants'+import { isSmtpEnabled, generateFormValues } from './SmtpForm.utils'++const SmtpForm = () => {+ const { authConfig, ui } = useStore()+ const [enableSmtp, setEnableSmtp] = useState(false)+ const { config, isLoaded } = authConfig++ const formId = 'auth-config-smtp-form'+ const initialValues = generateFormValues(authConfig.config)++ useEffect(() => {+ if (isLoaded && isSmtpEnabled(config)) {+ setEnableSmtp(true)+ }+ }, [isLoaded])++ const schema = object({+ SMTP_ADMIN_EMAIL: string().when([], {+ is: () => {+ return enableSmtp+ },+ then: (schema) => schema.email('Must be a valid email').required('Sender email is required'),+ otherwise: (schema) => schema,+ }),+ SMTP_SENDER_NAME: string().when([], {+ is: () => {+ return enableSmtp+ },+ then: (schema) => schema.required('Sender name is required'),+ otherwise: (schema) => schema,+ }),+ SMTP_HOST: string().when([], {+ is: () => {+ return enableSmtp+ },+ then: (schema) =>+ schema+ .matches(domainRegex, 'Must be a valid URL or IP address')+ .required('Host URL is required.'),+ otherwise: (schema) => schema,+ }),+ SMTP_PORT: number().when([], {+ is: () => {+ return enableSmtp+ },+ then: (schema) =>+ schema+ .required('Port number is required.')+ .min(1, 'Must be a valid port number more than 0')+ .max(65535, 'Must be a valid port number no more than 65535'),+ otherwise: (schema) => schema,+ }),+ SMTP_MAX_FREQUENCY: number().when([], {+ is: () => {+ return enableSmtp+ },+ then: (schema) =>+ schema+ .required('Rate limit is required.')+ .min(1, 'Must be more than 0')+ .max(32767, 'Must not be more than 32,767 an hour'),+ otherwise: (schema) => schema,+ }),+ SMTP_USER: string().when([], {+ is: () => {+ return enableSmtp+ },+ then: (schema) => schema.required('SMTP Username is required'),+ otherwise: (schema) => schema,+ }),+ SMTP_PASS: string().when([], {+ is: () => {+ return enableSmtp+ },+ then: (schema) => schema.required('SMTP password is required'),+ otherwise: (schema) => schema,+ }),+ })++ const onSubmit = async (values: any, { setSubmitting, resetForm }: any) => {+ const payload = enableSmtp ? values : defaultDisabledSmtpFormValues++ // Format payload: Remove redundant value + convert port to string+ delete payload.ENABLE_SMTP+ payload.SMTP_PORT = payload.SMTP_PORT ? payload.SMTP_PORT.toString() : payload.SMTP_PORT++ try {+ setSubmitting(true)+ await authConfig.update(payload)+ ui.setNotification({ category: 'success', message: 'Successfully updated settings' })++ const updatedFormValues = generateFormValues(payload)+ resetForm({ values: updatedFormValues, initialValues: updatedFormValues })+ } catch (error) {+ ui.setNotification({ category: 'error', message: 'Failed to update settings', error })+ } finally {+ setSubmitting(false)+ }+ }++ return (+ <Form id={formId} initialValues={initialValues} onSubmit={onSubmit} validationSchema={schema}>+ {({ isSubmitting, resetForm, values }: any) => {+ const isValidSmtpConfig = isSmtpEnabled(values)+ const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)++ useEffect(() => {+ if (isLoaded) {+ const formValues = generateFormValues(config)+ resetForm({ values: formValues, initialValues: formValues })+ }+ }, [isLoaded])++ const onResetForm = () => {+ setEnableSmtp(isSmtpEnabled(initialValues))+ resetForm({ values: initialValues })+ }++ return (+ <>+ <FormHeader+ title="SMTP Settings"+ description="You can use your own SMTP server instead of the built-in email service."+ />+ <FormPanel+ footer={+ <div className="flex justify-between py-4 px-8">+ <FormActions+ form={formId}+ isSubmitting={isSubmitting}+ hasChanges={hasChanges}+ handleReset={onResetForm}+ />+ </div>+ }+ >+ <FormSection>+ <FormSectionContent loading={!isLoaded}>+ <Toggle+ name="ENABLE_SMTP"+ size="small"+ label="Enable Custom SMTP"+ layout="flex"+ checked={enableSmtp}+ // @ts-ignore+ onChange={(value: boolean) => setEnableSmtp(value)}+ descriptionText="Emails will be sent using your custom SMTP provider"+ />+ </FormSectionContent>+ </FormSection>++ {enableSmtp && !isValidSmtpConfig && (+ <div className="mx-8 mb-8 -mt-4">+ <Alert withIcon variant="warning" title="All fields below must be filled">+ The following fields must be filled before custom SMTP can be properly enabled+ </Alert>+ </div>+ )}++ <FormSection+ visible={enableSmtp}+ header={<FormSectionLabel>Sender details</FormSectionLabel>}+ disabled={!enableSmtp}+ >+ <FormSectionContent loading={!isLoaded}>+ <Input+ name="SMTP_ADMIN_EMAIL"+ id="SMTP_ADMIN_EMAIL"+ label="Sender email"+ descriptionText="This is the email address the emails are sent from"+ placeholder="[email protected]"+ />+ <Input+ name="SMTP_SENDER_NAME"+ id="SMTP_SENDER_NAME"+ label="Sender name"+ descriptionText="Name displayed in the recipient's inbox"+ placeholder="The name shown on the email"+ />+ </FormSectionContent>+ </FormSection>++ <FormSection+ visible={enableSmtp}+ disabled={!enableSmtp}+ header={+ <FormSectionLabel>+ <span>SMTP Provider Settings</span>+ <p className="text-scale-900 my-4">+ Your SMTP Credentials will always be encrypted in our database.+ </p>+ </FormSectionLabel>+ }+ >+ <FormSectionContent loading={!isLoaded}>+ <Input+ name="SMTP_HOST"+ placeholder="your.smtp.host.com"+ id="SMTP_HOST"+ label="Host"+ descriptionText="Hostname or IP address of your SMTP server."+ />+ <Input+ type="number"+ name="SMTP_PORT"+ placeholder="587"+ id="SMTP_PORT"+ label="Port number"+ descriptionText={+ <>+ <span className="block">+ Port used by your SMTP server. Common ports include 25, 465, and 587.{' '}+ </span>+ <span className="mt-2 block">+ Avoid using port 25 as modern SMTP email clients shouldn't use this port,+ it is traditionally blocked by residential ISPs and Cloud Hosting+ Providers, to curb the amount of spam.+ </span>+ </>+ }+ />+ <Input+ type="number"+ name="SMTP_MAX_FREQUENCY"+ id="SMTP_MAX_FREQUENCY"+ min={0}+ label="Rate limit"+ descriptionText="Maximum number of emails sent per hour"+ actions={<span className="text-scale-900 mr-3">emails per hour</span>}+ />+ <Input+ name="SMTP_USER"+ id="SMTP_USER"+ label="Username"+ placeholder="SMTP Username"+ />+ <Input+ name="SMTP_PASS"+ id="SMTP_PASS"+ label="Password"+ placeholder="SMTP Password"+ />+ </FormSectionContent>+ </FormSection>+ </FormPanel>+ </>+ )+ }}+ </Form>+ )+}++export default observer(SmtpForm)diff --git a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.utils.ts b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.utils.tsnew file mode 100644index 00000000000..2dc008d8eac--- /dev/null+++ b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.utils.ts@@ -0,0 +1,31 @@+import { AuthConfig } from '../Auth.types'++interface AuthConfigForm extends AuthConfig {+ ENABLE_SMTP: boolean+}++// [Joshen TODO] Type properly and write tests+export const isSmtpEnabled = (config?: Partial<AuthConfig>): boolean => {+ return !!(+ config?.SMTP_ADMIN_EMAIL &&+ config?.SMTP_SENDER_NAME &&+ config?.SMTP_USER &&+ config?.SMTP_HOST &&+ config?.SMTP_PASS &&+ config?.SMTP_PORT &&+ (config?.SMTP_MAX_FREQUENCY ?? 0) > 0+ )+}++export const generateFormValues = (config?: Partial<AuthConfig>): Partial<AuthConfigForm> => {+ return {+ ENABLE_SMTP: isSmtpEnabled(config),+ SMTP_ADMIN_EMAIL: config?.SMTP_ADMIN_EMAIL ?? '',+ SMTP_SENDER_NAME: config?.SMTP_SENDER_NAME ?? '',+ SMTP_USER: config?.SMTP_USER ?? '',+ SMTP_HOST: config?.SMTP_HOST ?? '',+ SMTP_PASS: config?.SMTP_PASS ?? '',+ SMTP_PORT: config?.SMTP_PORT ?? 465,+ SMTP_MAX_FREQUENCY: config?.SMTP_MAX_FREQUENCY ?? 60,+ }+}diff --git a/studio/components/interfaces/Auth/index.tsx b/studio/components/interfaces/Auth/index.tsxindex acf40966d8e..1c060c17c5e 100644--- a/studio/components/interfaces/Auth/index.tsx+++ b/studio/components/interfaces/Auth/index.tsx@@ -1,5 +1,5 @@-import AuthProvidersForm from './AuthProvidersForm'-import { SmtpForm } from './SmtpForm'-import { EmailTemplates } from './EmailTemplates'+import AuthProvidersForm from './AuthProvidersForm/AuthProvidersForm'+import EmailTemplates from './EmailTemplates/EmailTemplates'+import SmtpForm from './SmtpForm/SmtpForm'-export { AuthProvidersForm, SmtpForm, EmailTemplates }+export { AuthProvidersForm, EmailTemplates, SmtpForm }diff --git a/studio/components/layouts/AuthLayout/AuthLayout.utils.ts b/studio/components/layouts/AuthLayout/AuthLayout.utils.tsindex 6e7de901308..b080ea87ec2 100644--- a/studio/components/layouts/AuthLayout/AuthLayout.utils.ts+++ b/studio/components/layouts/AuthLayout/AuthLayout.utils.ts@@ -8,7 +8,6 @@ export const generateAuthMenu = (ref: string): ProductMenuGroup[] => {items: [{ name: 'Users', key: 'users', url: `/project/${ref}/auth/users`, items: [] },{ name: 'Policies', key: 'policies', url: `/project/${ref}/auth/policies`, items: [] },- { name: 'Templates', key: 'templates', url: `/project/${ref}/auth/templates`, items: [] },...(IS_PLATFORM? [{diff --git a/studio/components/ui/Forms/FormSection.tsx b/studio/components/ui/Forms/FormSection.tsxindex 73de99532d8..1d1f0fec835 100644--- a/studio/components/ui/Forms/FormSection.tsx+++ b/studio/components/ui/Forms/FormSection.tsx@@ -14,7 +14,7 @@ const FormSection = ({className?: string}) => {const classes = [- 'grid grid-cols-12 gap-6 px-8 py-8 lg:gap-12',+ 'grid grid-cols-12 gap-6 px-8 py-8',`${disabled ? ' opacity-30' : ' opacity-100'}`,`${visible ? ' block' : ' hidden'}`,`${className}`,diff --git a/studio/components/ui/Forms/index.tsx b/studio/components/ui/Forms/index.tsxindex 9f129950e45..01e46414a8e 100644--- a/studio/components/ui/Forms/index.tsx+++ b/studio/components/ui/Forms/index.tsx@@ -1,5 +1,4 @@export * from './FormsContainer'-export * from '../../interfaces/Auth/AutoSchemaForm'export * from './FormHeader'export * from './FormSection'export * from './FormPanel'diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.jsindex 202ce43bfd6..7137465c57b 100644--- a/studio/localStores/storageExplorer/StorageExplorerStore.js+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js@@ -65,7 +65,11 @@ class StorageExplorerStore {selectedItemsToMove = []selectedFilePreview = {}- DEFAULT_OPTIONS = { limit: LIMIT, offset: OFFSET, sortBy: { column: this.sortBy, order: this.sortByOrder } }+ DEFAULT_OPTIONS = {+ limit: LIMIT,+ offset: OFFSET,+ sortBy: { column: this.sortBy, order: this.sortByOrder },+ }/* Supabase client */supabaseClient = null@@ -1182,7 +1186,11 @@ class StorageExplorerStore {formattedPathToFolder = `${prefix}/${name}`}- const options = { limit: LIMIT, offset: OFFSET, sortBy: { column: this.sortBy, order: this.sortByOrder } }+ const options = {+ limit: LIMIT,+ offset: OFFSET,+ sortBy: { column: this.sortBy, order: this.sortByOrder },+ }const { data: folderContents } = await this.supabaseClient.storage.from(this.selectedBucket.name).list(formattedPathToFolder, options)diff --git a/studio/package-lock.json b/studio/package-lock.jsonindex c75f6a3c085..08007a7c5bd 100644--- a/studio/package-lock.json+++ b/studio/package-lock.json@@ -22,7 +22,7 @@"@supabase/react-data-grid": "^7.1.0-beta.7","@supabase/shared-types": "^0.1.24","@supabase/supabase-js": "^1.35.3",- "@supabase/ui": "0.37.0-alpha.65",+ "@supabase/ui": "0.37.0-alpha.67","ajv": "^8.6.3","analytics-node": "^3.5.0","awesome-debounce-promise": "^2.1.0",@@ -8367,9 +8367,9 @@}},"node_modules/@supabase/ui": {- "version": "0.37.0-alpha.65",- "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.65.tgz",- "integrity": "sha512-11Pm/Q2j7JnhHtZ8uZ/tXF7uHenT4tJU9LCpfiHFgiPI91C9Kt0s4QvLiYehNLr8TxJ/rETz5uM5eODY6t4wmw==",+ "version": "0.37.0-alpha.67",+ "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.67.tgz",+ "integrity": "sha512-WnxwGq7HSrOFe9wdp6Gp2zuPNMxAp7PYBJ27RVxXnVGdfpOQhldxLLkfDXamgzAiPbNeJsMi/v7V26mMV8VM3w==","dependencies": {"@headlessui/react": "^1.0.0","@mertasan/tailwindcss-variables": "^2.0.1",@@ -36243,9 +36243,9 @@}},"@supabase/ui": {- "version": "0.37.0-alpha.65",- "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.65.tgz",- "integrity": "sha512-11Pm/Q2j7JnhHtZ8uZ/tXF7uHenT4tJU9LCpfiHFgiPI91C9Kt0s4QvLiYehNLr8TxJ/rETz5uM5eODY6t4wmw==",+ "version": "0.37.0-alpha.67",+ "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.67.tgz",+ "integrity": "sha512-WnxwGq7HSrOFe9wdp6Gp2zuPNMxAp7PYBJ27RVxXnVGdfpOQhldxLLkfDXamgzAiPbNeJsMi/v7V26mMV8VM3w==","requires": {"@headlessui/react": "^1.0.0","@mertasan/tailwindcss-variables": "^2.0.1",diff --git a/studio/package.json b/studio/package.jsonindex 37212575ab2..7a7baf67e07 100644--- a/studio/package.json+++ b/studio/package.json@@ -26,7 +26,7 @@"@supabase/react-data-grid": "^7.1.0-beta.7","@supabase/shared-types": "^0.1.24","@supabase/supabase-js": "^1.35.3",- "@supabase/ui": "0.37.0-alpha.65",+ "@supabase/ui": "0.37.0-alpha.67","ajv": "^8.6.3","analytics-node": "^3.5.0","awesome-debounce-promise": "^2.1.0",diff --git a/studio/pages/project/[ref]/auth/AuthFormSchema.tsx b/studio/pages/project/[ref]/auth/AuthFormSchema.tsxdeleted file mode 100644index 09ed076006f..00000000000--- a/studio/pages/project/[ref]/auth/AuthFormSchema.tsx+++ /dev/null@@ -1,293 +0,0 @@-import { object, string } from 'yup'--export default [- {- name: 'Email',- icon: 'email-icon',- form: [- {- type: 'text',- name: 'email-app-id',- label: 'email App Id',- description: '',- },- {- type: 'text',- name: 'email-id-key',- label: 'email client ID',- description: '',- },- {- type: 'text',- name: 'email-id-key',- label: 'email client ID',- description: '',- },- {- type: 'text',- name: 'email-id-key',- label: 'email client ID',- description: '',- },- ],- },- {- name: 'Phone',- icon: 'phone-icon',- form: [- {- type: 'select',- name: 'phone-app-provider',- label: 'Phone service provider',- description: 'You can use a provider etc etc',- },- {- type: 'text',- name: 'phone-id-key',- label: 'phone client ID',- description: '',- },- {- type: 'text',- name: 'phone-id-key',- label: 'phone client ID',- description: '',- },- {- type: 'text',- name: 'phone-id-key',- label: 'phone client ID',- description: '',- },- ],- },- {- name: 'Google',- icon: 'google-icon',- validationSchema: object({- 'google-app-id': string()- .required('You need THIS')- .min(7, 'Needs to be at least 7 characters')- .max(10, 'Can not be longer than 10 characters'),- 'google-id-key': string()- .required('You need THIS')- .min(7, 'Needs to be at least 7 characters')- .max(10, 'Can not be longer than 10 characters'),- }),- form: [- {- type: 'text',- name: 'google-app-id',- label: 'Google App Id',- description: '',- },- {- type: 'text',- name: 'google-id-key',- label: 'Google client ID',- description: '',- },- ],- },- {- name: 'Facebook',- icon: 'facebook-icon',- form: [- {- type: 'text',- name: 'facebook-app-id',- label: 'Facebook App Id',- description: '',- },- {- type: 'text',- name: 'facebook-id-key',- label: 'Facebook client ID',- description: '',- },- ],- },- {- name: 'Twitter',- icon: 'twitter-icon',- form: [- {- type: 'text',- name: 'twitter-app-id',- label: 'Twitter App Id',- description: '',- },- {- type: 'text',- name: 'twitter-id-key',- label: 'Twitter client ID',- description: '',- },- ],- },- {- name: 'Apple',- icon: 'apple-icon',- form: [- {- type: 'text',- name: 'apple-app-id',- label: 'Apple App Id',- description: '',- },- {- type: 'text',- name: 'apple-id-key',- label: 'Apple client ID',- description: '',- },- ],- },- {- name: 'Microsoft',- icon: 'microsoft-icon',- form: [- {- type: 'text',- name: 'microsoft-app-id',- label: 'Microsoft App Id',- description: '',- },- {- type: 'text',- name: 'microsoft-id-key',- label: 'Microsoft client ID',- description: '',- },- ],- },- {- name: 'Gitlab',- icon: 'gitlab-icon',- form: [- {- type: 'text',- name: 'gitlab-app-id',- label: 'Gitlab App Id',- description: '',- },- {- type: 'text',- name: 'gitlab-id-key',- label: 'Gitlab client ID',- description: '',- },- ],- },-- {- name: 'Bitbucket',- icon: 'bitbucket-icon',- form: [- {- type: 'text',- name: 'bitbucket-app-id',- label: 'Bitbucket App Id',- description: '',- },- {- type: 'text',- name: 'bitbucket-id-key',- label: 'Bitbucket client ID',- description: '',- },- ],- },- {- name: 'Discord',- icon: 'discord-icon',- form: [- {- type: 'text',- name: 'discord-app-id',- label: 'Discord App Id',- description: '',- },- {- type: 'text',- name: 'discord-id-key',- label: 'Discord client ID',- description: '',- },- ],- },-- {- name: 'Github',- icon: 'github-icon-dark',- form: [- {- type: 'text',- name: 'github-app-id',- label: 'Github App Id',- description: '',- },- {- type: 'text',- name: 'github-id-key',- label: 'Github client ID',- description: '',- },- ],- },-- {- name: 'Slack',- icon: 'slack-icon',- form: [- {- type: 'text',- name: 'slack-app-id',- label: 'Slack App Id',- description: '',- },- {- type: 'text',- name: 'slack-id-key',- label: 'Slack client ID',- description: '',- },- ],- },- {- name: 'Spotify',- icon: 'spotify-icon',- form: [- {- type: 'text',- name: 'spotify-app-id',- label: 'Spotify App Id',- description: '',- },- {- type: 'text',- name: 'spotify-id-key',- label: 'Spotify client ID',- description: '',- },- ],- },- {- name: 'Twitch',- icon: 'twitch-icon',- form: [- {- type: 'text',- name: 'twitch-app-id',- label: 'Twitch App Id',- description: '',- },- {- type: 'text',- name: 'twitch-id-key',- label: 'Twitch client ID',- description: '',- },- ],- },-]diff --git a/studio/pages/project/[ref]/auth/PhoneProvidersSchema.json b/studio/pages/project/[ref]/auth/PhoneProvidersSchema.jsondeleted file mode 100644index eb38715495a..00000000000--- a/studio/pages/project/[ref]/auth/PhoneProvidersSchema.json+++ /dev/null@@ -1,36 +0,0 @@- {- "name": "Twilio",- "icon": "twilio-icon",- "form": [- {- "type": "text",- "name": "twilio-app-id",- "label": "Enable twilio Provider",- "description": ""- },- {- "type": "text",- "name": "twilio-id-key",- "label": "twilio client ID",- "description": ""- }- ]- },- {- "name": "Messagebird",- "icon": "messagebird-icon",- "form": [- {- "type": "text",- "name": "messagebird-app-id",- "label": "Enable gitlab messagebird",- "description": ""- },- {- "type": "text",- "name": "messagebird-id-key",- "label": "messagebird client ID",- "description": ""- }- ]- }\ No newline at end of filediff --git a/studio/pages/project/[ref]/auth/settings-old.tsx b/studio/pages/project/[ref]/auth/settings-old.tsxdeleted file mode 100644index e32e1f4cfd8..00000000000--- a/studio/pages/project/[ref]/auth/settings-old.tsx+++ /dev/null@@ -1,1132 +0,0 @@-import useSWR from 'swr'-import { observer } from 'mobx-react-lite'-import { useState, useEffect } from 'react'-import { useRouter } from 'next/router'-import { AutoField, NumField } from 'uniforms-bootstrap4'-import { Button, Typography, Toggle as UIToggle } from '@supabase/ui'-import Divider from 'components/ui/Divider'--import { API_URL } from 'lib/constants'-import { useStore } from 'hooks'-import { authConfig } from 'stores/jsonSchema'-import { get, patch } from 'lib/common/fetch'-import { pluckJsonSchemaFields } from 'lib/helpers'-import { AuthLayout } from 'components/layouts'-import Table from 'components/to-be-cleaned/Table'-import Panel from 'components/ui/Panel'-import ToggleField from 'components/to-be-cleaned/forms/ToggleField'-import SecretField from 'components/to-be-cleaned/forms/SecretField'-import SchemaFormPanel from 'components/to-be-cleaned/forms/SchemaFormPanel'-import { NextPageWithLayout } from 'types'--const Auth: NextPageWithLayout = () => {- return (- <div className="p-4">- <Settings />- </div>- )-}--Auth.getLayout = (page) => <AuthLayout title="Auth">{page}</AuthLayout>--export default observer(Auth)--const Settings = () => {- const router = useRouter()- const { ui } = useStore()-- const [model, setModel] = useState<any>({})- const [smsProviderModel, setSmsProviderModel] = useState<any>({})- const [externalProvidersModel, setExternalProvidersModel] = useState<any>({})- const [isCustomSMTPEnabled, setCustomSMTP] = useState<boolean>(false)- const URL = `${API_URL}/auth/${router.query.ref}/config`- const { data: config, error }: any = useSWR(URL, get)- const { ref: projectRef } = router.query-- if (error) {- return (- <Typography.Text type="danger">- <p>Error connecting to API</p>- <p>{`${error}`}</p>- </Typography.Text>- )- }-- useEffect(() => {- if (config) {- const temp =- config.SMTP_ADMIN_EMAIL ||- config.SMTP_HOST ||- config.SMTP_PORT ||- config.SMTP_USER ||- config.SMTP_PASS- setCustomSMTP(temp)- }- setModel({ ...config })- setExternalProvidersModel({ ...config })- }, [config])-- const onFormSubmit = async (model: any) => {- for (const [key, value] of Object.entries(model)) {- // remove any whitespaces in OAuth or Sms provider credentials- if ((key.includes('EXTERNAL') || key.includes('SMS')) && typeof value === 'string') {- model[key] = value.replace(/\s/g, '')- }- }- const response = await patch(URL, model)- if (response.error) {- ui.setNotification({- category: 'error',- message: `Update config failed: ${response.error.message}`,- })- } else {- const updates = response- setModel({ ...updates })- ui.setNotification({ category: 'success', message: 'Settings saved' })- }- }-- /*- * handleToggle- *- * This can be used for toggles that are not in a schema form- */- const handleToggle = async (key: any, value?: any) => {- const payload = {- [key]: value ? value : !model[key],- }-- try {- const response = await patch(URL, payload)- if (response.error) throw response.error- const updates = response- setModel({ ...updates })- ui.setNotification({ category: 'success', message: 'Settings saved' })- } catch (error: any) {- ui.setNotification({ category: 'error', message: `Update config failed: ${error.message}` })- }- }-- const onFormReset = () => {- setExternalProvidersModel({ ...config })- }-- return (- <div className="">- <div className="my-8 mt-0">- <SchemaFormPanel- title="General"- schema={pluckJsonSchemaFields(authConfig, [- 'SITE_URL',- 'URI_ALLOW_LIST',- 'JWT_EXP',- 'DISABLE_SIGNUP',- 'PASSWORD_MIN_LENGTH',- 'SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION',- 'SECURITY_REFRESH_TOKEN_REUSE_INTERVAL',- ])}- model={{- SITE_URL: model.SITE_URL || undefined,- URI_ALLOW_LIST: model.URI_ALLOW_LIST || undefined,- DISABLE_SIGNUP: model.DISABLE_SIGNUP,- JWT_EXP: model.JWT_EXP || undefined,- PASSWORD_MIN_LENGTH: model.PASSWORD_MIN_LENGTH || undefined,- SECURITY_REFRESH_TOKEN_REUSE_INTERVAL: model.SECURITY_REFRESH_TOKEN_REUSE_INTERVAL || undefined,- SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION:- model.SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION || false,- }}- onSubmit={(model: any) => onFormSubmit(model)}- >- <AutoField- name="SITE_URL"- showInlineError- errorMessage="Please enter a valid site url."- />- <AutoField- name="URI_ALLOW_LIST"- showInlineError- errorMessage="Must be a comma separated list of URIs. No spaces."- />- <NumField name="JWT_EXP" step="1" />- <NumField name="PASSWORD_MIN_LENGTH" step="1" min={6} max={10} />- <NumField name="SECURITY_REFRESH_TOKEN_REUSE_INTERVAL" step="1" min={0}/>- <ToggleField name="SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION" />- <ToggleField name="DISABLE_SIGNUP" />- </SchemaFormPanel>- </div>- <div className="my-8 mt-0">- <SchemaFormPanel- title="Email Auth"- schema={pluckJsonSchemaFields(authConfig, [- 'MAILER_SECURE_EMAIL_CHANGE_ENABLED',- 'MAILER_OTP_EXP',- 'SMTP_ADMIN_EMAIL',- 'SMTP_HOST',- 'SMTP_PORT',- 'SMTP_USER',- 'SMTP_PASS',- 'SMTP_SENDER_NAME',- 'RATE_LIMIT_EMAIL_SENT',- ])}- model={{- MAILER_SECURE_EMAIL_CHANGE_ENABLED: model.MAILER_SECURE_EMAIL_CHANGE_ENABLED,- MAILER_OTP_EXP: model.MAILER_OTP_EXP || undefined,- SMTP_ADMIN_EMAIL: isCustomSMTPEnabled ? model.SMTP_ADMIN_EMAIL : '',- SMTP_HOST: isCustomSMTPEnabled ? model.SMTP_HOST : '',- SMTP_PORT: isCustomSMTPEnabled ? model.SMTP_PORT : '',- SMTP_USER: isCustomSMTPEnabled ? model.SMTP_USER : '',- SMTP_PASS: isCustomSMTPEnabled ? model.SMTP_PASS : '',- SMTP_SENDER_NAME: isCustomSMTPEnabled ? model.SMTP_SENDER_NAME : '',- RATE_LIMIT_EMAIL_SENT: isCustomSMTPEnabled ? model.RATE_LIMIT_EMAIL_SENT : 30,- }}- onSubmit={(model: any) =>- onFormSubmit({- ...model,- })- }- >- <UIToggle- layout="horizontal"- className="mb-4"- label={authConfig.properties.EXTERNAL_EMAIL_ENABLED.title}- onChange={(value) => {- handleToggle('EXTERNAL_EMAIL_ENABLED', value)- }}- checked={model.EXTERNAL_EMAIL_ENABLED}- descriptionText={authConfig.properties.EXTERNAL_EMAIL_ENABLED.help}- />- <NumField name="MAILER_OTP_EXP" step="1" min={0} max={86400}/>- <UIToggle- layout="horizontal"- className="mb-4"- label={authConfig.properties.MAILER_SECURE_EMAIL_CHANGE_ENABLED.title}- onChange={(value) => {- handleToggle('MAILER_SECURE_EMAIL_CHANGE_ENABLED', value)- }}- checked={model.MAILER_SECURE_EMAIL_CHANGE_ENABLED}- descriptionText={authConfig.properties.MAILER_SECURE_EMAIL_CHANGE_ENABLED.help}- />-- <UIToggle- layout="horizontal"- className="mb-4"- label={authConfig.properties.MAILER_AUTOCONFIRM.title}- onChange={(value) => {- // If MAILER_AUTOCONFIRM is set to true, it means we are disabling email confirmations.- // "Enable email confirmations" should be toggled off.- handleToggle('MAILER_AUTOCONFIRM', !value)- }}- checked={!model.MAILER_AUTOCONFIRM}- descriptionText={authConfig.properties.MAILER_AUTOCONFIRM.help}- />-- <UIToggle- layout="horizontal"- className="mb-4"- label="Enable Custom SMTP"- checked={isCustomSMTPEnabled}- onChange={(value: any) => {- /*- * temporary solution- * clear the values of SMTP when toggling- */- if (!value) {- onFormSubmit({- SMTP_ADMIN_EMAIL: '',- SMTP_HOST: '',- SMTP_PORT: '',- SMTP_USER: '',- SMTP_PASS: '',- SMTP_SENDER_NAME: '',- RATE_LIMIT_EMAIL_SENT: 30,- })- }- setCustomSMTP(!isCustomSMTPEnabled)- }}- />- {isCustomSMTPEnabled && (- <>- <AutoField- name="SMTP_ADMIN_EMAIL"- showInlineError- errorMessage="Please enter from email address."- />- <AutoField name="SMTP_HOST" showInlineError errorMessage="Please enter host." />- <AutoField name="SMTP_PORT" showInlineError errorMessage="Please enter port." />- <AutoField name="SMTP_USER" showInlineError errorMessage="Please enter user." />- <SecretField name="SMTP_PASS" errorMessage="Please enter password." />- <AutoField- name="SMTP_SENDER_NAME"- showInlineError- errorMessage="Please enter from name."- />- <NumField- showInlineError- step="1"- name="RATE_LIMIT_EMAIL_SENT"- errorMessage="Please enter a value between 1 to 32767"- />- </>- )}- </SchemaFormPanel>- </div>-- <div className="my-8 mt-0">- <SchemaFormPanel- title="Phone Auth"- schema={pluckJsonSchemaFields(authConfig, [- 'SMS_PROVIDER',- 'SMS_OTP_EXP',- 'SMS_OTP_LENGTH',- 'SMS_TWILIO_ACCOUNT_SID',- 'SMS_TWILIO_AUTH_TOKEN',- 'SMS_TWILIO_MESSAGE_SERVICE_SID',- 'SMS_MESSAGEBIRD_ORIGINATOR',- 'SMS_MESSAGEBIRD_ACCESS_KEY',- 'SMS_TEXTLOCAL_API_KEY',- 'SMS_TEXTLOCAL_SENDER',- 'SMS_VONAGE_API_KEY',- 'SMS_VONAGE_API_SECRET',- 'SMS_VONAGE_FROM',- ])}- model={{- SMS_PROVIDER: model.SMS_PROVIDER,- SMS_OTP_EXP: model.SMS_OTP_EXP || undefined,- SMS_OTP_LENGTH: model.SMS_OTP_LENGTH || undefined,- SMS_TEXTLOCAL_API_KEY: model.SMS_TEXTLOCAL_API_KEY || undefined,- SMS_TEXTLOCAL_SENDER: model.SMS_TEXTLOCAL_SENDER || undefined,- SMS_TWILIO_ACCOUNT_SID: model.SMS_TWILIO_ACCOUNT_SID || undefined,- SMS_TWILIO_AUTH_TOKEN: model.SMS_TWILIO_AUTH_TOKEN || undefined,- SMS_TWILIO_MESSAGE_SERVICE_SID: model.SMS_TWILIO_MESSAGE_SERVICE_SID || undefined,- SMS_MESSAGEBIRD_ORIGINATOR: model.SMS_MESSAGEBIRD_ORIGINATOR || undefined,- SMS_MESSAGEBIRD_ACCESS_KEY: model.SMS_MESSAGEBIRD_ACCESS_KEY || undefined,- SMS_VONAGE_API_KEY: model.SMS_VONAGE_API_KEY || undefined,- SMS_VONAGE_API_SECRET: model.SMS_VONAGE_API_SECRET || undefined,- SMS_VONAGE_FROM: model.SMS_VONAGE_FROM || undefined,- }}- onChangeModel={(model: any) => setSmsProviderModel(model)}- onSubmit={(model: any) => onFormSubmit(model)}- >- <>- <UIToggle- layout="horizontal"- className="mb-4"- label={authConfig.properties.EXTERNAL_PHONE_ENABLED.title}- onChange={() => {- handleToggle('EXTERNAL_PHONE_ENABLED')- }}- checked={model.EXTERNAL_PHONE_ENABLED}- descriptionText={authConfig.properties.EXTERNAL_PHONE_ENABLED.help}- />-- {model.EXTERNAL_PHONE_ENABLED && (- <>- <AutoField- name="SMS_PROVIDER"- showInlineError- errorMessage="Please enter the phone provider."- />- <NumField name="SMS_OTP_EXP" step="1" min={0}/>- <NumField name="SMS_OTP_LENGTH" step="1" min={6} max={10}/>- {smsProviderModel?.SMS_PROVIDER === 'messagebird' ? (- <>- <SecretField- name="SMS_MESSAGEBIRD_ACCESS_KEY"- showInlineError- errorMessage="Please enter the messagebird access key."- />- <AutoField- name="SMS_MESSAGEBIRD_ORIGINATOR"- showInlineError- errorMessage="Please enter the messagebird originator."- />- </>- ) : smsProviderModel?.SMS_PROVIDER === 'textlocal' ? (- <>- <AutoField- name="SMS_TEXTLOCAL_API_KEY"- showInlineError- errorMessage="Please enter the vonage account sid."- />- <SecretField- name="SMS_TEXTLOCAL_SENDER"- showInlineError- errorMessage="Please enter the vonage auth token."- />- </>- ) : smsProviderModel?.SMS_PROVIDER === 'vonage' ? (- <>- <AutoField- name="SMS_VONAGE_API_KEY"- showInlineError- errorMessage="Please enter the vonage account sid."- />- <SecretField- name="SMS_VONAGE_API_SECRET"- showInlineError- errorMessage="Please enter the vonage auth token."- />- <AutoField- name="SMS_VONAGE_FROM"- showInlineError- errorMessage="Please enter the vonage message service sid."- />- </>- ) : (- <>- <AutoField- name="SMS_TWILIO_ACCOUNT_SID"- showInlineError- errorMessage="Please enter the twilio account sid."- />- <SecretField- name="SMS_TWILIO_AUTH_TOKEN"- showInlineError- errorMessage="Please enter the twilio auth token."- />- <AutoField- name="SMS_TWILIO_MESSAGE_SERVICE_SID"- showInlineError- errorMessage="Please enter the twilio message service sid."- />- </>- )}- </>- )}- <UIToggle- layout="horizontal"- label={authConfig.properties.SMS_AUTOCONFIRM.title}- onChange={(value) => {- // If SMS_AUTOCONFIRM is set to true, it means we are disabling phone confirmations.- // "Enable phone confirmations" should be toggled off.- handleToggle('SMS_AUTOCONFIRM', !value)- }}- //- checked={!model.SMS_AUTOCONFIRM}- descriptionText={authConfig.properties.SMS_AUTOCONFIRM.help}- />- </>- </SchemaFormPanel>- </div>- <div className="my-8 mt-0">- <SchemaFormPanel- title="External OAuth Providers"- schema={pluckJsonSchemaFields(authConfig, [- 'EXTERNAL_APPLE_ENABLED',- 'EXTERNAL_APPLE_CLIENT_ID',- 'EXTERNAL_APPLE_SECRET',- 'EXTERNAL_AZURE_ENABLED',- 'EXTERNAL_AZURE_CLIENT_ID',- 'EXTERNAL_AZURE_SECRET',- 'EXTERNAL_AZURE_URL',- 'EXTERNAL_BITBUCKET_ENABLED',- 'EXTERNAL_BITBUCKET_CLIENT_ID',- 'EXTERNAL_BITBUCKET_SECRET',- 'EXTERNAL_DISCORD_ENABLED',- 'EXTERNAL_DISCORD_CLIENT_ID',- 'EXTERNAL_DISCORD_SECRET',- 'EXTERNAL_FACEBOOK_ENABLED',- 'EXTERNAL_FACEBOOK_CLIENT_ID',- 'EXTERNAL_FACEBOOK_SECRET',- 'EXTERNAL_GOOGLE_ENABLED',- 'EXTERNAL_GOOGLE_CLIENT_ID',- 'EXTERNAL_GOOGLE_SECRET',- 'EXTERNAL_GITHUB_ENABLED',- 'EXTERNAL_GITHUB_CLIENT_ID',- 'EXTERNAL_GITHUB_SECRET',- 'EXTERNAL_GITLAB_ENABLED',- 'EXTERNAL_GITLAB_CLIENT_ID',- 'EXTERNAL_GITLAB_SECRET',- 'EXTERNAL_KEYCLOAK_ENABLED',- 'EXTERNAL_KEYCLOAK_CLIENT_ID',- 'EXTERNAL_KEYCLOAK_SECRET',- 'EXTERNAL_KEYCLOAK_URL',- 'EXTERNAL_LINKEDIN_ENABLED',- 'EXTERNAL_LINKEDIN_CLIENT_ID',- 'EXTERNAL_LINKEDIN_SECRET',- 'EXTERNAL_NOTION_ENABLED',- 'EXTERNAL_NOTION_CLIENT_ID',- 'EXTERNAL_NOTION_SECRET',- 'EXTERNAL_TWITCH_ENABLED',- 'EXTERNAL_TWITCH_CLIENT_ID',- 'EXTERNAL_TWITCH_SECRET',- 'EXTERNAL_TWITTER_ENABLED',- 'EXTERNAL_TWITTER_CLIENT_ID',- 'EXTERNAL_TWITTER_SECRET',- 'EXTERNAL_SLACK_ENABLED',- 'EXTERNAL_SLACK_CLIENT_ID',- 'EXTERNAL_SLACK_SECRET',- 'EXTERNAL_SPOTIFY_ENABLED',- 'EXTERNAL_SPOTIFY_CLIENT_ID',- 'EXTERNAL_SPOTIFY_SECRET',- 'EXTERNAL_WORKOS_ENABLED',- 'EXTERNAL_WORKOS_CLIENT_ID',- 'EXTERNAL_WORKOS_SECRET',- 'EXTERNAL_WORKOS_URL',- 'EXTERNAL_ZOOM_ENABLED',- 'EXTERNAL_ZOOM_CLIENT_ID',- 'EXTERNAL_ZOOM_SECRET',- ])}- model={{- EXTERNAL_APPLE_ENABLED: model.EXTERNAL_APPLE_ENABLED,- EXTERNAL_APPLE_CLIENT_ID: model.EXTERNAL_APPLE_CLIENT_ID || undefined,- EXTERNAL_APPLE_SECRET: model.EXTERNAL_APPLE_SECRET || undefined,- EXTERNAL_AZURE_ENABLED: model.EXTERNAL_AZURE_ENABLED,- EXTERNAL_AZURE_CLIENT_ID: model.EXTERNAL_AZURE_CLIENT_ID || undefined,- EXTERNAL_AZURE_SECRET: model.EXTERNAL_AZURE_SECRET || undefined,- EXTERNAL_AZURE_URL: model.EXTERNAL_AZURE_URL || undefined,- EXTERNAL_BITBUCKET_ENABLED: model.EXTERNAL_BITBUCKET_ENABLED,- EXTERNAL_BITBUCKET_CLIENT_ID: model.EXTERNAL_BITBUCKET_CLIENT_ID || undefined,- EXTERNAL_BITBUCKET_SECRET: model.EXTERNAL_BITBUCKET_SECRET || undefined,- EXTERNAL_DISCORD_ENABLED: model.EXTERNAL_DISCORD_ENABLED,- EXTERNAL_DISCORD_CLIENT_ID: model.EXTERNAL_DISCORD_CLIENT_ID || undefined,- EXTERNAL_DISCORD_SECRET: model.EXTERNAL_DISCORD_SECRET || undefined,- EXTERNAL_FACEBOOK_ENABLED: model.EXTERNAL_FACEBOOK_ENABLED,- EXTERNAL_FACEBOOK_CLIENT_ID: model.EXTERNAL_FACEBOOK_CLIENT_ID || undefined,- EXTERNAL_FACEBOOK_SECRET: model.EXTERNAL_FACEBOOK_SECRET || undefined,- EXTERNAL_GITHUB_ENABLED: model.EXTERNAL_GITHUB_ENABLED,- EXTERNAL_GITHUB_CLIENT_ID: model.EXTERNAL_GITHUB_CLIENT_ID || undefined,- EXTERNAL_GITHUB_SECRET: model.EXTERNAL_GITHUB_SECRET || undefined,- EXTERNAL_GITLAB_ENABLED: model.EXTERNAL_GITLAB_ENABLED,- EXTERNAL_GITLAB_CLIENT_ID: model.EXTERNAL_GITLAB_CLIENT_ID || undefined,- EXTERNAL_GITLAB_SECRET: model.EXTERNAL_GITLAB_SECRET || undefined,- EXTERNAL_GOOGLE_ENABLED: model.EXTERNAL_GOOGLE_ENABLED,- EXTERNAL_GOOGLE_CLIENT_ID: model.EXTERNAL_GOOGLE_CLIENT_ID || undefined,- EXTERNAL_GOOGLE_SECRET: model.EXTERNAL_GOOGLE_SECRET || undefined,- EXTERNAL_KEYCLOAK_ENABLED: model.EXTERNAL_KEYCLOAK_ENABLED,- EXTERNAL_KEYCLOAK_CLIENT_ID: model.EXTERNAL_KEYCLOAK_CLIENT_ID || undefined,- EXTERNAL_KEYCLOAK_SECRET: model.EXTERNAL_KEYCLOAK_SECRET || undefined,- EXTERNAL_KEYCLOAK_URL: model.EXTERNAL_KEYCLOAK_URL || undefined,- EXTERNAL_LINKEDIN_ENABLED: model.EXTERNAL_LINKEDIN_ENABLED,- EXTERNAL_LINKEDIN_CLIENT_ID: model.EXTERNAL_LINKEDIN_CLIENT_ID || undefined,- EXTERNAL_LINKEDIN_SECRET: model.EXTERNAL_LINKEDIN_SECRET || undefined,- EXTERNAL_NOTION_ENABLED: model.EXTERNAL_NOTION_ENABLED,- EXTERNAL_NOTION_CLIENT_ID: model.EXTERNAL_NOTION_CLIENT_ID || undefined,- EXTERNAL_NOTION_SECRET: model.EXTERNAL_NOTION_SECRET || undefined,- EXTERNAL_TWITCH_ENABLED: model.EXTERNAL_TWITCH_ENABLED,- EXTERNAL_TWITCH_CLIENT_ID: model.EXTERNAL_TWITCH_CLIENT_ID || undefined,- EXTERNAL_TWITCH_SECRET: model.EXTERNAL_TWITCH_SECRET || undefined,- EXTERNAL_TWITTER_ENABLED: model.EXTERNAL_TWITTER_ENABLED,- EXTERNAL_TWITTER_CLIENT_ID: model.EXTERNAL_TWITTER_CLIENT_ID || undefined,- EXTERNAL_TWITTER_SECRET: model.EXTERNAL_TWITTER_SECRET || undefined,- EXTERNAL_SLACK_ENABLED: model.EXTERNAL_SLACK_ENABLED,- EXTERNAL_SLACK_CLIENT_ID: model.EXTERNAL_SLACK_CLIENT_ID || undefined,- EXTERNAL_SLACK_SECRET: model.EXTERNAL_SLACK_SECRET || undefined,- EXTERNAL_SPOTIFY_ENABLED: model.EXTERNAL_SPOTIFY_ENABLED,- EXTERNAL_SPOTIFY_CLIENT_ID: model.EXTERNAL_SPOTIFY_CLIENT_ID || undefined,- EXTERNAL_SPOTIFY_SECRET: model.EXTERNAL_SPOTIFY_SECRET || undefined,- EXTERNAL_WORKOS_ENABLED: model.EXTERNAL_WORKOS_ENABLED,- EXTERNAL_WORKOS_CLIENT_ID: model.EXTERNAL_WORKOS_CLIENT_ID || undefined,- EXTERNAL_WORKOS_SECRET: model.EXTERNAL_WORKOS_SECRET || undefined,- EXTERNAL_WORKOS_URL: model.EXTERNAL_WORKOS_URL || undefined,- EXTERNAL_ZOOM_ENABLED: model.EXTERNAL_ZOOM_ENABLED,- EXTERNAL_ZOOM_CLIENT_ID: model.EXTERNAL_ZOOM_CLIENT_ID || undefined,- EXTERNAL_ZOOM_SECRET: model.EXTERNAL_ZOOM_SECRET || undefined,- }}- onChangeModel={(model) => setExternalProvidersModel(model)}- onReset={() => onFormReset()}- onSubmit={(model: any) => onFormSubmit(model)}- >- <ToggleField- name="EXTERNAL_APPLE_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_APPLE_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://developer.apple.com/account/resources/identifiers/add/bundleId"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_APPLE_ENABLED && (- <>- <AutoField- name="EXTERNAL_APPLE_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_APPLE_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_AZURE_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_AZURE_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_AZURE_ENABLED && (- <>- <AutoField- name="EXTERNAL_AZURE_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_AZURE_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- <AutoField- name="EXTERNAL_AZURE_URL"- showInlineError- errorMessage="Please enter the azure tenant url."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_BITBUCKET_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_BITBUCKET_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_BITBUCKET_ENABLED && (- <>- <AutoField- name="EXTERNAL_BITBUCKET_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_BITBUCKET_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_DISCORD_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_DISCORD_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://discord.com/developers/applications#top"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_DISCORD_ENABLED && (- <>- <AutoField- name="EXTERNAL_DISCORD_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_DISCORD_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_FACEBOOK_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_FACEBOOK_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://developers.facebook.com/apps/"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_FACEBOOK_ENABLED && (- <>- <AutoField- name="EXTERNAL_FACEBOOK_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_FACEBOOK_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_GITHUB_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_GITHUB_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://github.com/settings/applications/new"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_GITHUB_ENABLED && (- <>- <AutoField- name="EXTERNAL_GITHUB_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_GITHUB_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_GITLAB_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_GITLAB_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://gitlab.com/oauth/applications"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_GITLAB_ENABLED && (- <>- <AutoField- name="EXTERNAL_GITLAB_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_GITLAB_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_GOOGLE_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_GOOGLE_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://console.developers.google.com/apis/credentials"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_GOOGLE_ENABLED && (- <>- <AutoField- name="EXTERNAL_GOOGLE_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_GOOGLE_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_KEYCLOAK_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_KEYCLOAK_ENABLED && (- <a className="text-scale-900 pl-4" href="https://www.keycloak.org/" target="_blank">- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_KEYCLOAK_ENABLED && (- <>- <AutoField- name="EXTERNAL_KEYCLOAK_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_KEYCLOAK_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- <AutoField- name="EXTERNAL_KEYCLOAK_URL"- showInlineError- errorMessage="Please enter the Keycloak url."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_LINKEDIN_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_LINKEDIN_ENABLED && (- <a- className="pl-4 text-gray-400"- href="https://www.linkedin.com/developers/apps"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_LINKEDIN_ENABLED && (- <>- <AutoField- name="EXTERNAL_LINKEDIN_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_LINKEDIN_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_NOTION_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_NOTION_ENABLED && (- <a- className="pl-4 text-gray-400"- href="https://www.notion.so/my-integrations"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_NOTION_ENABLED && (- <>- <AutoField- name="EXTERNAL_NOTION_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_NOTION_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_TWITCH_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_TWITCH_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://dev.twitch.tv/console"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_TWITCH_ENABLED && (- <>- <AutoField- name="EXTERNAL_TWITCH_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_TWITCH_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_TWITTER_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_TWITTER_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://developer.twitter.com/en/portal/dashboard"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_TWITTER_ENABLED && (- <>- <AutoField- name="EXTERNAL_TWITTER_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_TWITTER_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_SLACK_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_SLACK_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://api.slack.com/apps"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_SLACK_ENABLED && (- <>- <AutoField- name="EXTERNAL_SLACK_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_SLACK_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_SPOTIFY_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_SPOTIFY_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://developer.spotify.com/dashboard/"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_SPOTIFY_ENABLED && (- <>- <AutoField- name="EXTERNAL_SPOTIFY_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_SPOTIFY_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_WORKOS_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_WORKOS_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://dashboard.workos.com"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_WORKOS_ENABLED && (- <>- <AutoField- name="EXTERNAL_WORKOS_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_WORKOS_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- <AutoField- name="EXTERNAL_WORKOS_URL"- showInlineError- errorMessage="Please enter the WorkOS url."- />- </>- )}- <Divider light />- <ToggleField- name="EXTERNAL_ZOOM_ENABLED"- addOns={- externalProvidersModel.EXTERNAL_ZOOM_ENABLED && (- <a- className="text-scale-900 pl-4"- href="https://developers.zoom.us/"- target="_blank"- >- Create new credentials- </a>- )- }- />- {externalProvidersModel.EXTERNAL_ZOOM_ENABLED && (- <>- <AutoField- name="EXTERNAL_ZOOM_CLIENT_ID"- showInlineError- errorMessage="Please enter the client id."- />- <SecretField- name="EXTERNAL_ZOOM_SECRET"- showInlineError- errorMessage="Please enter the secret."- />- </>- )}- </SchemaFormPanel>- </div>-- <div className="my-8 mt-0">- {config && (- <AuditLog interval={config.isFreeTier ? '1 hour' : '7 days'} projectRef={projectRef} />- )}- </div>- </div>- )-}--const AuditLog = ({ interval, projectRef }: any) => {- const { meta } = useStore()- const [logs, setLogs] = useState<any>([])- const [isLoading, setIsLoading] = useState<any>(false)-- const refreshLogs = async () => {- setIsLoading(true)- try {- let query = `- SELECT- *- FROM- auth.audit_log_entries- WHERE- created_at > CURRENT_TIMESTAMP - interval '${interval}'- ORDER BY- created_at DESC- LIMIT 1000;- `- const response = await meta.query(query)- if (response.error) throw response.error- setLogs(response)- } catch (error) {- console.error('Refresh logs error:', error)- } finally {- setIsLoading(false)- }- }-- useEffect(() => {- refreshLogs()- }, [])-- if (!logs.length) return <div></div>- const cellCss = 'table-cell px-4 py-3 text-gray-200 font-mono text-xs'- return (- <Panel- title={- <div className=" flex w-full items-center justify-between">- <Typography.Title level={5} className="block flex-1">- Audit Trail- </Typography.Title>- <div className="flex-1 text-right">- <Button- type="default"- className="hover:border-gray-400"- disabled={isLoading}- loading={isLoading}- onClick={() => refreshLogs()}- >- Refresh- </Button>- </div>- </div>- }- >- <Table- borderless- head={- <>- <Table.th>Time</Table.th>- <Table.th>Action</Table.th>- <Table.th>User ID</Table.th>- <Table.th>Identity</Table.th>- </>- }- body={logs.map((x: any, i: number) => (- <Table.tr key={x.id} className={`${i % 2 ? '' : 'bg-gray-500'}`}>- <Table.td className={cellCss}>- <Typography.Text>{x.payload.timestamp.replace('T', ' ')}</Typography.Text>- </Table.td>- <Table.td className={cellCss + ''}>- <Typography.Text>{x.payload.action}</Typography.Text>- </Table.td>- <Table.td className={cellCss}>- <Typography.Text>{x.payload.actor_id || x.payload.traits?.user_id}</Typography.Text>- </Table.td>- <Table.td className={cellCss}>- <Typography.Text>- {x.payload.actor_username || x.payload.traits?.user_email}- </Typography.Text>- </Table.td>- </Table.tr>- ))}- />- </Panel>- )-}diff --git a/studio/pages/project/[ref]/auth/settings.tsx b/studio/pages/project/[ref]/auth/settings.tsxindex 7b015b32bbe..792bed5f2e8 100644--- a/studio/pages/project/[ref]/auth/settings.tsx+++ b/studio/pages/project/[ref]/auth/settings.tsx@@ -1,17 +1,18 @@-import { AuthProvidersForm } from 'components/interfaces'-import RedirectDomains from 'components/interfaces/Auth/RedirectDomains'-import { AuthLayout } from 'components/layouts'-import { AutoSchemaForm, FormsContainer } from 'components/ui/Forms'-import { useStore } from 'hooks'-import { observer } from 'mobx-react-lite'import React, { useEffect } from 'react'+import { observer } from 'mobx-react-lite'++import { useStore } from 'hooks'import { NextPageWithLayout } from 'types'+import { AuthLayout } from 'components/layouts'+import { FormsContainer } from 'components/ui/Forms'+import { AuthProvidersForm } from 'components/interfaces'+import RedirectDomains from 'components/interfaces/Auth/RedirectDomains/RedirectDomains'+import AutoSchemaForm from 'components/interfaces/Auth/AutoSchemaForm'const PageLayout: NextPageWithLayout = () => {const { ui, authConfig } = useStore()useEffect(() => {- // temporary store loaderauthConfig.load()}, [ui.selectedProjectRef])diff --git a/studio/pages/project/[ref]/auth/templates-old.tsx b/studio/pages/project/[ref]/auth/templates-old.tsxdeleted file mode 100644index 92c73531f3f..00000000000--- a/studio/pages/project/[ref]/auth/templates-old.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { observer } from 'mobx-react-lite'-import { useStore } from 'hooks'-import { AuthLayout } from 'components/layouts'-import { Templates } from 'components/interfaces/Authentication'-import { NextPageWithLayout } from 'types'--const TemplatesPage: NextPageWithLayout = () => {- const { ui } = useStore()- const project = ui.selectedProject-- return (- <div className="p-4">- <Templates project={project} />- </div>- )-}--TemplatesPage.getLayout = (page) => <AuthLayout title="Auth">{page}</AuthLayout>--export default observer(TemplatesPage)diff --git a/studio/pages/project/[ref]/auth/templates-oldd.tsx b/studio/pages/project/[ref]/auth/templates-oldd.tsxdeleted file mode 100644index 2d6156c1129..00000000000--- a/studio/pages/project/[ref]/auth/templates-oldd.tsx+++ /dev/null@@ -1,602 +0,0 @@-import {- Button,- Collapsible,- Form,- IconArrowRight,- IconCheck,- IconChevronUp,- IconGlobe,- IconTrash,- IconX,- Input,- InputNumber,- Modal,- Tabs,- Toggle,-} from '@supabase/ui'-import { AuthLayout } from 'components/layouts'-import AutoSchemaForm from 'components/interfaces/Auth/AutoSchemaForm'-import { withAuth } from 'hooks'-import { observer } from 'mobx-react-lite'-import React, { useReducer, useState } from 'react'-import AuthFormSchema from './AuthFormSchema'--// import GoogleIcon './../../../static/icons/google-icon.svg'--const DocsButton = () => {- return (- <button- className="- bg-scale-300- dark:bg-scale-100- border-scale-500- hover:border-scale-700- dark:border-scale-300- dark:hover:border-scale-500 group- my-6 flex- w-full items-center- gap-6- rounded-md border px-6- py-4 text-left- shadow-sm- transition- "- >- <div className="bg-brand-900 h-10 w-10 rounded p-1 transition duration-500 group-hover:-rotate-3 group-hover:scale-110">- {/* <img- className="text-white w-12 h-12"- src="/icons/docs-illustration.svg"- /> */}- </div>- <div className="grow">- <h3 className="text-scale-1200">Use authentication as the backbone of your app</h3>- <p className="text-scale-900 text-xs">- Learn how to use Supabase Auth with Auth Policies to pick and choose what users see what.- </p>- <p className="text-brand-900 mt-2 flex items-center gap-1 text-xs">- See Documenation- <span className="transition group-hover:translate-x-1">- <IconArrowRight strokeWidth={2} width={12} />- </span>- </p>- </div>- <div className="text-scale-900">- <IconX />- </div>- </button>- )-}--const CardForm = () => {- // panel- const Panel = ({- children,- header,- footer,- }: {- children: React.ReactNode- header?: React.ReactNode- footer?: React.ReactNode- }) => (- <div- className="- bg-scale-100- dark:bg-scale-300-- border-scale-400 my-8 overflow-hidden rounded-md border shadow"- >- {header && (- <div className="bg-scale-100 dark:bg-scale-200 border-scale-400 border-b px-8 py-4">- {header}- </div>- )}- <div className="space-y-6 py-6">{children}</div>- {footer}- </div>- )-- const Section = ({- children,- header,- }: {- children: React.ReactNode- header?: React.ReactNode- }) => (- <div className="grid grid-cols-12 px-8 py-2">- {header}- {children}- </div>- )-- return (- <>- <AutoSchemaForm />- <Form- id="general_form"- initialValues={{- enable_signups: true,- jwt_expiry: 3600,- }}- onSubmit={(values: any, { setSubmitting }: any) => {- setTimeout(() => {- alert(JSON.stringify(values, null, 2))- setSubmitting(false)- }, 400)- }}- validate={(values: Values) => {- const errors: any = {}- if (!values.jwt_expiry) {- errors.jwt_expiry = 'This is required'- }- if (values.jwt_expiry > 604800) {- errors.jwt_expiry =- 'The maxiumum allowed is 604,800 seconds. Use a smaller number of seconds.'- }- return errors- }}- >- {({ isSubmitting, handleReset }: any) => (- <Panel- footer={- <>- <div className="border-scale-400 border-t"></div>- <div className="flex justify-end gap-2 py-3 px-6">- <Button type="default" htmlType="reset" onClick={() => handleReset()}>- Cancel- </Button>- <Button- loading={isSubmitting}- type="primary"- htmlType="submit"- form="general_form"- >- Save- </Button>- </div>- </>- }- >- <Section- header={<label className="text-scale-1200 col-span-4 text-sm">User Signups</label>}- >- <Toggle- id="enable_signups"- className="col-span-8"- 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."- />- </Section>- <div className="border-scale-400 border-t"></div>- <Section- header={<label className="text-scale-1200 col-span-4 text-sm">User Sessions</label>}- >- <InputNumber- className="col-span-8"- id="jwt_expiry"- label="JWT expiry limit"- descriptionText="How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one week)."- />- </Section>- </Panel>- )}- </Form>- </>- )-}--// type to do later..-let initialState: any = {}--AuthFormSchema.map((provider) => {- initialState[`${provider.name.toLowerCase()}-active`] = provider.name == 'Email' ? true : false- initialState[`${provider.name.toLowerCase()}-app-id`] = ''- initialState[`${provider.name.toLowerCase()}-id-key`] = ''-})--console.log('form initialState', initialState)--function providersReducer(state: any, action: any) {- switch (action.type) {- case 'update':- return Object.assign(state, action.values)- // case 'decrement':- // return { count: state.count - 1 }- default:- throw new Error()- }-}--const SmtpForm = () => {- const [active, setActive] = useState(true)-- // panel- const Panel = ({- children,- header,- footer,- }: {- children: React.ReactNode- header?: React.ReactNode- footer?: React.ReactNode- }) => (- <div- className="- bg-scale-100- dark:bg-scale-300-- border-scale-400 my-8 overflow-hidden rounded-md border shadow"- >- {header && (- <div className="bg-scale-100 dark:bg-scale-200 border-scale-400 border-b px-8 py-4">- {header}- </div>- )}- <div className="space-y-6 py-6">{children}</div>- {footer}- </div>- )-- const Section = ({- children,- header,- }: {- children: React.ReactNode- header?: React.ReactNode- }) => (- <div className="grid grid-cols-12 gap-8 px-8 py-2">- {header && <div className="col-span-4">{header}</div>}- {children}- </div>- )-- return (- <>- <Form- id="general_form"- initialValues={{- enable_smtp: false,- jwt_expiry: 3600,- }}- onSubmit={(values: any, { setSubmitting }: any) => {- setTimeout(() => {- alert(JSON.stringify(values, null, 2))- setSubmitting(false)- }, 400)- }}- validate={(values: Values) => {- const errors: any = {}- if (!values.jwt_expiry) {- errors.jwt_expiry = 'This is required'- }- if (values.jwt_expiry > 604800) {- errors.jwt_expiry =- 'The maxiumum allowed is 604,800 seconds. Use a smaller number of seconds.'- }- return errors- }}- >- {({ isSubmitting, handleReset, values }: any) => (- <Panel- footer={- <>- <div className="border-scale-400 border-t"></div>- <div className="flex justify-end gap-2 py-3 px-6">- <Button- loading={isSubmitting}- type="secondary"- htmlType="reset"- onClick={() => handleReset()}- >- Cancel- </Button>- <Button- loading={isSubmitting}- type="primary"- htmlType="submit"- form="general_form"- >- Save- </Button>- </div>- </>- }- >- {/* <Section- header={- <label className="text-sm text-scale-1200 col-span-4">- Enable SMTP- </label>- }- > */}- <Toggle- // onChange={() => setActive(!active)}- // checked={active}- name="enable_smtp"- className="col-span-8 mx-8"- label="Enable Custom SMTP"- layout="flex"- descriptionText="If this is disabled, new users will not be able to sign up to your application."- />- {/* </Section> */}- <div className="border-scale-400 border-t"></div>- <Section- header={- <div className="w-full">- <label className="text-scale-1100 text-sm">SMTP details</label>- <p className="text-scale-900 text-sm">- These settings can be found in your SMTP provider config- </p>- </div>- }- >- <div className="col-span-8 space-y-6">- <Input label="Sender address" type="url" disabled={!values.enable_smtp} />- <Input label="SMTP server host" disabled={!values.enable_smtp} />- <InputNumber label="SMTP server port" disabled={!values.enable_smtp} />- <Input label="SMTP account username" disabled={!values.enable_smtp} />- <Input- label="SMTP account password"- type="password"- disabled={!values.enable_smtp}- />- </div>- </Section>- {values.enable_smtp && (- <div className="mx-8">- <DocsButton />- </div>- )}- </Panel>- )}- </Form>- </>- )-}--const TemplatesForm = () => {- const [active, setActive] = useState(true)-- // panel- const Panel = ({- children,- header,- footer,- }: {- children: React.ReactNode- header?: React.ReactNode- footer?: React.ReactNode- }) => (- <div- className="- bg-scale-100- dark:bg-scale-300- border-scale-400 mb-8 overflow-hidden rounded-md border shadow"- >- {header && (- <div className="bg-scale-100 dark:bg-scale-200 border-scale-400 border-b px-8 py-4">- {header}- </div>- )}- <div className="space-y-6 py-6">{children}</div>- {footer}- </div>- )-- const Section = ({- children,- header,- }: {- children: React.ReactNode- header?: React.ReactNode- }) => (- <div className="grid grid-cols-12 gap-8 px-8 py-2">- {header && <div className="col-span-4">{header}</div>}- {children}- </div>- )-- return (- <>- <Form- id="general_form"- initialValues={{- enable_smtp: false,- jwt_expiry: 3600,- }}- onSubmit={(values: any, { setSubmitting }: any) => {- setTimeout(() => {- alert(JSON.stringify(values, null, 2))- setSubmitting(false)- }, 400)- }}- validate={(values: Values) => {- const errors: any = {}- if (!values.jwt_expiry) {- errors.jwt_expiry = 'This is required'- }- if (values.jwt_expiry > 604800) {- errors.jwt_expiry =- 'The maxiumum allowed is 604,800 seconds. Use a smaller number of seconds.'- }- return errors- }}- >- {({ isSubmitting, handleReset, values }: any) => (- <>- <div className="my-4">- <Tabs- defaultActiveId="confirm_signup"- type="underlined"- // listClassNames="px-8"- size="medium"- >- <Tabs.Panel id={'confirm_signup'} label="Confirm Signup" />- <Tabs.Panel id={'reset_password'} label="Reset Password" />- <Tabs.Panel id={'magic_link'} label="Magic Link" />- <Tabs.Panel id={'change_email_address'} label="Change Email Address" />- <Tabs.Panel id={'invite_user'} label="Invite User" />- </Tabs>- </div>- <Panel- footer={- <>- <div className="border-scale-400 border-t"></div>- <div className="flex justify-end gap-2 py-3 px-6">- <Button- loading={isSubmitting}- type="secondary"- htmlType="reset"- onClick={() => handleReset()}- >- Cancel- </Button>- <Button- loading={isSubmitting}- type="primary"- htmlType="submit"- form="general_form"- >- Save- </Button>- </div>- </>- }- >- {/* <Section- header={- <label className="text-sm text-scale-1200 col-span-4">- Enable SMTP- </label>- }- > */}- {/* <Toggle- // onChange={() => setActive(!active)}- // checked={active}- name="enable_smtp"- className="col-span-8 mx-8"- label="Enable Custom SMTP"- layout="flex"- descriptionText="If this is disabled, new users will not be able to sign up to your application."- /> */}- {/* </Section> */}- {/* <div className="border-t border-scale-400"></div> */}- <Section- header={- <div className="w-full">- <h3 className="text-scale-1200 mb-4 text-base">Confirm Signup</h3>- <p className="text-scale-900 text-sm">- When a user signs up using an email address and password, you can send them a- confirmation email to verify their registered email address. Learn more- </p>- </div>- }- >- <div className="col-span-8 space-y-6">- <Input label="Sender address" type="url" />- <Input label="SMTP server host" />- <InputNumber label="SMTP server port" />- <Input label="SMTP account username" />- <Input.TextArea- label="SMTP account password"- type="password"- rows={8}- defaultValue={`<h2>Confirm your signup</h2>--<p>Follow this link to confirm your user:</p>-<p><a href="{{ .ConfirmationURL }}">Confirm your mail</a></p>- `}- />- </div>- </Section>- {values.enable_smtp && (- <div className="mx-8">- <DocsButton />- </div>- )}- </Panel>- </>- )}- </Form>- </>- )-}--const Auth = () => {- return (- <AuthLayout title="Auth">- <div className="p-4">- <WholeForm />- </div>- </AuthLayout>- )-}--export function WholeForm() {- return (- <div style={{ width: '820px' }} className="mx-auto">- <div className="animate-fade-in space-y-12 py-12">- <div>- <h1 className="text-scale-1200 text-3xl">Emails</h1>- </div>- <button- className="- bg-scale-300- dark:bg-scale-100- border-scale-500- hover:border-scale-700- dark:border-scale-300- dark:hover:border-scale-500 group- my-6 flex- w-full items-center- gap-6- rounded-md border px-6- py-4 text-left- shadow-sm- transition- "- >- <div className="bg-brand-900 h-10 w-10 rounded p-1 transition duration-500 group-hover:-rotate-3 group-hover:scale-110">- {/* <img- className="text-white w-12 h-12"- src="/icons/docs-illustration.svg"- /> */}- </div>- <div className="grow">- <h3 className="text-scale-1200">Use authentication as the backbone of your app</h3>- <p className="text-scale-900 text-xs">- Learn how to use Supabase Auth with Auth Policies to pick and choose what users see- what.- </p>- <p className="text-brand-900 mt-2 flex items-center gap-1 text-xs">- See Documenation- <span className="transition group-hover:translate-x-1">- <IconArrowRight strokeWidth={2} width={12} />- </span>- </p>- </div>- <div className="text-scale-900">- <IconX />- </div>- </button>- <div className="border-scale-400 border-t"></div>- <div>- <h3 className="text-scale-1200 mb-2 text-2xl">Custom SMTP</h3>- <p className="text-scale-900 text-sm">- You can use your own SMTP server instead of the built-in email service.- </p>- <SmtpForm />- </div>- <div>- <h3 className="text-scale-1200 mb-2 text-2xl">Templates</h3>- <p className="text-scale-900 text-sm">- You can use your own SMTP server instead of the built-in email service.- </p>- <TemplatesForm />- </div>- </div>- </div>- )-}--export default withAuth(observer(Auth))diff --git a/studio/pages/project/[ref]/auth/templates.tsx b/studio/pages/project/[ref]/auth/templates.tsxindex 6459554e8bc..50ed1b77106 100644--- a/studio/pages/project/[ref]/auth/templates.tsx+++ b/studio/pages/project/[ref]/auth/templates.tsx@@ -21,6 +21,8 @@ const PageLayout: NextPageWithLayout = () => {<EmailTemplates /></FormsContainer>)+ } else {+ return <div />}}diff --git a/studio/stores/authConfig/ProjectAuthConfigStore.ts b/studio/stores/authConfig/ProjectAuthConfigStore.tsindex 4dfe3ffd29c..090b3d645d5 100644--- a/studio/stores/authConfig/ProjectAuthConfigStore.ts+++ b/studio/stores/authConfig/ProjectAuthConfigStore.ts@@ -1,13 +1,8 @@import { makeAutoObservable, toJS } from 'mobx'-import { keyBy } from 'lodash'--import { get, post, patch, delete_ } from 'lib/common/fetch'-import { UserContent, UserContentMap } from 'types'+import { UserContentMap } from 'types'import { IRootStore } from '../RootStore'import { API_URL } from 'lib/constants'--// [Joshen] This will be the new ProjectContentStore-// but use the one under the stores folder projectContentStore first while we transition+import { get, patch } from 'lib/common/fetch'export interface IProjectAuthConfigStore {isLoading: boolean@@ -20,7 +15,7 @@ export interface IProjectAuthConfigStore {projectRef: stringload: () => void- update: ({}) => void+ update: (updates: any) => Promise<any>setProjectRef: (ref?: string) => void}diff --git a/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx b/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsxindex d27db774559..a2ef4ea4ff5 100644--- a/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx+++ b/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx@@ -2,7 +2,7 @@ import { boolean, number, object, string } from 'yup'const JSON_SCHEMA_VERSION = 'http://json-schema.org/draft-07/schema#'-export const PROVIDER_EMAIL = {+const PROVIDER_EMAIL = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Email',@@ -50,7 +50,7 @@ export const PROVIDER_EMAIL = {},}-export const PROVIDER_PHONE = {+const PROVIDER_PHONE = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Phone',@@ -176,29 +176,33 @@ export const PROVIDER_PHONE = {*/SMS_AUTOCONFIRM: {title: 'Enable phone confirmations',- description: 'Users will need to confirm their phone number before signing in.',type: 'boolean',+ description: 'Users will need to confirm their phone number before signing in.',},SMS_OTP_EXP: {title: 'SMS OTP Expiry',type: 'number',description: 'Duration before an SMS OTP expires',- descriptionOptional: 'Seconds',+ descriptionOptional: 'In seconds',},SMS_OTP_LENGTH: {title: 'SMS OTP Length',type: 'number',description: 'Number of digits in OTP',- descriptionOptional: 'Seconds',+ descriptionOptional: 'In seconds',+ },+ SMS_TEMPLATE: {+ title: 'SMS Message',+ type: 'string',+ description: 'To format the OPT code use `{{ .Code }}`',},},validationSchema: object().shape({EXTERNAL_PHONE_ENABLED: boolean().required(),SMS_PROVIDER: string().required(),- /**- * twilio- */++ // TwilioSMS_TWILIO_ACCOUNT_SID: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {is: (EXTERNAL_PHONE_ENABLED: boolean, SMS_PROVIDER: string) => {return EXTERNAL_PHONE_ENABLED && SMS_PROVIDER === 'twilio'@@ -220,9 +224,8 @@ export const PROVIDER_PHONE = {then: (schema) => schema.required('"Twilio Message Service Sid" is required'),otherwise: (schema) => schema,}),- /**- * messagebird- */++ // MessagebirdSMS_MESSAGEBIRD_ACCESS_KEY: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {is: (EXTERNAL_PHONE_ENABLED: boolean, SMS_PROVIDER: string) => {return EXTERNAL_PHONE_ENABLED && SMS_PROVIDER === 'messagebird'@@ -237,9 +240,8 @@ export const PROVIDER_PHONE = {then: (schema) => schema.required('"Messagebird Originator" is required'),otherwise: (schema) => schema,}),- /**- * textlocal- */++ // TextlocalSMS_TEXTLOCAL_API_KEY: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {is: (EXTERNAL_PHONE_ENABLED: boolean, SMS_PROVIDER: string) => {return EXTERNAL_PHONE_ENABLED && SMS_PROVIDER === 'textlocal'@@ -254,9 +256,8 @@ export const PROVIDER_PHONE = {then: (schema) => schema.required('"Textlocal Sender" is required'),otherwise: (schema) => schema,}),- /**- * vonage- */++ // VonageSMS_VONAGE_API_KEY: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {is: (EXTERNAL_PHONE_ENABLED: boolean, SMS_PROVIDER: string) => {return EXTERNAL_PHONE_ENABLED && SMS_PROVIDER === 'vonage'@@ -278,8 +279,11 @@ export const PROVIDER_PHONE = {then: (schema) => schema.required('"Vonage From" is required'),otherwise: (schema) => schema,}),++ // Phone SMSSMS_OTP_EXP: number().min(0, 'Must be more than 0').required('This is required'),SMS_OTP_LENGTH: number().min(6, 'Must be 6 or more in length').required('This is required'),+ SMS_TEMPLATE: string().required('SMS template is required.'),}),misc: {iconKey: 'phone-icon4',@@ -288,7 +292,7 @@ export const PROVIDER_PHONE = {},}-export const EXTERNAL_PROVIDER_APPLE = {+const EXTERNAL_PROVIDER_APPLE = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Apple',@@ -344,7 +348,7 @@ The secret key is a JWT token that must be generated.},}-export const EXTERNAL_PROVIDER_AZURE = {+const EXTERNAL_PROVIDER_AZURE = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Azure',@@ -396,7 +400,7 @@ export const EXTERNAL_PROVIDER_AZURE = {},}-export const EXTERNAL_PROVIDER_BITBUCKET = {+const EXTERNAL_PROVIDER_BITBUCKET = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Bitbucket',@@ -433,7 +437,7 @@ export const EXTERNAL_PROVIDER_BITBUCKET = {},}-export const EXTERNAL_PROVIDER_DISCORD = {+const EXTERNAL_PROVIDER_DISCORD = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Discord',@@ -470,7 +474,7 @@ export const EXTERNAL_PROVIDER_DISCORD = {},}-export const EXTERNAL_PROVIDER_FACEBOOK = {+const EXTERNAL_PROVIDER_FACEBOOK = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Facebook',@@ -507,7 +511,7 @@ export const EXTERNAL_PROVIDER_FACEBOOK = {},}-export const EXTERNAL_PROVIDER_GITHUB = {+const EXTERNAL_PROVIDER_GITHUB = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'GitHub',@@ -544,7 +548,7 @@ export const EXTERNAL_PROVIDER_GITHUB = {},}-export const EXTERNAL_PROVIDER_GITLAB = {+const EXTERNAL_PROVIDER_GITLAB = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'GitLab',@@ -593,7 +597,7 @@ export const EXTERNAL_PROVIDER_GITLAB = {},}-export const EXTERNAL_PROVIDER_GOOGLE = {+const EXTERNAL_PROVIDER_GOOGLE = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Google',@@ -636,10 +640,8 @@ export const EXTERNAL_PROVIDER_GOOGLE = {},}-/**- * TO DO: clarify the EXTERNAL_KEYCLOAK_URL property- */-export const EXTERNAL_PROVIDER_KEYCLOAK = {+// [TODO]: clarify the EXTERNAL_KEYCLOAK_URL property+const EXTERNAL_PROVIDER_KEYCLOAK = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'KeyCloak',@@ -686,7 +688,7 @@ export const EXTERNAL_PROVIDER_KEYCLOAK = {},}-export const EXTERNAL_PROVIDER_LINKEDIN = {+const EXTERNAL_PROVIDER_LINKEDIN = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'LinkedIn',@@ -729,7 +731,7 @@ export const EXTERNAL_PROVIDER_LINKEDIN = {},}-export const EXTERNAL_PROVIDER_NOTION = {+const EXTERNAL_PROVIDER_NOTION = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Notion',@@ -766,7 +768,7 @@ export const EXTERNAL_PROVIDER_NOTION = {},}-export const EXTERNAL_PROVIDER_TWITCH = {+const EXTERNAL_PROVIDER_TWITCH = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'twitch',@@ -803,7 +805,7 @@ export const EXTERNAL_PROVIDER_TWITCH = {},}-export const EXTERNAL_PROVIDER_TWITTER = {+const EXTERNAL_PROVIDER_TWITTER = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Twitter',@@ -840,7 +842,7 @@ export const EXTERNAL_PROVIDER_TWITTER = {},}-export const EXTERNAL_PROVIDER_SLACK = {+const EXTERNAL_PROVIDER_SLACK = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Slack',@@ -877,7 +879,7 @@ export const EXTERNAL_PROVIDER_SLACK = {},}-export const EXTERNAL_PROVIDER_SPOTIFY = {+const EXTERNAL_PROVIDER_SPOTIFY = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'Spotify',@@ -914,7 +916,7 @@ export const EXTERNAL_PROVIDER_SPOTIFY = {},}-export const EXTERNAL_PROVIDER_WORKOS = {+const EXTERNAL_PROVIDER_WORKOS = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'WorkOS',@@ -962,7 +964,7 @@ export const EXTERNAL_PROVIDER_WORKOS = {},}-export const EXTERNAL_PROVIDER_ZOOM = {+const EXTERNAL_PROVIDER_ZOOM = {$schema: JSON_SCHEMA_VERSION,type: 'object',title: 'zoom',@@ -1519,7 +1521,6 @@ export const OLD = {export const PROVIDERS_SCHEMAS = [PROVIDER_EMAIL,PROVIDER_PHONE,-EXTERNAL_PROVIDER_APPLE,EXTERNAL_PROVIDER_AZURE,EXTERNAL_PROVIDER_BITBUCKET,diff --git a/studio/stores/authConfig/schema/AuthProviders/AuthTemplatesValidation.tsx b/studio/stores/authConfig/schema/AuthProviders/AuthTemplatesValidation.tsxindex 6caef62e8a6..9cfa51468a0 100644--- a/studio/stores/authConfig/schema/AuthProviders/AuthTemplatesValidation.tsx+++ b/studio/stores/authConfig/schema/AuthProviders/AuthTemplatesValidation.tsx@@ -148,26 +148,4 @@ export const RECOVERY: FormSchema = {},}-export const SMS: FormSchema = {- $schema: JSON_SCHEMA_VERSION,- id: 'SMS',- type: 'object',- title: 'SMS Message',- properties: {- SMS_TEMPLATE: {- title: 'Message',- type: 'string',- description: 'To format the OPT code use `{{ .Code }}`',- },- },- validationSchema: object().shape({- SMS_TEMPLATE: string().required('"SMS template is required.'),- }),- misc: {- iconKey: 'email-icon2',- helper: `To complete setup, add this authorisation callback URL to your app's configuration in the Apple Developer Console.- [Learn more](https://supabase.com/docs/guides/auth/auth-apple#configure-your-services-id)`,- },-}--export const TEMPLATES_SCHEMAS = [CONFIRMATION, INVITE, MAGIC_LINK, EMAIL_CHANGE, RECOVERY, SMS]+export const TEMPLATES_SCHEMAS = [CONFIRMATION, INVITE, MAGIC_LINK, EMAIL_CHANGE, RECOVERY]diff --git a/studio/stores/jsonSchema/auth_gotrue_config.json b/studio/stores/jsonSchema/auth_gotrue_config.jsonindex 27af5fd66a6..22b97d4af6f 100644--- a/studio/stores/jsonSchema/auth_gotrue_config.json+++ b/studio/stores/jsonSchema/auth_gotrue_config.json@@ -458,16 +458,6 @@"type": "integer","help": "Time interval where the same refresh token can be used to request for an access token."},- "SECURITY_CAPTCHA_ENABLED": {- "title": "hCaptcha protection",- "type": "boolean",- "help": "Enables hCaptcha protection on all auth endpoints."- },- "SECURITY_CAPTCHA_SECRET": {- "title": "hCaptcha sitekey",- "type": "string",- "help": "Secret (sitekey) used to verify hCaptcha challenges."- },"SMS_AUTOCONFIRM": {"title": "Enable phone confirmations","type": "boolean",