import { useParams } from 'common' import { ExternalLink } from 'lucide-react' import Link from 'next/link' import { Alert, AlertDescription, AlertTitle, Button, WarningIcon } from 'ui' import { PageSection, PageSectionContent, PageSectionDescription, PageSectionMeta, PageSectionSummary, PageSectionTitle, } from 'ui-patterns/PageSection' import { getPhoneProviderValidationSchema, PROVIDERS_SCHEMAS } from '../AuthProvidersFormValidation' import type { Provider } from './AuthProvidersForm.types' import { ProviderForm } from './ProviderForm' import AlertError from '@/components/ui/AlertError' import { ResourceList } from '@/components/ui/Resource/ResourceList' import { HorizontalShimmerWithIcon } from '@/components/ui/Shimmers' import { useAuthConfigQuery } from '@/data/auth/auth-config-query' export const AuthProvidersForm = () => { const { ref: projectRef } = useParams() const { data: authConfig, error: authConfigError, isPending: isLoading, isError, isSuccess, } = useAuthConfigQuery({ projectRef }) return ( Auth Providers Authenticate your users through a suite of providers and login methods {isError ? ( ) : (
{authConfig?.EXTERNAL_EMAIL_ENABLED && authConfig?.MAILER_OTP_EXP > 3600 && (
OTP expiry exceeds recommended threshold

We have detected that you have enabled the email provider with the OTP expiry set to more than an hour. It is recommended to set this value to less than an hour.

)} {isLoading && PROVIDERS_SCHEMAS.map((provider) => (
))} {isSuccess && PROVIDERS_SCHEMAS.map((provider) => { const providerSchema = provider.title === 'Phone' ? { ...provider, validationSchema: getPhoneProviderValidationSchema(authConfig), } : provider let isActive = false if (providerSchema.title === 'SAML 2.0') { isActive = authConfig && (authConfig as any)['SAML_ENABLED'] } else if (providerSchema.title === 'LinkedIn (OIDC)') { isActive = authConfig && (authConfig as any)['EXTERNAL_LINKEDIN_OIDC_ENABLED'] } else if (providerSchema.title === 'Slack (OIDC)') { isActive = authConfig && (authConfig as any)['EXTERNAL_SLACK_OIDC_ENABLED'] } else if (providerSchema.title.includes('Web3')) { isActive = authConfig && (authConfig as any)['EXTERNAL_WEB3_SOLANA_ENABLED'] } else if (providerSchema.title.includes('X / Twitter (OAuth 2.0)')) { isActive = authConfig && (authConfig as any)['EXTERNAL_X_ENABLED'] } else if (providerSchema.title === 'Twitter (Deprecated)') { isActive = authConfig && (authConfig as any)['EXTERNAL_TWITTER_ENABLED'] } else { isActive = authConfig && (authConfig as any)[`EXTERNAL_${providerSchema.title.toUpperCase()}_ENABLED`] } return ( ) })}
)}
) }