The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Make secret fields in auth config/smtp form visibility toggleable
Joshen Limf06ee0982254
diff --git a/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.types.ts b/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.types.tsindex 1aef61b6539..fcc638cf630 100644--- a/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.types.ts+++ b/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.types.ts@@ -12,14 +12,15 @@ export interface Provider {[x: string]: {title: stringtype: 'boolean' | 'string' | 'select' | 'number'- description?: string- descriptionOptional?: string- units?: stringenum: Enum[]show: {key: stringmatches: string}+ description?: string+ descriptionOptional?: string+ units?: string+ isSecret?: boolean}}validationSchema: any // todo: use Yup typediff --git a/studio/components/interfaces/Auth/AuthProvidersForm/FormField.tsx b/studio/components/interfaces/Auth/AuthProvidersForm/FormField.tsxnew file mode 100644index 00000000000..b93a366d108--- /dev/null+++ b/studio/components/interfaces/Auth/AuthProvidersForm/FormField.tsx@@ -0,0 +1,136 @@+import { FC, useState } from 'react'+import ReactMarkdown from 'react-markdown'+import { Button, Input, InputNumber, Toggle, Listbox, IconEye, IconEyeOff } from '@supabase/ui'+import { Enum } from './AuthProvidersForm.types'++interface Props {+ name: string+ properties: any+ formValues: any+}++const FormField: FC<Props> = ({ name, properties, formValues }) => {+ if (properties.show && formValues[properties.show.key] !== properties.show.matches) return <></>++ const [hidden, setHidden] = useState(!!properties.isSecret)++ switch (properties.type) {+ case 'string':+ return (+ <Input+ size="small"+ layout="vertical"+ id={name}+ name={name}+ type={hidden ? 'password' : 'text'}+ label={properties.title}+ labelOptional={+ properties.descriptionOptional ? (+ <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>+ {properties.descriptionOptional}+ </ReactMarkdown>+ ) : null+ }+ descriptionText={+ properties.description ? (+ <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>+ {properties.description}+ </ReactMarkdown>+ ) : null+ }+ actions={+ !!properties.isSecret ? (+ <Button+ icon={hidden ? <IconEye /> : <IconEyeOff />}+ type="default"+ onClick={() => setHidden(!hidden)}+ />+ ) : (+ <span className="text-scale-900 mr-3">+ {properties.units ? (+ <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>+ {properties.units}+ </ReactMarkdown>+ ) : null}+ </span>+ )+ }+ />+ )+ case 'number':+ return (+ <InputNumber+ size="small"+ layout="vertical"+ id={name}+ name={name}+ label={properties.title}+ labelOptional={+ properties.descriptionOptional ? (+ <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>+ {properties.descriptionOptional}+ </ReactMarkdown>+ ) : null+ }+ descriptionText={+ properties.description ? (+ <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>+ {properties.description}+ </ReactMarkdown>+ ) : null+ }+ actions={+ <span className="text-scale-900 mr-3">+ {properties.units ? (+ <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>+ {properties.units}+ </ReactMarkdown>+ ) : null}+ </span>+ }+ />+ )++ case 'boolean':+ return (+ <Toggle+ size="small"+ id={name}+ name={name}+ label={properties.title}+ descriptionText={properties.description}+ />+ )++ case 'select':+ return (+ <Listbox+ size="small"+ name={name}+ label={properties.title}+ descriptionText={properties.description}+ defaultValue={properties.enum[0]}+ >+ {properties.enum.map((option: Enum) => {+ return (+ <Listbox.Option+ id={option.value}+ label={option.label}+ value={option.value}+ addOnBefore={() => <img className="h-6 w-6" src={`/img/icons/${option.icon}`} />}+ >+ {option.label}+ </Listbox.Option>+ )+ })}+ </Listbox>+ )++ default:+ break+ }++ return <></>+}++export default FormFielddiff --git a/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx b/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsxindex bc9db760c88..dd6ba809d51 100644--- a/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx+++ b/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx@@ -1,22 +1,11 @@import { FC, useEffect, useState } from 'react'import ReactMarkdown from 'react-markdown'-import {- Alert,- Button,- Collapsible,- Form,- IconCheck,- IconChevronUp,- Input,- InputNumber,- Listbox,- Toggle,-} from '@supabase/ui'+import { Alert, Button, Collapsible, Form, IconCheck, IconChevronUp, Input } from '@supabase/ui'import { useStore } from 'hooks'-import { Enum, Provider } from './AuthProvidersForm.types'+import { Provider } from './AuthProvidersForm.types'import { ProviderCollapsibleClasses } from './AuthProvidersForm.constants'-import { createConsoleLogger } from 'configcat-js'+import FormField from './FormField'interface Props {provider: Provider@@ -129,128 +118,14 @@ const ProviderForm: FC<Props> = ({ provider }) => {"><div className="mx-auto my-6 max-w-md space-y-6">- {Object.keys(provider.properties).map((x: string) => {- const properties = provider.properties[x]- // Conditionally hide properties based on value of key- if (- properties.show &&- values[properties.show.key] !== properties.show.matches- ) {- return null- }- switch (properties.type) {- case 'string':- return (- <Input- size="small"- layout="vertical"- id={x}- key={x}- name={x}- label={properties.title}- labelOptional={- properties.descriptionOptional ? (- <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>- {properties.descriptionOptional}- </ReactMarkdown>- ) : null- }- descriptionText={- properties.description ? (- <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>- {properties.description}- </ReactMarkdown>- ) : null- }- actions={- <span className="text-scale-900 mr-3">- {properties.units ? (- <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>- {properties.units}- </ReactMarkdown>- ) : null}- </span>- }- />- )-- case 'number':- return (- <InputNumber- size="small"- layout="vertical"- id={x}- key={x}- name={x}- label={properties.title}- labelOptional={- properties.descriptionOptional ? (- <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>- {properties.descriptionOptional}- </ReactMarkdown>- ) : null- }- descriptionText={- properties.description ? (- <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>- {properties.description}- </ReactMarkdown>- ) : null- }- actions={- <span className="text-scale-900 mr-3">- {properties.units ? (- <ReactMarkdown unwrapDisallowed disallowedElements={['p']}>- {properties.units}- </ReactMarkdown>- ) : null}- </span>- }- />- )-- case 'boolean':- return (- <Toggle- size="small"- key={x}- name={x}- label={properties.title}- descriptionText={properties.description}- />- )-- case 'select':- return (- <Listbox- size="small"- key={x}- name={x}- label={properties.title}- descriptionText={properties.description}- defaultValue={properties.enum[0]}- >- {properties.enum.map((option: Enum) => {- return (- <Listbox.Option- id={option.value}- label={option.label}- value={option.value}- addOnBefore={() => (- <img className="h-6 w-6" src={`/img/icons/${option.icon}`} />- )}- >- {option.label}- </Listbox.Option>- )- })}- </Listbox>- )-- default:- break- }- })}+ {Object.keys(provider.properties).map((x: string) => (+ <FormField+ key={x}+ name={x}+ properties={provider.properties[x]}+ formValues={values}+ />+ ))}{provider?.misc?.alert && (<Alert title={provider.misc.alert.title} variant="warning" withIcon><ReactMarkdown>{provider.misc.alert.description}</ReactMarkdown>diff --git a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsxindex 32f9786d2b3..a9b736e7925 100644--- a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx+++ b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx@@ -1,7 +1,7 @@-import { Alert, Form, Input, InputNumber, Toggle } from '@supabase/ui'import { observer } from 'mobx-react-lite'import { useEffect, useState } from 'react'import { number, object, string } from 'yup'+import { Alert, Button, Form, Input, InputNumber, Toggle, IconEye, IconEyeOff } from '@supabase/ui'import {FormActions,@@ -18,9 +18,11 @@ import { generateFormValues, isSmtpEnabled } from './SmtpForm.utils'const SmtpForm = () => {const { authConfig, ui } = useStore()- const [enableSmtp, setEnableSmtp] = useState(false)const { config, isLoaded } = authConfig+ const [enableSmtp, setEnableSmtp] = useState(false)+ const [hidden, setHidden] = useState(true)+const formId = 'auth-config-smtp-form'const initialValues = generateFormValues(authConfig.config)@@ -265,8 +267,16 @@ const SmtpForm = () => {<Inputname="SMTP_PASS"id="SMTP_PASS"+ type={hidden ? 'password' : 'text'}label="Password"placeholder="SMTP Password"+ actions={+ <Button+ icon={hidden ? <IconEye /> : <IconEyeOff />}+ type="default"+ onClick={() => setHidden(!hidden)}+ />+ }/></FormSectionContent></FormSection>diff --git a/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx b/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsxindex 28f801d5e56..0dd9964fcd4 100644--- a/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx+++ b/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx@@ -86,6 +86,7 @@ const PROVIDER_PHONE = {SMS_TWILIO_AUTH_TOKEN: {type: 'string',title: 'Twilio Auth Token',+ isSecret: true,show: {key: 'SMS_PROVIDER',matches: 'twilio',@@ -311,6 +312,7 @@ Client identifier when authenticating or validating users.The secret key is a JWT token that must be generated.[Learn more](https://supabase.com/docs/guides/auth/auth-apple#generate-a-client_secret)`,type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -356,6 +358,7 @@ const EXTERNAL_PROVIDER_AZURE = {// [TODO] Change docstitle: 'Secret ID',type: 'string',+ isSecret: true,},EXTERNAL_AZURE_URL: {// [TODO] Change docs@@ -400,6 +403,7 @@ const EXTERNAL_PROVIDER_BITBUCKET = {EXTERNAL_BITBUCKET_SECRET: {title: 'Secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -437,6 +441,7 @@ const EXTERNAL_PROVIDER_DISCORD = {EXTERNAL_DISCORD_SECRET: {title: 'Client Secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -474,6 +479,7 @@ const EXTERNAL_PROVIDER_FACEBOOK = {EXTERNAL_FACEBOOK_SECRET: {title: 'Facebook secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -511,6 +517,7 @@ const EXTERNAL_PROVIDER_GITHUB = {EXTERNAL_GITHUB_SECRET: {title: 'Client Secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -550,6 +557,7 @@ const EXTERNAL_PROVIDER_GITLAB = {EXTERNAL_GITLAB_SECRET: {title: 'Secret',type: 'string',+ isSecret: true,},EXTERNAL_GITLAB_URL: {title: 'Self Hosted GitLab URL',@@ -595,6 +603,7 @@ const EXTERNAL_PROVIDER_GOOGLE = {EXTERNAL_GOOGLE_SECRET: {title: 'Client Secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -633,6 +642,7 @@ const EXTERNAL_PROVIDER_KEYCLOAK = {EXTERNAL_KEYCLOAK_SECRET: {title: 'Secret',type: 'string',+ isSecret: true,},EXTERNAL_KEYCLOAK_URL: {title: 'Realm URL',@@ -683,6 +693,7 @@ const EXTERNAL_PROVIDER_LINKEDIN = {EXTERNAL_LINKEDIN_SECRET: {title: 'API Secret Key',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -720,6 +731,7 @@ const EXTERNAL_PROVIDER_NOTION = {EXTERNAL_NOTION_SECRET: {title: 'OAuth client secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -757,6 +769,7 @@ const EXTERNAL_PROVIDER_TWITCH = {EXTERNAL_TWITCH_SECRET: {title: 'Client secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -794,6 +807,7 @@ const EXTERNAL_PROVIDER_TWITTER = {EXTERNAL_TWITTER_SECRET: {title: 'API Secret Key',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -831,6 +845,7 @@ const EXTERNAL_PROVIDER_SLACK = {EXTERNAL_SLACK_SECRET: {title: 'Client Secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -868,6 +883,7 @@ const EXTERNAL_PROVIDER_SPOTIFY = {EXTERNAL_SPOTIFY_SECRET: {title: 'Client Secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -909,6 +925,7 @@ const EXTERNAL_PROVIDER_WORKOS = {EXTERNAL_WORKOS_SECRET: {title: 'Secret Key',type: 'string',+ isSecret: true,},},validationSchema: object().shape({@@ -953,6 +970,7 @@ const EXTERNAL_PROVIDER_ZOOM = {EXTERNAL_ZOOM_SECRET: {title: 'Client secret',type: 'string',+ isSecret: true,},},validationSchema: object().shape({