diff --git a/apps/docs/content/_partials/quickstart_db_setup.mdx b/apps/docs/content/_partials/quickstart_db_setup.mdx index cd282520da84d..161ea8b7f5edb 100644 --- a/apps/docs/content/_partials/quickstart_db_setup.mdx +++ b/apps/docs/content/_partials/quickstart_db_setup.mdx @@ -2,6 +2,28 @@ Go to [database.new](https://database.new) and create a new Supabase project. +Alternatively, you can create a project using the Management API: + +```bash +# First, get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" + +# List your organizations to get the organization ID +curl -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + https://api.supabase.com/v1/organizations + +# Create a new project (replace with your organization ID) +curl -X POST https://api.supabase.com/v1/projects \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "organization_id": "", + "name": "My Project", + "region": "us-east-1", + "password": "" + }' +``` + When your project is up and running, go to the [Table Editor](https://supabase.com/dashboard/project/_/editor), create a new table and insert some data. Alternatively, you can run the following snippet in your project's [SQL Editor](https://supabase.com/dashboard/project/_/sql/new). This will create a `instruments` table with some sample data. diff --git a/apps/docs/content/guides/auth/auth-email-templates.mdx b/apps/docs/content/guides/auth/auth-email-templates.mdx index af34bfd7f4cc0..20167f74ac32a 100644 --- a/apps/docs/content/guides/auth/auth-email-templates.mdx +++ b/apps/docs/content/guides/auth/auth-email-templates.mdx @@ -29,6 +29,36 @@ The templating system provides the following variables for use: On hosted Supabase projects, edit your email templates on the [Email Templates](/dashboard/project/_/auth/templates) page. On self-hosted projects or in local development, edit your [configuration files](/docs/guides/local-development/customizing-email-templates). +You can also manage email templates using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Get current email templates +curl -X GET "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + | jq 'to_entries | map(select(.key | startswith("mailer_templates"))) | from_entries' + +# Update email templates +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "mailer_subjects_confirmation": "Confirm your signup", + "mailer_templates_confirmation_content": "

Confirm your signup

Follow this link to confirm your user:

Confirm your email

", + "mailer_subjects_magic_link": "Your Magic Link", + "mailer_templates_magic_link_content": "

Magic Link

Follow this link to login:

Log In

", + "mailer_subjects_recovery": "Rest Your Password", + "mailer_templates_recovery_content": "

Reset Password

Follow this link to reset the password for your user:

Reset Password

", + "mailer_subjects_invite": "You have been invited", + "mailer_templates_invite_content": "

You have been invited

You have been invited to create a user on {{ .SiteURL }}. Follow this link to accept the invite:

Accept the invite

", + "mailer_subjects_email_change": "Confirm email change", + "mailer_templates_email_change_content": "

Confirm email change

Follow this link to confirm the update of your email:

Change email

", + }' +``` + ## Mobile deep linking For mobile applications, you might need to link or redirect to a specific page within your app. See the [Mobile Deep Linking guide](/docs/guides/auth/native-mobile-deep-linking) to set this up. diff --git a/apps/docs/content/guides/auth/auth-smtp.mdx b/apps/docs/content/guides/auth/auth-smtp.mdx index 1d1558d3c1882..5f7f05b0ed5d4 100644 --- a/apps/docs/content/guides/auth/auth-smtp.mdx +++ b/apps/docs/content/guides/auth/auth-smtp.mdx @@ -50,6 +50,30 @@ A non-exhaustive list of services that work with Supabase Auth is: Once you've set up your account with an email sending service, head to the [Authentication settings page](/dashboard/project/_/settings/auth) to enable and configure custom SMTP. +You can also configure custom SMTP using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure custom SMTP +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_email_enabled": true, + "mailer_secure_email_change_enabled": true, + "mailer_autoconfirm": false, + "smtp_admin_email": "no-reply@example.com", + "smtp_host": "smtp.example.com", + "smtp_port": 587, + "smtp_user": "your-smtp-user", + "smtp_pass": "your-smtp-password", + "smtp_sender_name": "Your App Name" + }' +``` + Once you save these settings, your project's Auth server will send messages to all addresses. To protect the reputation of your newly set up service a low rate-limit of 30 messages per hour is imposed. To adjust this to an acceptable value for your use case head to the [Rate Limits configuration page](/dashboard/project/_/auth/rate-limits). ## Dealing with abuse: How to maintain the sending reputation of your SMTP server? diff --git a/apps/docs/content/guides/auth/rate-limits.mdx b/apps/docs/content/guides/auth/rate-limits.mdx index 6edd22b0df8e7..1233f2c06b360 100644 --- a/apps/docs/content/guides/auth/rate-limits.mdx +++ b/apps/docs/content/guides/auth/rate-limits.mdx @@ -5,4 +5,31 @@ subtitle: 'Rate limits protect your services from abuse' Supabase Auth enforces rate limits on endpoints to prevent abuse. Some rate limits are [customizable](/dashboard/project/_/auth/rate-limits). +You can also manage rate limits using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Get current rate limits +curl -X GET "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + | jq 'to_entries | map(select(.key | startswith("rate_limit_"))) | from_entries' + +# Update rate limits +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "rate_limit_anonymous_users": 10, + "rate_limit_email_sent": 10, + "rate_limit_sms_sent": 10, + "rate_limit_verify": 10, + "rate_limit_token_refresh": 10, + "rate_limit_otp": 10, + "rate_limit_web3": 10 + }' +``` + <$Partial path="auth_rate_limits.mdx" /> diff --git a/apps/docs/content/guides/auth/social-login/auth-apple.mdx b/apps/docs/content/guides/auth/social-login/auth-apple.mdx index a80abc34d71c7..b2fd02f6eec26 100644 --- a/apps/docs/content/guides/auth/social-login/auth-apple.mdx +++ b/apps/docs/content/guides/auth/social-login/auth-apple.mdx @@ -67,6 +67,24 @@ When developing with Expo, you can test Sign in with Apple via the Expo Go app, 6. Create a signing **Key** in the [Keys](https://developer.apple.com/account/resources/authkeys/list) section of the Apple Developer Console. You can use this key to generate a secret key using the tool below, which is added to your Supabase project's Auth configuration. Make sure you safely store the `AuthKey_XXXXXXXXXX.p8` file. If you ever lose access to it, or make it public accidentally, revoke it from the Apple Developer Console and create a new one immediately. You will have to generate a new secret key using this file every 6 months, so make sure you schedule a recurring meeting in your calendar! 7. Finally, add the information you configured above to the [Apple provider configuration in the Supabase dashboard](https://supabase.com/dashboard/project/_/auth/providers). +You can also configure the Apple auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure Apple auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_apple_enabled": true, + "external_apple_client_id": "your-services-id", + "external_apple_secret": "your-generated-secret-key" + }' +``` + Use this tool to generate a new Apple client secret. No keys leave your browser! Be aware that this tool does not currently work in Safari, so use Firefox or a Chrome-based browser instead. diff --git a/apps/docs/content/guides/auth/social-login/auth-azure.mdx b/apps/docs/content/guides/auth/social-login/auth-azure.mdx index 1b31c75b679a3..1057da8f83100 100644 --- a/apps/docs/content/guides/auth/social-login/auth-azure.mdx +++ b/apps/docs/content/guides/auth/social-login/auth-azure.mdx @@ -44,6 +44,25 @@ Setting up OAuth with Azure consists of four broad steps: ![Obtain the client secret](/docs/img/guides/auth-azure/azure-client-secret.png) +You can also configure the Azure auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure Azure auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_azure_enabled": true, + "external_azure_client_id": "your-azure-client-id", + "external_azure_secret": "your-azure-client-secret", + "external_azure_url": "your-azure-url" + }' +``` + ## Guarding against unverified email domains Microsoft Entra ID can send out unverified email domains in certain cases. This may open up your project to a vulnerability where a malicious user can impersonate already existing accounts on your project. diff --git a/apps/docs/content/guides/auth/social-login/auth-discord.mdx b/apps/docs/content/guides/auth/social-login/auth-discord.mdx index 64ca269b7c463..18992be42c094 100644 --- a/apps/docs/content/guides/auth/social-login/auth-discord.mdx +++ b/apps/docs/content/guides/auth/social-login/auth-discord.mdx @@ -43,6 +43,24 @@ Setting up Discord logins for your application consists of 3 parts: <$Partial path="social_provider_settings_supabase.mdx" variables={{ "provider": "Discord" }} /> +You can also configure the Discord auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure Discord auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_discord_enabled": true, + "external_discord_client_id": "your-discord-client-id", + "external_discord_secret": "your-discord-client-secret" + }' +``` + ## Add login code to your client app +You can also configure the Facebook auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure Facebook auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_facebook_enabled": true, + "external_facebook_client_id": "your-facebook-app-id", + "external_facebook_secret": "your-facebook-app-secret" + }' +``` + ## Add login code to your client app +You can also configure the GitHub auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure GitHub auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_github_enabled": true, + "external_github_client_id": "your-github-client-id", + "external_github_secret": "your-github-client-secret" + }' +``` + ## Add login code to your client app In local development, you can add the client ID and secret to your `config.toml` file. diff --git a/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx b/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx index 4d1c83644930a..c01d491f023b2 100644 --- a/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx +++ b/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx @@ -46,6 +46,24 @@ Ensure that the appropriate scopes have been added under OAuth 2.0 Scopes at the <$Partial path="social_provider_settings_supabase.mdx" variables={{ "provider": "LinkedIn (OIDC)" }} /> +You can also configure the LinkedIn (OIDC) auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure LinkedIn (OIDC) auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_linkedin_oidc_enabled": true, + "external_linkedin_oidc_client_id": "your-linkedin-client-id", + "external_linkedin_oidc_secret": "your-linkedin-client-secret" + }' +``` + ## Add login code to your client app +You can also configure the Slack (OIDC) auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure Slack (OIDC) auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_slack_oidc_enabled": true, + "external_slack_oidc_client_id": "your-slack-client-id", + "external_slack_oidc_secret": "your-slack-client-secret" + }' +``` + ## Add login code to your client app +You can also configure the Spotify auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure Spotify auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_spotify_enabled": true, + "external_spotify_client_id": "your-spotify-client-id", + "external_spotify_secret": "your-spotify-client-secret" + }' +``` + ## Add login code to your client app The following outlines the steps to sign in using Spotify with Supabase Auth. diff --git a/apps/docs/content/guides/auth/social-login/auth-twitter.mdx b/apps/docs/content/guides/auth/social-login/auth-twitter.mdx index 8c181621f0bcc..f1ed101fbc1fd 100644 --- a/apps/docs/content/guides/auth/social-login/auth-twitter.mdx +++ b/apps/docs/content/guides/auth/social-login/auth-twitter.mdx @@ -50,6 +50,24 @@ Setting up Twitter logins for your application consists of 3 parts: <$Partial path="social_provider_settings_supabase.mdx" variables={{ "provider": "Twitter" }} /> +You can also configure the Twitter auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure Twitter auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_twitter_enabled": true, + "external_twitter_client_id": "your-twitter-api-key", + "external_twitter_secret": "your-twitter-api-secret-key" + }' +``` + ## Add login code to your client app +You can also configure the Zoom auth provider using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Configure Zoom auth provider +curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "external_zoom_enabled": true, + "external_zoom_client_id": "your-zoom-client-id", + "external_zoom_secret": "your-zoom-client-secret" + }' +``` + ## Add login code to your client app +### Using the Management API + +You can also manage secrets programmatically using the Management API: + +```bash +# First, get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Create a secret +curl -X POST "https://api.supabase.com/v1/projects/$PROJECT_REF/secrets" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '[{ + "name": "MY_SECRET_NAME", + "value": "my-secret-value" + }]' + +# List all secrets +curl -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + "https://api.supabase.com/v1/projects/$PROJECT_REF/secrets" + +# Delete a secret +curl -X DELETE "https://api.supabase.com/v1/projects/$PROJECT_REF/secrets" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '["MY_SECRET_NAME"]' +``` + ### Using the CLI Let's create a `.env` to help us deploy our secrets to production. In this case we'll just use the same as our local secrets: diff --git a/apps/docs/content/guides/getting-started/features.mdx b/apps/docs/content/guides/getting-started/features.mdx index 72e0269556e4a..b1993b861a7cb 100644 --- a/apps/docs/content/guides/getting-started/features.mdx +++ b/apps/docs/content/guides/getting-started/features.mdx @@ -195,53 +195,56 @@ Features in Beta are tested by an external penetration tester for security issue In addition to the Beta requirements, features in GA are covered by the [uptime SLA](https://supabase.com/sla). -| Product | Feature | Stage | Available on self-hosted | -| -------------- | -------------------------- | --------------- | ------------------------------------------- | -| Database | Postgres | `GA` | ✅ | -| Database | Vector Database | `GA` | ✅ | -| Database | Auto-generated Rest API | `GA` | ✅ | -| Database | Auto-generated GraphQL API | `GA` | ✅ | -| Database | Webhooks | `beta` | ✅ | -| Database | Vault | `public alpha` | ✅ | -| Platform | | `GA` | ✅ | -| Platform | Point-in-Time Recovery | `GA` | 🚧 [wal-g](https://github.com/wal-g/wal-g) | -| Platform | Custom Domains | `GA` | N/A | -| Platform | Network Restrictions | `beta` | N/A | -| Platform | SSL enforcement | `GA` | N/A | -| Platform | Branching | `beta` | N/A | -| Platform | Terraform Provider | `public alpha` | N/A | -| Platform | Read Replicas | `private alpha` | N/A | -| Platform | Log Drains | `public alpha` | ✅ | -| Studio | | `GA` | ✅ | -| Studio | SSO | `GA` | ✅ | -| Realtime | Postgres Changes | `GA` | ✅ | -| Realtime | Broadcast | `GA` | ✅ | -| Realtime | Presence | `GA` | ✅ | -| Realtime | Broadcast Authorization | `public beta` | ✅ | -| Realtime | Presence Authorization | `public beta` | ✅ | -| Storage | | `GA` | ✅ | -| Storage | CDN | `GA` | 🚧 [Cloudflare](https://www.cloudflare.com) | -| Storage | Smart CDN | `GA` | 🚧 [Cloudflare](https://www.cloudflare.com) | -| Storage | Image Transformations | `GA` | ✅ | -| Storage | Resumable Uploads | `GA` | ✅ | -| Storage | S3 compatibility | `public alpha` | ✅ | -| Edge Functions | | `beta` | ✅ | -| Edge Functions | Regional Invocations | `beta` | ✅ | -| Edge Functions | NPM compatibility | `beta` | ✅ | -| Auth | | `GA` | ✅ | -| Auth | Email login | `GA` | ✅ | -| Auth | Social login | `GA` | ✅ | -| Auth | Phone login | `GA` | ✅ | -| Auth | Passwordless login | `GA` | ✅ | -| Auth | SSO with SAML | `GA` | ✅ | -| Auth | Authorization via RLS | `GA` | ✅ | -| Auth | CAPTCHA protection | `GA` | ✅ | -| Auth | Server-side Auth | `beta` | ✅ | -| CLI | | `GA` | ✅ Works with self-hosted | -| Management API | | `GA` | N/A | -| Client Library | JavaScript | `GA` | N/A | -| Client Library | Flutter | `beta` | N/A | -| Client Library | Swift | `beta` | N/A | +| Product | Feature | Stage | Available on self-hosted | +| -------------- | -------------------------- | -------------- | ------------------------------------------- | +| Database | Postgres | `GA` | ✅ | +| Database | Vector Database | `GA` | ✅ | +| Database | Auto-generated Rest API | `GA` | ✅ | +| Database | Auto-generated GraphQL API | `GA` | ✅ | +| Database | Webhooks | `beta` | ✅ | +| Database | Vault | `public alpha` | ✅ | +| Platform | | `GA` | ✅ | +| Platform | Point-in-Time Recovery | `GA` | 🚧 [wal-g](https://github.com/wal-g/wal-g) | +| Platform | Custom Domains | `GA` | N/A | +| Platform | Network Restrictions | `GA` | N/A | +| Platform | SSL enforcement | `GA` | N/A | +| Platform | Branching | `beta` | N/A | +| Platform | Terraform Provider | `public alpha` | N/A | +| Platform | Read Replicas | `GA` | N/A | +| Platform | Log Drains | `public alpha` | ✅ | +| Studio | | `GA` | ✅ | +| Studio | SSO | `GA` | ✅ | +| Realtime | Postgres Changes | `GA` | ✅ | +| Realtime | Broadcast | `GA` | ✅ | +| Realtime | Presence | `GA` | ✅ | +| Realtime | Broadcast Authorization | `public beta` | ✅ | +| Realtime | Presence Authorization | `public beta` | ✅ | +| Realtime | Broadcast from Database | `public beta` | ✅ | +| Storage | | `GA` | ✅ | +| Storage | CDN | `GA` | 🚧 [Cloudflare](https://www.cloudflare.com) | +| Storage | Smart CDN | `GA` | 🚧 [Cloudflare](https://www.cloudflare.com) | +| Storage | Image Transformations | `GA` | ✅ | +| Storage | Resumable Uploads | `GA` | ✅ | +| Storage | S3 compatibility | `GA` | ✅ | +| Edge Functions | | `GA` | ✅ | +| Edge Functions | Regional Invocations | `GA` | ✅ | +| Edge Functions | NPM compatibility | `GA` | ✅ | +| Auth | | `GA` | ✅ | +| Auth | Email login | `GA` | ✅ | +| Auth | Social login | `GA` | ✅ | +| Auth | Phone login | `GA` | ✅ | +| Auth | Passwordless login | `GA` | ✅ | +| Auth | SSO with SAML | `GA` | ✅ | +| Auth | Authorization via RLS | `GA` | ✅ | +| Auth | CAPTCHA protection | `GA` | ✅ | +| Auth | Server-side Auth | `beta` | ✅ | +| Auth | Third-Party Auth | `GA` | ✅ | +| CLI | | `GA` | ✅ Works with self-hosted | +| Management API | | `GA` | N/A | +| Client Library | JavaScript | `GA` | N/A | +| Client Library | Flutter | `GA` | N/A | +| Client Library | Swift | `GA` | N/A | +| Client Library | Python | `beta` | N/A | - ✅ = Fully Available - 🚧 = Available, but requires external tools or configuration diff --git a/apps/docs/content/guides/platform/access-control.mdx b/apps/docs/content/guides/platform/access-control.mdx index 444a153b35b56..37b7b85dd52a4 100644 --- a/apps/docs/content/guides/platform/access-control.mdx +++ b/apps/docs/content/guides/platform/access-control.mdx @@ -32,6 +32,20 @@ This is a security measure to prevent accidental invites to accounts not managed +### Viewing organization members using the Management API + +You can also view organization members using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export ORG_ID="your-organization-id" + +# List organization members +curl "https://api.supabase.com/v1/organizations/$ORG_ID/members" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" +``` + ### Transferring ownership of an organization Each Supabase organization must have at least one owner. If your organization has other owners then you can relinquish ownership and leave the organization by clicking **Leave team** in your organization's team [settings](/dashboard/org/_/team). diff --git a/apps/docs/content/guides/platform/backups.mdx b/apps/docs/content/guides/platform/backups.mdx index aadb728ba21f1..64efb201ba51b 100644 --- a/apps/docs/content/guides/platform/backups.mdx +++ b/apps/docs/content/guides/platform/backups.mdx @@ -71,6 +71,26 @@ The Postgres utility [pg_dumpall](https://www.postgresql.org/docs/current/app-pg You can access daily backups in the [Scheduled backups](https://supabase.com/dashboard/project/_/database/backups/scheduled) settings in the Dashboard. Pro Plan projects can access the last 7 days' worth of daily backups. Team Plan projects can access the last 14 days' worth of daily backups, while Enterprise Plan projects can access up to 30 days' worth of daily backups. Users can restore their project to any one of the backups. If you wish to generate a logical backup on your own, you can do so through the [Supabase CLI](/docs/reference/cli/supabase-db-dump). +You can also manage backups programmatically using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# List all available backups +curl -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + "https://api.supabase.com/v1/projects/$PROJECT_REF/database/backups" + +# Restore from a PITR (not logical) backup (replace ISO timestamp with desired restore point) +curl -X POST "https://api.supabase.com/v1/projects/$PROJECT_REF/database/backups/restore-pitr" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "recovery_time_target_unix": "1735689600" + }' +``` + #### Backup process for large databases Databases larger than 15GB[^1], if they're on a recent build[^2] of the Supabase platform, get automatically transitioned[^3] to use daily physical backups. Physical backups are a more performant backup mechanism that lowers the overhead and impact on the database being backed up, and also avoids holding locks on objects in your database for a long period of time. While restores are unaffected, the backups created using this method cannot be downloaded from the Backups section of the dashboard. diff --git a/apps/docs/content/guides/platform/ipv4-address.mdx b/apps/docs/content/guides/platform/ipv4-address.mdx index b8510e7ba3dbe..790ea5221960a 100644 --- a/apps/docs/content/guides/platform/ipv4-address.mdx +++ b/apps/docs/content/guides/platform/ipv4-address.mdx @@ -28,6 +28,30 @@ IPv4 addresses are guaranteed to be static for ingress traffic. If your database You can enable the IPv4 add-on in your project's [add-ons settings](/dashboard/project/_/settings/addons). +You can also manage the IPv4 add-on using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Get current IPv4 add-on status +curl -X GET "https://api.supabase.com/v1/projects/$PROJECT_REF/billing/addons" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" + +# Enable IPv4 add-on +curl -X POST "https://api.supabase.com/v1/projects/$PROJECT_REF/addons" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "addon_type": "ipv4" + }' + +# Disable IPv4 add-on +curl -X DELETE "https://api.supabase.com/v1/projects/$PROJECT_REF/billing/addons/ipv4" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" +``` + Note that direct database connections can experience a short amount of downtime when toggling the add-on due to DNS reconfiguration and propagation. Generally, this should be less than a minute. diff --git a/apps/docs/content/guides/platform/network-restrictions.mdx b/apps/docs/content/guides/platform/network-restrictions.mdx index aa80fbbc638f6..95c842244602e 100644 --- a/apps/docs/content/guides/platform/network-restrictions.mdx +++ b/apps/docs/content/guides/platform/network-restrictions.mdx @@ -18,6 +18,30 @@ If direct connections to your database [resolve to a IPv6 address](https://supab Network restrictions can be configured in the [Database Settings](https://supabase.com/dashboard/project/_/settings/database) page. Ensure that you have [Owner or Admin permissions](/docs/guides/platform/access-control#manage-team-members) for the project that you are enabling network restrictions. +## To get started via the Management API: + +You can also manage network restrictions using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Get current network restrictions +curl -X GET "https://api.supabase.com/v1/projects/$PROJECT_REF/network-restrictions" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" + +# Update network restrictions +curl -X POST "https://api.supabase.com/v1/projects/$PROJECT_REF/network-restrictions/apply" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "db_allowed_cidrs": [ + "192.168.0.1/24", + ] + }' +``` + ## To get started via the CLI: 1. [Install](/docs/guides/cli) the Supabase CLI 1.22.0+. diff --git a/apps/docs/content/guides/platform/read-replicas.mdx b/apps/docs/content/guides/platform/read-replicas.mdx index 358b348332f19..4d6b836fbf2f4 100644 --- a/apps/docs/content/guides/platform/read-replicas.mdx +++ b/apps/docs/content/guides/platform/read-replicas.mdx @@ -51,6 +51,30 @@ Projects must meet these requirements to use Read Replicas: To add a Read Replica, go to the [Infrastructure Settings page](/dashboard/project/_/settings/infrastructure) in your dashboard. +You can also manage Read Replicas using the Management API (beta functionality): + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Create a new Read Replica +curl -X POST "https://api.supabase.com/v1/projects/$PROJECT_REF/read-replicas/setup" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "region": "us-east-1" + }' + +# Delete a Read Replica +curl -X POST "https://api.supabase.com/v1/projects/$PROJECT_REF/read-replicas/remove" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "database_identifier": "abcdefghijklmnopqrst" + }' +``` + Projects on an XL compute add-on or larger can create up to five Read Replicas. Projects on compute add-ons smaller than XL can create up to two Read Replicas. All Read Replicas inherit the compute size of their Primary database. ### Deploying a Read Replica diff --git a/apps/docs/content/guides/platform/ssl-enforcement.mdx b/apps/docs/content/guides/platform/ssl-enforcement.mdx index d0b4c82efa6f1..5f9b5d62167c4 100644 --- a/apps/docs/content/guides/platform/ssl-enforcement.mdx +++ b/apps/docs/content/guides/platform/ssl-enforcement.mdx @@ -18,6 +18,40 @@ Projects need to be at least on Postgres 13.3.0 to enable SSL enforcement. You c SSL enforcement can be configured via the "Enforce SSL on incoming connections" setting under the SSL Configuration section in [Database Settings page](https://supabase.com/dashboard/project/_/settings/database) of the dashboard. +## Manage SSL enforcement via the Management API + +You can also manage SSL enforcement using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Get current SSL enforcement status +curl -X GET "https://api.supabase.com/v1/projects/$PROJECT_REF/ssl-enforceemnt" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" + +# Enable SSL enforcement +curl -X PUT "https://api.supabase.com/v1/projects/$PROJECT_REF/ssl-enforcement" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "requestedConfig": { + "database": true + } + }' + +# Disable SSL enforcement +curl -X PUT "https://api.supabase.com/v1/projects/$PROJECT_REF/ssl-enforcement" \ + -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "requestedConfig": { + "database": false + } + }' +``` + ## Manage SSL enforcement via the CLI To get started: diff --git a/apps/docs/content/guides/telemetry/metrics.mdx b/apps/docs/content/guides/telemetry/metrics.mdx index eac18f6d9ad09..267e4692747de 100644 --- a/apps/docs/content/guides/telemetry/metrics.mdx +++ b/apps/docs/content/guides/telemetry/metrics.mdx @@ -29,6 +29,18 @@ Access to the endpoint is secured via HTTP Basic Auth: - username: `service_role` - password: the service role JWT from the [Supabase dashboard](https://supabase.com/dashboard/project/_/settings/api-keys) +You can also retrieve your service role key programmatically using the Management API: + +```bash +# Get your access token from https://supabase.com/dashboard/account/tokens +export SUPABASE_ACCESS_TOKEN="your-access-token" +export PROJECT_REF="your-project-ref" + +# Get project API keys including service_role key +curl -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ + "https://api.supabase.com/v1/projects/$PROJECT_REF/api-keys?reveal=true" +``` + ```shell diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobScheduleSection.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobScheduleSection.tsx index 813d94eecf970..09ad555434f45 100644 --- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobScheduleSection.tsx +++ b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobScheduleSection.tsx @@ -6,6 +6,7 @@ import { useDebounce } from 'use-debounce' import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext' import { useSqlCronGenerateMutation } from 'data/ai/sql-cron-mutation' import { useCronTimezoneQuery } from 'data/database-cron-jobs/database-cron-timezone-query' +import { useFlag } from 'hooks/ui/useFlag' import { Accordion_Shadcn_, AccordionContent_Shadcn_, @@ -35,6 +36,7 @@ interface CronJobScheduleSectionProps { export const CronJobScheduleSection = ({ form, supportsSeconds }: CronJobScheduleSectionProps) => { const { project } = useProjectContext() + const useBedrockAssistant = useFlag('useBedrockAssistant') const [inputValue, setInputValue] = useState('') const [debouncedValue] = useDebounce(inputValue, 750) const [useNaturalLanguage, setUseNaturalLanguage] = useState(false) @@ -65,7 +67,7 @@ export const CronJobScheduleSection = ({ form, supportsSeconds }: CronJobSchedul useEffect(() => { if (useNaturalLanguage && debouncedValue) { - generateCronSyntax({ prompt: debouncedValue }) + generateCronSyntax({ prompt: debouncedValue, useBedrockAssistant }) } // eslint-disable-next-line react-hooks/exhaustive-deps }, [debouncedValue, useNaturalLanguage]) diff --git a/apps/studio/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector.tsx b/apps/studio/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector.tsx index b471fce693ad0..7d890a0fb0997 100644 --- a/apps/studio/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector.tsx +++ b/apps/studio/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector.tsx @@ -15,6 +15,21 @@ interface AIOptInLevelSelectorProps { layout?: 'horizontal' | 'vertical' | 'flex-row-reverse' } +const AI_OPT_IN_LEVELS_OLD = [ + { + value: 'disabled', + title: 'Disabled', + description: + 'You do not consent to sharing any database information with Supabase AI and understand that responses will be generic and not tailored to your database', + }, + { + value: 'schema', + title: 'Send anonymous metadata', + description: + 'You consent to sending anonymous data to Supabase AI, which can improve the answers it shows you.', + }, +] + const AI_OPT_IN_LEVELS = [ { value: 'disabled', @@ -49,30 +64,37 @@ export const AIOptInLevelSelector = ({ layout = 'vertical', }: AIOptInLevelSelectorProps) => { const newOrgAiOptIn = useFlag('newOrgAiOptIn') + const useBedrockAssistant = useFlag('useBedrockAssistant') + + const optInLevels = useBedrockAssistant ? AI_OPT_IN_LEVELS : AI_OPT_IN_LEVELS_OLD return ( - {!newOrgAiOptIn && ( - + {useBedrockAssistant && ( + <> + {!newOrgAiOptIn && ( + + )} +

