Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add clerk as third-party auth provider / TP-MAU pricing (#33327)

Stojan Dimitrovski127dd8afc9fa
diff --git a/apps/docs/content/guides/platform/manage-your-usage/monthly-active-users-third-party.mdx b/apps/docs/content/guides/platform/manage-your-usage/monthly-active-users-third-party.mdx
index 5a65b8b26a1..231653b5374 100644
--- a/apps/docs/content/guides/platform/manage-your-usage/monthly-active-users-third-party.mdx
+++ b/apps/docs/content/guides/platform/manage-your-usage/monthly-active-users-third-party.mdx
@@ -72,12 +72,12 @@ The count resets at the start of each billing cycle.
</Admonition>
-| Plan | Quota | Over-Usage |
-| ---------- | ------ | ---------------------------- |
-| Free | 50 | - |
-| Pro | 50 | $0.00325 per Third-Party MAU |
-| Team | 50 | $0.00325 per Third-Party MAU |
-| Enterprise | Custom | Custom |
+| Plan | Quota | Over-Usage |
+| ---------- | ------- | ---------------------------- |
+| Free | 50,000 | - |
+| Pro | 100,000 | $0.00325 per Third-Party MAU |
+| Team | 100,000 | $0.00325 per Third-Party MAU |
+| Enterprise | Custom | Custom |
## Billing examples
@@ -85,27 +85,27 @@ The count resets at the start of each billing cycle.
The organization's Third-Party MAU usage for the billing cycle is within the quota, so no charges apply.
-| Line Item | Units | Costs |
-| -------------------------------- | ------------------ | ------- |
-| Pro Plan | 1 | $25 |
-| Compute Hours Micro | 744 hours | $10 |
-| Monthly Active Third-Party Users | 37 Third-Party MAU | $0 |
-| **Subtotal** | | **$35** |
-| Compute Credits | | -$10 |
-| **Total** | | **$25** |
+| Line Item | Units | Costs |
+| -------------------------------- | ---------------------- | ------- |
+| Pro Plan | 1 | $25 |
+| Compute Hours Micro | 744 hours | $10 |
+| Monthly Active Third-Party Users | 37,000 Third-Party MAU | $0 |
+| **Subtotal** | | **$35** |
+| Compute Credits | | -$10 |
+| **Total** | | **$25** |
### Exceeding quota
The organization's Third-Party MAU usage for the billing cycle exceeds the quota by 4950, incurring charges for this additional usage.
-| Line Item | Units | Costs |
-| -------------------------------- | -------------------- | ---------- |
-| Pro Plan | 1 | $25 |
-| Compute Hours Micro | 744 hours | $10 |
-| Monthly Active Third-Party Users | 5000 Third-Party MAU | $16.09 |
-| **Subtotal** | | **$51.09** |
-| Compute Credits | | -$10 |
-| **Total** | | **$41.09** |
+| Line Item | Units | Costs |
+| -------------------------------- | ----------------------- | ----------- |
+| Pro Plan | 1 | $25 |
+| Compute Hours Micro | 744 hours | $10 |
+| Monthly Active Third-Party Users | 130,000 Third-Party MAU | $97.50 |
+| **Subtotal** | | **$132.50** |
+| Compute Credits | | -$10 |
+| **Total** | | **$122.50** |
## View usage
diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AddIntegrationDropdown.tsx b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AddIntegrationDropdown.tsx
index 71bb7e01fd4..35d7b81d707 100644
--- a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AddIntegrationDropdown.tsx
+++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AddIntegrationDropdown.tsx
@@ -1,10 +1,8 @@
import { ChevronDown } from 'lucide-react'
import Image from 'next/image'
-import { IS_PLATFORM } from 'common'
-import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
-import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
-import Link from 'next/link'
+import { useSelectedProject } from 'hooks/misc/useSelectedProject'
+import { useFlag } from 'hooks/ui/useFlag'
import {
Button,
cn,
@@ -26,8 +24,6 @@ interface AddIntegrationDropdownProps {
onSelectIntegrationType: (type: INTEGRATION_TYPES) => void
}
-const Providers: INTEGRATION_TYPES[] = ['firebase', 'auth0', 'awsCognito']
-
const ProviderDropdownItem = ({
disabled,
type,
@@ -53,12 +49,16 @@ const ProviderDropdownItem = ({
export const AddIntegrationDropdown = ({
onSelectIntegrationType,
}: AddIntegrationDropdownProps) => {
- const organization = useSelectedOrganization()
+ const selectedProject = useSelectedProject()
- const { data: subscription } = useOrgSubscriptionQuery(
- { orgSlug: organization?.slug },
- { enabled: IS_PLATFORM }
- )
+ const isClerkTPAEnabledFlag = useFlag<string>('isClerkTPAEnabledOnProjects')
+ const isClerkTPAEnabled =
+ selectedProject?.ref &&
+ isClerkTPAEnabledFlag &&
+ isClerkTPAEnabledFlag
+ .split(',')
+ .map((it) => it.trim())
+ .includes(selectedProject.ref)
return (
<DropdownMenu modal={false}>
@@ -73,45 +73,11 @@ export const AddIntegrationDropdown = ({
<ProviderDropdownItem type="firebase" onSelectIntegrationType={onSelectIntegrationType} />
- {subscription?.plan.id === 'free' ? (
- <>
- <DropdownMenuSeparator />
- <div className="bg-surface-200 -m-1 p-2">
- <DropdownMenuLabel className="grid gap-1">
- <p className="text-foreground-light">Unavailable on the Free plan</p>
- <p className="text-foreground-lighter text-xs">
- <Link
- target="_href"
- rel="noreferrer"
- className="underline hover:text-foreground-light transition"
- href={`/org/${organization?.slug}/billing`}
- >
- Upgrade your plan
- </Link>{' '}
- to add the following providers to your project.
- </p>
- </DropdownMenuLabel>
- <ProviderDropdownItem
- disabled
- type="auth0"
- onSelectIntegrationType={onSelectIntegrationType}
- />
- <ProviderDropdownItem
- disabled
- type="awsCognito"
- onSelectIntegrationType={onSelectIntegrationType}
- />
- </div>
- </>
- ) : (
- <>
- <ProviderDropdownItem type="auth0" onSelectIntegrationType={onSelectIntegrationType} />
- <ProviderDropdownItem
- type="awsCognito"
- onSelectIntegrationType={onSelectIntegrationType}
- />
- </>
+ {isClerkTPAEnabled && (
+ <ProviderDropdownItem type="clerk" onSelectIntegrationType={onSelectIntegrationType} />
)}
+ <ProviderDropdownItem type="auth0" onSelectIntegrationType={onSelectIntegrationType} />
+ <ProviderDropdownItem type="awsCognito" onSelectIntegrationType={onSelectIntegrationType} />
</DropdownMenuContent>
</DropdownMenu>
)
diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/CreateClerkAuthDialog.tsx b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/CreateClerkAuthDialog.tsx
new file mode 100644
index 00000000000..54ceb48dad1
--- /dev/null
+++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/CreateClerkAuthDialog.tsx
@@ -0,0 +1,143 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import { Trash } from 'lucide-react'
+import { useEffect } from 'react'
+import { SubmitHandler, useForm } from 'react-hook-form'
+import { toast } from 'sonner'
+import * as z from 'zod'
+
+import { useParams } from 'common'
+import { useCreateThirdPartyAuthIntegrationMutation } from 'data/third-party-auth/integration-create-mutation'
+import {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogSection,
+ DialogTitle,
+ FormControl_Shadcn_,
+ FormField_Shadcn_,
+ Form_Shadcn_,
+ Input_Shadcn_,
+ Separator,
+} from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+
+interface CreateClerkAuthIntegrationProps {
+ visible: boolean
+ prod?: boolean
+ onClose: () => void
+ // TODO: Remove this if this Dialog is only used for creating.
+ onDelete: () => void
+}
+
+const FORM_ID = 'create-firebase-auth-integration-form'
+
+const FormSchema = z
+ .object({
+ enabled: z.boolean(),
+ domain: z.string(),
+ })
+ .superRefine((val, ctx) => {
+ if (
+ !val.domain.match(/https:\/\/clerk([.][a-z0-9-]+){2,}\/?/) &&
+ !val.domain.match(/https:\/\/[a-z0-9-]+[.]clerk[.]accounts[.]dev\/?$/)
+ ) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.invalid_string,
+ path: ['domain'],
+ message:
+ 'Production Clerk domains use HTTPS and start with the clerk subdomain (https://clerk.example.com). Development Clerk domains use HTTPS and end with .clerk.accounts.dev (https://example.clerk.accounts.dev).',
+ validation: 'regex',
+ })
+ }
+ })
+
+export const CreateClerkAuthIntegrationDialog = ({
+ visible,
+ onClose,
+ onDelete,
+}: CreateClerkAuthIntegrationProps) => {
+ const { ref: projectRef } = useParams()
+ const { mutate: createAuthIntegration, isLoading } = useCreateThirdPartyAuthIntegrationMutation({
+ onSuccess: () => {
+ toast.success(`Successfully created a new Clerk integration.`)
+ onClose()
+ },
+ })
+
+ const form = useForm<z.infer<typeof FormSchema>>({
+ resolver: zodResolver(FormSchema),
+ defaultValues: {
+ enabled: true,
+ domain: '',
+ },
+ })
+
+ useEffect(() => {
+ if (visible) {
+ form.reset({
+ enabled: true,
+ domain: '',
+ })
+ // the form input doesn't exist when the form is reset
+ setTimeout(() => {
+ form.setFocus('domain')
+ }, 25)
+ }
+ }, [visible])
+
+ const onSubmit: SubmitHandler<z.infer<typeof FormSchema>> = async (values) => {
+ createAuthIntegration({
+ projectRef: projectRef!,
+ oidcIssuerUrl: values.domain,
+ })
+ }
+
+ return (
+ <Dialog open={visible} onOpenChange={() => onClose()}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle className="truncate">Add new Clerk connection</DialogTitle>
+ </DialogHeader>
+
+ <Separator />
+ <DialogSection>
+ <Form_Shadcn_ {...form}>
+ <form id={FORM_ID} onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
+ <p className="text-sm text-foreground-light">
+ This will enable a Clerk session token (JWT) from a specific access data from this
+ Supabase project.{' '}
+ </p>
+ <FormField_Shadcn_
+ key="domain"
+ control={form.control}
+ name="domain"
+ render={({ field }) => (
+ <FormItemLayout label="Clerk Domain">
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ {...field}
+ placeholder={
+ 'https://clerk.example.com / https://example.clerk.accounts.dev'
+ }
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </form>
+ </Form_Shadcn_>
+ </DialogSection>
+ <DialogFooter>
+ <Button disabled={isLoading} type="default" onClick={() => onClose()}>
+ Cancel
+ </Button>
+ <Button form={FORM_ID} htmlType="submit" disabled={isLoading} loading={isLoading}>
+ Create connection
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/IntegrationCard.tsx b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/IntegrationCard.tsx
index aab6710eec1..9b4fe99b4f0 100644
--- a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/IntegrationCard.tsx
+++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/IntegrationCard.tsx
@@ -65,6 +65,21 @@ export const getIntegrationTypeDescription = (type: INTEGRATION_TYPES) => {
.
</>
)
+
+ case 'clerk':
+ return (
+ <>
+ Allow users to use Supabase with Clerk. Additional setup may be required. You can read
+ more in the{' '}
+ <a
+ className="hover:decoration-brand underline hover:text-foreground transition"
+ href="https://supabase.com/docs/guides/auth/third-party/clerk"
+ >
+ documentation
+ </a>
+ .
+ </>
+ )
case 'custom':
default:
return 'Custom'
@@ -121,6 +136,14 @@ export const IntegrationTypeContent = ({
)
}
+ case 'clerk':
+ return (
+ <div className="text-sm flex flex-row gap-x-4">
+ <span className="text-foreground-light w-36">Domain</span>
+ <span className="text-foreground">{integration?.oidc_issuer_url ?? ''}</span>
+ </div>
+ )
+
case 'custom':
default:
return <>Custom</>
@@ -132,7 +155,6 @@ export const IntegrationCard = ({
canUpdateConfig,
onDelete,
}: IntegrationCardProps) => {
- const { ref: projectRef } = useParams()
let type = getIntegrationType(integration)
if (type === 'custom') {
diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/ThirdPartyAuthForm.utils.ts b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/ThirdPartyAuthForm.utils.ts
index 7c8486d26a3..c7f887e7162 100644
--- a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/ThirdPartyAuthForm.utils.ts
+++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/ThirdPartyAuthForm.utils.ts
@@ -1,24 +1,29 @@
import { ThirdPartyAuthIntegration } from 'data/third-party-auth/integrations-query'
import { BASE_PATH } from 'lib/constants'
-export const INTEGRATION_TYPES = ['firebase', 'auth0', 'awsCognito', 'custom'] as const
+export const INTEGRATION_TYPES = ['firebase', 'auth0', 'awsCognito', 'clerk', 'custom'] as const
export type INTEGRATION_TYPES = (typeof INTEGRATION_TYPES)[number]
export const getIntegrationType = (integration?: ThirdPartyAuthIntegration): INTEGRATION_TYPES => {
- if (
- integration?.oidc_issuer_url &&
- integration?.oidc_issuer_url.startsWith('https://securetoken.google.com/')
- ) {
+ if (integration?.oidc_issuer_url?.startsWith('https://securetoken.google.com/')) {
return 'firebase'
}
- if (integration?.oidc_issuer_url && integration?.oidc_issuer_url.includes('amazonaws.com')) {
+
+ if (integration?.oidc_issuer_url?.includes('amazonaws.com')) {
return 'awsCognito'
}
- if (integration?.oidc_issuer_url && integration?.oidc_issuer_url.includes('auth0.com')) {
+ if (integration?.oidc_issuer_url?.includes('auth0.com')) {
return 'auth0'
}
+ if (
+ integration?.oidc_issuer_url?.includes('.clerk.accounts.dev') ||
+ integration?.oidc_issuer_url?.startsWith('https://clerk.')
+ ) {
+ return 'clerk'
+ }
+
return 'custom'
}
@@ -30,6 +35,8 @@ export const getIntegrationTypeLabel = (type: INTEGRATION_TYPES) => {
return 'Auth0'
case 'awsCognito':
return 'Amazon Cognito'
+ case 'clerk':
+ return 'Clerk'
case 'custom':
default:
return 'Custom'
@@ -44,6 +51,9 @@ export const getIntegrationTypeIcon = (type: INTEGRATION_TYPES) => {
return `${BASE_PATH}/img/icons/auth0-icon.svg`
case 'awsCognito':
return `${BASE_PATH}/img/icons/cognito-icon.svg`
+ case 'clerk':
+ return `${BASE_PATH}/img/icons/clerk-icon.svg`
+
case 'custom':
default:
return `${BASE_PATH}/img/icons/cognito-icon.svg`
diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx
index 39e81d3c9d7..0a51c9dea52 100644
--- a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx
+++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx
@@ -18,12 +18,14 @@ import { AddIntegrationDropdown } from './AddIntegrationDropdown'
import { CreateAuth0IntegrationDialog } from './CreateAuth0Dialog'
import { CreateAwsCognitoAuthIntegrationDialog } from './CreateAwsCognitoAuthDialog'
import { CreateFirebaseAuthIntegrationDialog } from './CreateFirebaseAuthDialog'
+import { CreateClerkAuthIntegrationDialog } from './CreateClerkAuthDialog'
import { IntegrationCard } from './IntegrationCard'
import {
getIntegrationType,
getIntegrationTypeLabel,
INTEGRATION_TYPES,
} from './ThirdPartyAuthForm.utils'
+import Link from 'next/link'
export const ThirdPartyAuthForm = () => {
const { ref: projectRef } = useParams()
@@ -65,13 +67,16 @@ export const ThirdPartyAuthForm = () => {
}
docsUrl="https://supabase.com/docs/guides/auth/third-party/overview"
/>
- <div className="prose text-sm mb-6 max-w-full">
- <span>
- Billing is based on the number of monthly active users (MAUs) requesting your API
- throughout the billing period (50 included then you'll be charged{' '}
- </span>
- <span className="text-brand">$0.00325</span>
- <span> per MAU).</span>
+ <div className="prose text-sm mb-6 max-w-full prose">
+ Billing is based on the number of distinct monthly active users (MAUs) requesting your API
+ throughout the billing period, see{' '}
+ <Link
+ href="/docs/guides/platform/manage-your-usage/monthly-active-users-third-party"
+ target="_blank"
+ >
+ billing docs
+ </Link>
+ .
</div>
{isLoading && (
<div
@@ -132,6 +137,12 @@ export const ThirdPartyAuthForm = () => {
onClose={() => setSelectedIntegration(undefined)}
/>
+ <CreateClerkAuthIntegrationDialog
+ visible={selectedIntegration === 'clerk'}
+ onDelete={() => {}}
+ onClose={() => setSelectedIntegration(undefined)}
+ />
+
<ConfirmationModal
visible={!!selectedIntegrationForDeletion}
variant="destructive"
diff --git a/apps/studio/components/interfaces/Billing/SpendCapModal.tsx b/apps/studio/components/interfaces/Billing/SpendCapModal.tsx
index 3abb6cd471c..6e7b5eac1e1 100644
--- a/apps/studio/components/interfaces/Billing/SpendCapModal.tsx
+++ b/apps/studio/components/interfaces/Billing/SpendCapModal.tsx
@@ -65,7 +65,7 @@ const SpendCapModal = ({ visible, onHide }: SpendCapModalProps) => {
<TableRow>
<TableCell>Auth Third-Party MAUs</TableCell>
- <TableCell>50</TableCell>
+ <TableCell>100,000</TableCell>
<TableCell>$0.00325 per user</TableCell>
</TableRow>
diff --git a/apps/studio/public/img/icons/clerk-icon.svg b/apps/studio/public/img/icons/clerk-icon.svg
new file mode 100644
index 00000000000..93d243f9cd9
--- /dev/null
+++ b/apps/studio/public/img/icons/clerk-icon.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
+<ellipse cx="16.0003" cy="16" rx="4.99998" ry="5" fill="#6C47FF" style="fill:#6C47FF;fill:color(display-p3 0.4235 0.2784 1.0000);fill-opacity:1;"/>
+<path d="M25.0091 27.8382C25.4345 28.2636 25.3918 28.9679 24.8919 29.3027C22.3488 31.0062 19.2899 31.9997 15.999 31.9997C12.7082 31.9997 9.64934 31.0062 7.10615 29.3027C6.60632 28.9679 6.56361 28.2636 6.989 27.8382L10.6429 24.1843C10.9732 23.854 11.4855 23.8019 11.9012 24.0148C13.1302 24.6445 14.5232 24.9997 15.999 24.9997C17.4749 24.9997 18.8678 24.6445 20.0969 24.0148C20.5126 23.8019 21.0249 23.854 21.3552 24.1843L25.0091 27.8382Z" fill="#6C47FF" style="fill:#6C47FF;fill:color(display-p3 0.4235 0.2784 1.0000);fill-opacity:1;"/>
+<path d="M24.8928 2.697C25.3926 3.0318 25.4353 3.73609 25.0099 4.16149L21.356 7.81544C21.0258 8.14569 20.5134 8.19785 20.0978 7.98491C18.8687 7.35525 17.4758 7 15.9999 7C11.0294 7 6.99997 11.0294 6.99997 16C6.99997 17.4759 7.35522 18.8688 7.98488 20.0979C8.19782 20.5136 8.14565 21.0259 7.81541 21.3561L4.16147 25.0101C3.73607 25.4355 3.03178 25.3927 2.69698 24.8929C0.993522 22.3497 0 19.2909 0 16C0 7.16344 7.16341 0 15.9999 0C19.2908 0 22.3496 0.993529 24.8928 2.697Z" fill="#BAB1FF" style="fill:#BAB1FF;fill:color(display-p3 0.7294 0.6941 1.0000);fill-opacity:1;"/>
+</svg>
diff --git a/packages/shared-data/pricing.ts b/packages/shared-data/pricing.ts
index c9e718a54c3..4156922ae1b 100644
--- a/packages/shared-data/pricing.ts
+++ b/packages/shared-data/pricing.ts
@@ -313,9 +313,9 @@ export const pricing: Pricing = {
key: 'auth.thirdPartyMAUs',
title: 'Third-Party MAUs',
plans: {
- free: '50 included',
- pro: ['50 included', 'then $0.00325 per MAU'],
- team: ['50 included', 'then $0.00325 per MAU'],
+ free: '50,000 included',
+ pro: ['100,000 included', 'then $0.00325 per MAU'],
+ team: ['100,000 included', 'then $0.00325 per MAU'],
enterprise: 'Custom',
},
usage_based: true,