Skip to content

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

feat: add sign in with solana (web3) configuration UI (#34909)

Stojan Dimitrovski49c677dff40b
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx
index 292497680b3..a5b9834684c 100644
--- a/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx
+++ b/apps/studio/components/interfaces/Auth/AuthProvidersForm/AuthProvidersForm.tsx
@@ -84,6 +84,8 @@ export const AuthProvidersForm = () => {
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 {
isActive =
authConfig &&
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersFormValidation.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersFormValidation.tsx
index 2e99814461b..1931a49b408 100644
--- a/apps/studio/components/interfaces/Auth/AuthProvidersFormValidation.tsx
+++ b/apps/studio/components/interfaces/Auth/AuthProvidersFormValidation.tsx
@@ -1386,10 +1386,32 @@ const PROVIDER_SAML = {
},
}
+const PROVIDER_WEB3 = {
+ $schema: JSON_SCHEMA_VERSION,
+ type: 'object',
+ title: 'Web3 Wallet (Solana)',
+ link: 'https://supabase.com/docs/guides/auth/auth-web3',
+ properties: {
+ EXTERNAL_WEB3_SOLANA_ENABLED: {
+ title: 'Enable Sign in with Solana',
+ description:
+ 'Allow Solana wallet holders to sign in to your project via the Sign in with Solana (SIWS, EIP-4361) standard. Set up [attack protection](../auth/protection) and adjust [rate limits](../auth/rate-limits) to counter abuse.',
+ type: 'boolean',
+ },
+ },
+ validationSchema: object().shape({
+ EXTERNAL_WEB3_SOLANA_ENABLED: boolean().required(),
+ }),
+ misc: {
+ iconKey: 'web3-icon',
+ },
+}
+
export const PROVIDERS_SCHEMAS = [
PROVIDER_EMAIL,
PROVIDER_PHONE,
PROVIDER_SAML,
+ PROVIDER_WEB3,
EXTERNAL_PROVIDER_APPLE,
EXTERNAL_PROVIDER_AZURE,
EXTERNAL_PROVIDER_BITBUCKET,
diff --git a/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx b/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx
index 7b72ddd9e2a..30befae90b5 100644
--- a/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx
+++ b/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx
@@ -54,6 +54,7 @@ const RateLimits = () => {
const canUpdateEmailLimit = authConfig?.EXTERNAL_EMAIL_ENABLED && isSmtpEnabled(authConfig)
const canUpdateSMSRateLimit = authConfig?.EXTERNAL_PHONE_ENABLED
const canUpdateAnonymousUsersRateLimit = authConfig?.EXTERNAL_ANONYMOUS_USERS_ENABLED
+ const canUpdateWeb3RateLimit = authConfig?.EXTERNAL_WEB3_SOLANA_ENABLED
const FormSchema = z.object({
RATE_LIMIT_TOKEN_REFRESH: z.coerce
@@ -80,6 +81,10 @@ const RateLimits = () => {
.number()
.min(0, 'Must be not be lower than 0')
.max(32767, 'Must not be more than 32,767 an hour'),
+ RATE_LIMIT_WEB3: z.coerce
+ .number()
+ .min(0, 'Must be not be lower than 0')
+ .max(32767, 'Must not be more than 32,767 an hour'),
})
const form = useForm<z.infer<typeof FormSchema>>({
@@ -91,6 +96,7 @@ const RateLimits = () => {
RATE_LIMIT_SMS_SENT: 0,
RATE_LIMIT_ANONYMOUS_USERS: 0,
RATE_LIMIT_OTP: 0,
+ RATE_LIMIT_WEB3: 0,
},
})
@@ -105,6 +111,7 @@ const RateLimits = () => {
'RATE_LIMIT_SMS_SENT',
'RATE_LIMIT_ANONYMOUS_USERS',
'RATE_LIMIT_OTP',
+ 'RATE_LIMIT_WEB3',
] as (keyof typeof payload)[]
params.forEach((param) => {
if (data[param] !== authConfig?.[param]) payload[param] = data[param]
@@ -122,6 +129,7 @@ const RateLimits = () => {
RATE_LIMIT_SMS_SENT: authConfig.RATE_LIMIT_SMS_SENT,
RATE_LIMIT_ANONYMOUS_USERS: authConfig.RATE_LIMIT_ANONYMOUS_USERS,
RATE_LIMIT_OTP: authConfig.RATE_LIMIT_OTP,
+ RATE_LIMIT_WEB3: authConfig.RATE_LIMIT_WEB3 ?? 0,
})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -366,9 +374,9 @@ const RateLimits = () => {
{!canUpdateConfig || !canUpdateAnonymousUsersRateLimit ? (
<TooltipContent side="left" className="w-80 p-4">
<p className="font-medium">
- Anonymous logins are not enabled for your project
+ Anonymous sign-ins are not enabled for your project. Enable them to
+ control this rate limit.
</p>
- <p className="mt-1">Enable anonymous logins to update this rate limit</p>
<div className="mt-3">
<Button asChild type="default" size="tiny">
<Link href={`/project/${projectRef}/auth/providers`}>
@@ -427,6 +435,49 @@ const RateLimits = () => {
/>
</CardContent>
+ <CardContent>
+ <FormField_Shadcn_
+ control={form.control}
+ name="RATE_LIMIT_WEB3"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Rate limit for Web3 sign up and sign-in"
+ description="Number of Web3 (Sign in with Solana) sign up or sign in requests that can be made per IP address in 5 minutes"
+ >
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ type="number"
+ className="w-24"
+ min={0}
+ {...field}
+ disabled={!canUpdateConfig || !canUpdateWeb3RateLimit}
+ />
+ </FormControl_Shadcn_>
+ </TooltipTrigger>
+ {!canUpdateConfig || !canUpdateWeb3RateLimit ? (
+ <TooltipContent side="left" className="w-80 p-4">
+ <p className="font-medium">
+ Web3 auth provider is not enabled for this project. Enable it to control
+ this rate limit.
+ </p>
+ <div className="mt-3">
+ <Button asChild type="default" size="tiny">
+ <Link href={`/project/${projectRef}/auth/providers`}>
+ View Auth provider settings
+ </Link>
+ </Button>
+ </div>
+ </TooltipContent>
+ ) : null}
+ </Tooltip>
+ </FormItemLayout>
+ )}
+ />
+ </CardContent>
+
<CardFooter className="justify-end space-x-2">
{form.formState.isDirty && (
<Button type="default" onClick={() => form.reset()}>
diff --git a/apps/studio/public/img/icons/web3-icon.svg b/apps/studio/public/img/icons/web3-icon.svg
new file mode 100644
index 00000000000..a2a8735da49
--- /dev/null
+++ b/apps/studio/public/img/icons/web3-icon.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="gray" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-wallet-icon lucide-wallet"><path d="M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"/><path d="M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"/></svg>
diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.ts
index 7432bff9644..ef64fa23810 100644
--- a/packages/api-types/types/api.d.ts
+++ b/packages/api-types/types/api.d.ts
@@ -4160,13 +4160,12 @@ export interface operations {
}
}
responses: {
- /** @description [Alpha] Create a new signing key for the project in standby status */
201: {
headers: {
[name: string]: unknown
}
content: {
- 'application/json': components['schemas']['CreateSigningKeyBody']
+ 'application/json': components['schemas']['SigningKeyResponse']
}
}
403: {
diff --git a/packages/api-types/types/platform.d.ts b/packages/api-types/types/platform.d.ts
index d18765310ac..b7bb05c7dca 100644
--- a/packages/api-types/types/platform.d.ts
+++ b/packages/api-types/types/platform.d.ts
@@ -5565,6 +5565,7 @@ export interface components {
EXTERNAL_TWITTER_CLIENT_ID: string
EXTERNAL_TWITTER_ENABLED: boolean
EXTERNAL_TWITTER_SECRET: string
+ EXTERNAL_WEB3_SOLANA_ENABLED: boolean
EXTERNAL_WORKOS_CLIENT_ID: string
EXTERNAL_WORKOS_ENABLED: boolean
EXTERNAL_WORKOS_SECRET: string