The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add support for multiple custom auth providers in custom-content (#48030)
Joshen Lim8962308215a0
diff --git a/apps/studio/components/interfaces/SignIn/SignInWithCustom.tsx b/apps/studio/components/interfaces/SignIn/SignInWithCustom.tsxindex 05ea9935e2d..19feedfb1c1 100644--- a/apps/studio/components/interfaces/SignIn/SignInWithCustom.tsx+++ b/apps/studio/components/interfaces/SignIn/SignInWithCustom.tsx@@ -10,6 +10,10 @@ interface SignInWithCustomProps {providerName: string}+const formatProviderName = (name: string) => {+ return name.replace('custom:', '')+}+export const SignInWithCustom = ({ providerName }: SignInWithCustomProps) => {const [loading, setLoading] = useState(false)@@ -42,7 +46,7 @@ export const SignInWithCustom = ({ providerName }: SignInWithCustomProps) => {return (<Button block onClick={handleCustomSignIn} size="large" variant="default" loading={loading}>- Continue with {providerName}+ Continue with <span className="capitalize">{formatProviderName(providerName)}</span></Button>)}diff --git a/apps/studio/hooks/custom-content/CustomContent.types.ts b/apps/studio/hooks/custom-content/CustomContent.types.tsindex b62e124743d..d965508912d 100644--- a/apps/studio/hooks/custom-content/CustomContent.types.ts+++ b/apps/studio/hooks/custom-content/CustomContent.types.ts@@ -5,6 +5,8 @@ export type CustomContentTypes = {dashboardAuthCustomProvider: string+ dashboardAuthCustomProviders: string[]+docsRowLevelSecurityGuidePath: stringorganizationLegalDocuments: {diff --git a/apps/studio/hooks/custom-content/custom-content.json b/apps/studio/hooks/custom-content/custom-content.jsonindex 717ecb5852b..a3ffff7d1d0 100644--- a/apps/studio/hooks/custom-content/custom-content.json+++ b/apps/studio/hooks/custom-content/custom-content.json@@ -5,6 +5,8 @@"dashboard_auth:custom_provider": null,+ "dashboard_auth:custom_providers": null,+"docs:row_level_security_guide_path": "/guides/auth/row-level-security","organization:legal_documents": null,diff --git a/apps/studio/hooks/custom-content/custom-content.sample.json b/apps/studio/hooks/custom-content/custom-content.sample.jsonindex 6cc90b3f621..23ac2df49b5 100644--- a/apps/studio/hooks/custom-content/custom-content.sample.json+++ b/apps/studio/hooks/custom-content/custom-content.sample.json@@ -5,6 +5,8 @@"dashboard_auth:custom_provider": "Nimbus",+ "dashboard_auth:custom_providers": ["Nimbus"],+"docs:row_level_security_guide_path": "/guides/database/postgres/row-level-security","organization:legal_documents": [diff --git a/apps/studio/hooks/custom-content/custom-content.schema.json b/apps/studio/hooks/custom-content/custom-content.schema.jsonindex f6f80dd2722..3fed50e746c 100644--- a/apps/studio/hooks/custom-content/custom-content.schema.json+++ b/apps/studio/hooks/custom-content/custom-content.schema.json@@ -13,7 +13,15 @@"dashboard_auth:custom_provider": {"type": ["string", "null"],- "description": "Show a custom provider on the sign in page (Continue with X)"+ "description": "Show a custom provider on the sign in page (Continue with X). Will be deprecated by dashboard_auth:custom_providers."+ },++ "dashboard_auth:custom_providers": {+ "type": ["array", "null"],+ "description": "Show a custom provider on the sign in page (Continue with X)",+ "items": {+ "type": "string"+ }},"docs:row_level_security_guide_path": {diff --git a/apps/studio/hooks/custom-content/useCustomContent.ts b/apps/studio/hooks/custom-content/useCustomContent.tsindex f125025178e..bbf69aec53e 100644--- a/apps/studio/hooks/custom-content/useCustomContent.ts+++ b/apps/studio/hooks/custom-content/useCustomContent.ts@@ -27,16 +27,12 @@ function contentToCamelCase(feature: CustomContent) {export const useCustomContent = <T extends CustomContent[]>(contents: T): {- [key in CustomContentToCamelCase<T[number]>]:- | CustomContentTypes[CustomContentToCamelCase<T[number]>]- | null+ [key in CustomContentToCamelCase<T[number]>]: CustomContentTypes[key] | null} => {// [Joshen] Running into some TS errors without the `as` here - must be overlooking something super simplereturn Object.fromEntries(contents.map((content) => [contentToCamelCase(content), customContentStaticObj[content]])) as {- [key in CustomContentToCamelCase<T[number]>]:- | CustomContentTypes[CustomContentToCamelCase<T[number]>]- | null+ [key in CustomContentToCamelCase<T[number]>]: CustomContentTypes[key] | null}}diff --git a/apps/studio/pages/sign-in.tsx b/apps/studio/pages/sign-in.tsxindex aeffd266dc3..9cf0b1c6ea5 100644--- a/apps/studio/pages/sign-in.tsx+++ b/apps/studio/pages/sign-in.tsx@@ -32,9 +32,14 @@ const SignInPage: NextPageWithLayout = () => {'dashboard_auth:sign_up',])- const { dashboardAuthCustomProvider: customProvider } = useCustomContent([- 'dashboard_auth:custom_provider',- ])+ const {+ dashboardAuthCustomProvider: customProvider,+ dashboardAuthCustomProviders: customProvidersNew,+ } = useCustomContent(['dashboard_auth:custom_provider', 'dashboard_auth:custom_providers'])++ // [Joshen] This is just for backward compatibility - singular customProvider needs to be deprecated subsequently+ // Just need to remove customProvider and rename customProvidersNew to customProviders+ const customProviders = customProvidersNew ?? (customProvider ? [customProvider] : [])const { focusProvider } = useInboundBranding('sign-in')const signInProviders = useEnabledIdentityProviders().filter((provider) => provider.showOnSignIn)@@ -44,11 +49,15 @@ const SignInPage: NextPageWithLayout = () => {dividerBgClass = 'bg-studio') => {const showOrDivider =- (providers.length > 0 || signInWithSsoEnabled || !!customProvider) && signInWithEmailEnabled+ (providers.length > 0 || signInWithSsoEnabled || customProviders.length > 0) &&+ signInWithEmailEnabledreturn (<>- {customProvider && <SignInWithCustom providerName={customProvider} />}+ {Array.isArray(customProviders) &&+ customProviders.map((providerName: string) => (+ <SignInWithCustom key={providerName} providerName={providerName} />+ ))}{providers.map((provider) => (<SignInWithExternalProvider key={provider.id} provider={provider} />))}@@ -90,7 +99,7 @@ const SignInPage: NextPageWithLayout = () => {const hasOtherOptions =otherProviders.length > 0 ||signInWithSsoEnabled ||- !!customProvider ||+ customProviders.length > 0 ||signInWithEmailEnabledreturn (