+ Supabase AI can provide more relevant answers if you choose to share different + levels of data. This feature is powered by Amazon Bedrock which does not store or + log your prompts and completions, nor does it use them to train AWS models or + distribute them to third parties. This is an organization-wide setting, so please + select the level of data you are comfortable sharing. +

+ )} -

- Supabase AI can provide more relevant answers if you choose to share different levels of - data. This feature is powered by Amazon Bedrock which does not store or log your prompts - and completions, nor does it use them to train AWS models or distribute them to third - parties. This is an organization-wide setting, so please select the level of data you - are comfortable sharing. -

} - layout={layout} >
- {AI_OPT_IN_LEVELS.map((item) => ( + {optInLevels.map((item) => (
{ + const useBedrockAssistant = useFlag('useBedrockAssistant') + return ( @@ -26,37 +29,81 @@ export const OptInToOpenAIToggle = () => { padding="small" className="flex flex-col gap-y-4 text-sm text-foreground-light" > -

- Supabase AI utilizes Amazon Bedrock ("Bedrock"), a service designed with a strong focus - on data privacy and security. -

+ {useBedrockAssistant ? ( + <> +

+ Supabase AI utilizes Amazon Bedrock ("Bedrock"), a service designed with a strong + focus on data privacy and security. +

+ +

+ Amazon Bedrock does not store or log your prompts and completions. This data is not + used to train any AWS models and is not distributed to third parties or model + providers. Model providers do not have access to Amazon Bedrock logs or customer + prompts and completions. +

+ +

+ By default, no information is shared with Bedrock unless you explicitly provide + consent. With your permission, Supabase may share customer-generated prompts, + database schema, database data, and project logs with Bedrock. This information is + used solely to generate responses to your queries and is not retained by Bedrock or + used to train their foundation models. +

+ +

+ If you are a HIPAA Covered Entity, please note that Bedrock is HIPAA eligible, and + Supabase has a Business Associate Agreement in place covering this use. +

+ +

+ For more detailed information about how we collect and use your data, see our{' '} + Privacy Policy. You can + choose which types of information you consent to share by selecting from the options + in the AI settings. +

+ + ) : ( + <> +

+ Supabase AI is a chatbot support tool powered by OpenAI. Supabase will share the + query you submit and information about the databases you manage through Supabase + with OpenAI, L.L.C. and its affiliates in order to provide the Supabase AI tool. +

+ +

+ OpenAI will only access information about the structure of your databases, such as + table names, column and row headings. OpenAI will not access the contents of the + database itself. +

-

- Amazon Bedrock does not store or log your prompts and completions. This data is not used - to train any AWS models and is not distributed to third parties or model providers. - Model providers do not have access to Amazon Bedrock logs or customer prompts and - completions. -

+

+ OpenAI uses this information to generate responses to your query, and does not + retain or use the information to train its algorithms or otherwise improve its + products and services. +

-

- By default, no information is shared with Bedrock unless you explicitly provide consent. - With your permission, Supabase may share customer-generated prompts, database schema, - database data, and project logs with Bedrock. This information is used solely to - generate responses to your queries and is not retained by Bedrock or used to train their - foundation models. -

+

+ If you have your own individual account on Supabase, we will use any personal + information collected through [Supabase AI] to provide you with the [Supabase AI] + tool. If you are in the UK, EEA or Switzerland, the processing of this personal + information is necessary for the performance of a contract between you and us. +

-

- If you are a HIPAA Covered Entity, please note that Bedrock is HIPAA eligible, and - Supabase has a Business Associate Agreement in place covering this use. -

+

+ Supabase collects information about the queries you submit through Supabase AI and + the responses you receive to assess the performance of the Supabase AI tool and + improve our services. If you are in the UK, EEA or Switzerland, the processing is + necessary for our legitimate interests, namely informing our product development and + improvement. +

-

- For more detailed information about how we collect and use your data, see our{' '} - Privacy Policy. You can - choose which types of information you consent to share by selecting from the options in - the AI settings. -

+

+ For more information about how we use personal information, please see our{' '} + privacy policy. +

+ + )}
diff --git a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx index 8a4cc98cef78c..87c29b77990b7 100644 --- a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx +++ b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx @@ -29,8 +29,10 @@ import { FormField_Shadcn_, FormMessage_Shadcn_, Input_Shadcn_, + Switch, } from 'ui' import { Admonition } from 'ui-patterns' +import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' const formId = 'realtime-configuration-form' @@ -70,16 +72,14 @@ export const RealtimeSettings = () => { // max_channels_per_client: z.coerce.number().min(1).max(10000), // max_joins_per_second: z.coerce.number().min(1).max(5000), - // [Filipe] This field is temporarily hidden from the UI - // allow_public: z.boolean(), + allow_public: z.boolean(), }) const form = useForm>({ resolver: zodResolver(FormSchema), defaultValues: { ...REALTIME_DEFAULT_CONFIG, - // [Filipe] This field is temporarily hidden from the UI - // allow_public: !REALTIME_DEFAULT_CONFIG.private_only, + allow_public: !REALTIME_DEFAULT_CONFIG.private_only, }, }) @@ -87,8 +87,7 @@ export const RealtimeSettings = () => { if (!projectRef) return console.error('Project ref is required') updateRealtimeConfig({ ref: projectRef, - // [Filipe] This field is temporarily hidden from the UI - // private_only: !data.allow_public, + private_only: !data.allow_public, connection_pool: data.connection_pool, max_concurrent_users: data.max_concurrent_users, }) @@ -97,10 +96,9 @@ export const RealtimeSettings = () => { useEffect(() => { // [Joshen] Temp typed with any - API typing marks all the properties as nullable, // but checked with Filipe that they're not supposed to - // [Filipe] This field is temporarily hidden from the UI - // if (data) form.reset({ ...data, allow_public: !data.private_only } as any) - - if (data) form.reset({ ...data } as any) + if (isSuccess) { + form.reset({ ...data, allow_public: !data.private_only } as any) + } }, [isSuccess]) return ( @@ -111,10 +109,7 @@ export const RealtimeSettings = () => { ) : ( - {/* - [Filipe] We're hidding this field until we implement a 'kill all sockets` on change to be triggered in realtime server - */} - {/* + { )} /> - */} + { const { ref } = useParams() const organization = useSelectedOrganization() + const useBedrockAssistant = useFlag('useBedrockAssistant') const snapV2 = useSqlEditorV2StateSnapshot() const tabsSnap = useTabsStateSnapshot() @@ -64,12 +66,12 @@ const RenameQueryModal = ({ const generateTitle = async () => { if ('content' in snippet && isSQLSnippet) { - titleSql({ sql: snippet.content.sql }) + titleSql({ sql: snippet.content.sql, useBedrockAssistant }) } else { try { const { content } = await getContentById({ projectRef: ref, id: snippet.id }) if ('sql' in content) { - titleSql({ sql: content.sql }) + titleSql({ sql: content.sql, useBedrockAssistant }) } } catch (error) { toast.error('Unable to generate title based on query contents') diff --git a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx index f2ee2ea6d88c4..c8f472df44651 100644 --- a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx +++ b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx @@ -23,6 +23,7 @@ import { useOrgAiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi' import { useSchemasForAi } from 'hooks/misc/useSchemasForAi' import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization' import { useSelectedProject } from 'hooks/misc/useSelectedProject' +import { useFlag } from 'hooks/ui/useFlag' import { BASE_PATH } from 'lib/constants' import { formatSql } from 'lib/formatSql' import { detectOS, uuidv4 } from 'lib/helpers' @@ -80,6 +81,7 @@ export const SQLEditor = () => { const os = detectOS() const router = useRouter() const { ref, id: urlId } = useParams() + const useBedrockAssistant = useFlag('useBedrockAssistant') const { profile } = useProfile() const project = useSelectedProject() @@ -207,7 +209,7 @@ export const SQLEditor = () => { const setAiTitle = useCallback( async (id: string, sql: string) => { try { - const { title: name } = await generateSqlTitle({ sql }) + const { title: name } = await generateSqlTitle({ sql, useBedrockAssistant }) snapV2.renameSnippet({ id, name }) const tabId = createTabId('sql', { id }) tabs.updateTab(tabId, { label: name }) @@ -215,7 +217,7 @@ export const SQLEditor = () => { // [Joshen] No error handler required as this happens in the background and not necessary to ping the user } }, - [generateSqlTitle, snapV2] + [generateSqlTitle, useBedrockAssistant, snapV2] ) const prettifyQuery = useCallback(async () => { @@ -459,7 +461,9 @@ export const SQLEditor = () => { completion, isLoading: isCompletionLoading, } = useCompletion({ - api: `${BASE_PATH}/api/ai/sql/complete`, + api: useBedrockAssistant + ? `${BASE_PATH}/api/ai/sql/complete-v2` + : `${BASE_PATH}/api/ai/sql/complete`, body: { projectRef: project?.ref, connectionString: project?.connectionString, diff --git a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx index d1417fd14ad33..640b511c37cb7 100644 --- a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx +++ b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx @@ -90,6 +90,7 @@ export const AIAssistant = ({ className }: AIAssistantProps) => { const newOrgAiOptIn = useFlag('newOrgAiOptIn') const disablePrompts = useFlag('disableAssistantPrompts') + const useBedrockAssistant = useFlag('useBedrockAssistant') const { snippets } = useSqlEditorV2StateSnapshot() const snap = useAiAssistantStateSnapshot() @@ -105,7 +106,8 @@ export const AIAssistant = ({ className }: AIAssistantProps) => { const showMetadataWarning = IS_PLATFORM && !!selectedOrganization && - (aiOptInLevel === 'disabled' || aiOptInLevel === 'schema') + ((!useBedrockAssistant && aiOptInLevel === 'disabled') || + (useBedrockAssistant && (aiOptInLevel === 'disabled' || aiOptInLevel === 'schema'))) // Add a ref to store the last user message const lastUserMessageRef = useRef(null) @@ -157,7 +159,9 @@ export const AIAssistant = ({ className }: AIAssistantProps) => { setMessages, } = useChat({ id: snap.activeChatId, - api: `${BASE_PATH}/api/ai/sql/generate-v3`, + api: useBedrockAssistant + ? `${BASE_PATH}/api/ai/sql/generate-v4` + : `${BASE_PATH}/api/ai/sql/generate-v3`, maxSteps: 5, // [Alaister] typecast is needed here because valtio returns readonly arrays // and useChat expects a mutable array @@ -175,6 +179,9 @@ export const AIAssistant = ({ className }: AIAssistantProps) => { connectionString: project?.connectionString, schema: currentSchema, table: currentTable?.name, + includeSchemaMetadata: !useBedrockAssistant + ? !IS_PLATFORM || aiOptInLevel !== 'disabled' + : undefined, }) }, fetch: async (input: RequestInfo | URL, init?: RequestInit) => { diff --git a/apps/studio/components/ui/AIAssistantPanel/AIOptInModal.tsx b/apps/studio/components/ui/AIAssistantPanel/AIOptInModal.tsx index 1766e91705f22..9a12a7c8162b1 100644 --- a/apps/studio/components/ui/AIAssistantPanel/AIOptInModal.tsx +++ b/apps/studio/components/ui/AIAssistantPanel/AIOptInModal.tsx @@ -47,14 +47,16 @@ export const AIOptInModal = ({ visible, onCancel }: AIOptInModalProps) => { Update Supabase Assistant Opt-in Level + - + + - +