mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem The CLI reads `supabase/config.jsonc` (and `config.json`) since v3.1.0, but every docs page still shows `config.toml` only. There's also no page explaining the formats, how to switch, the `$schema` / `#:schema` declaration, or editor setup, and no reference pages for the new `supabase config convert` and `supabase config validate` commands. Linear: CLI-2871 ## Solution - **Dual-format examples from one source.** A new directive (`features/directives/ConfigFormats.ts`) picks up any ```` ```toml ```` fence with `name=supabase/config.toml` and renders it as `supabase/config.toml` / `supabase/config.jsonc` tabs. The JSONC is generated at build time with `convertCliConfigTomlToJsonc` from `@supabase/config`, the same converter `supabase config convert` uses, so authors only write TOML and the JSONC matches what the CLI would produce (comments included). Inside `<$CodeTabs>` the JSONC is added as an extra tab. - **The format choice sticks.** `ConfigCodeTabs` keeps the selected format in `localStorage`, so choosing JSONC switches every config example on the page and on later pages. - **Config reference.** The `usage` examples on `/guides/local-development/cli/config` use the same tabs (they were highlighted as Python before), and the intro mentions `config.jsonc`. The `remotes.<branch_name>` example now uses `[remotes.staging]`, since `<branch_name>` isn't a valid TOML key. - **New guide, "Config file formats"** (`/guides/local-development/cli/config-formats`): which file wins, minimum CLI version, `convert` and `validate`, schema declaration and versioning, and editor setup (VS Code trusted domains, Even Better TOML, Tombi, SchemaStore). - **CLI reference.** Adds `supabase-config-convert` and `supabase-config-validate` to the CLI reference nav. `cli_v1_commands.yaml` is the generated v3.2.0 reference, identical to the release bot's update in #53463, so the two PRs don't conflict. - **Content.** About 60 existing config examples across the guides, including the Branching configuration page, are tagged `name=supabase/config.toml`. Branching reads `config.json` and `config.jsonc` as well, and the Branching configuration page now says so. Non-Supabase TOML (`pyproject.toml`, `bunfig.toml`) and the v2-era `[inbucket]` before/after snippet stay TOML-only. - **Format-neutral prose.** Sentences that described the config as `config.toml` now say "your config file", naming `supabase/config.toml` and `supabase/config.jsonc` once per page. TOML section syntax in prose (`max_frequency` under `[auth.email]`) is written as key paths (`auth.email.max_frequency`), which read the same in both formats. Headings that named `config.toml` keep their old anchors. Sentences about what `supabase init` creates still say `config.toml`. - **Markdown export for agents.** `internals/generate-guides-markdown.ts` runs the same transform, so the `.md` pages served to AI agents include the JSONC example after each TOML one. - A test converts every tagged example under `content/`, so a broken TOML example fails tests instead of the build. New dependencies for `apps/docs`: `@supabase/config` (^1.8.0) and `effect` (the same `effect` version Studio pins). `config convert` and `config validate` ship in CLI v3.2.0, which is now stable. ## Review instructions 1. Open `/docs/guides/local-development/seeding-your-database` on the preview. Switch an example to `supabase/config.jsonc` and check the other examples on the page switch too. 2. Open `/docs/guides/local-development/cli/config` and check the usage examples open on JSONC. 3. Read `/docs/guides/local-development/cli/config-formats`. 4. Open `/docs/reference/cli/supabase-config-convert` and `/docs/reference/cli/supabase-config-validate`. ## Self-review Ran the `review-the-docs` local self-review (content, pipeline, and component checks) over the 54 changed pages. - No blockers. Fixed the nits it found: leftover TOML section syntax in prose (diff engines, declarative schemas, Branching, the common settings table on Local and hosted projects), a few long or ungrammatical sentences, and the conversion follow-up steps on Config file formats, now a list. - Links, custom anchors, nav wiring, and frontmatter check out. - The `.md` export on the preview shows each TOML example followed by its JSONC version. - `test-the-docs` deferred: the changed fences are config snippets, and `ConfigFormats.test.ts` already converts every tagged example. No procedural steps changed apart from the `config convert` and `config validate` commands on the new page. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
130 lines
7.4 KiB
Plaintext
130 lines
7.4 KiB
Plaintext
---
|
|
title: 'Test auth flows'
|
|
description: 'Test email and phone sign-in without hitting email and SMS limits'
|
|
---
|
|
|
|
Test sign-up, sign-in, and password recovery as often as you need without waiting on email or SMS limits. Develop against local Supabase to capture every email in Mailpit, and use test phone numbers to sign in with a fixed code.
|
|
|
|
The local development steps need the Supabase CLI and a project initialized with `supabase init`. To set them up, see [Supabase CLI](/docs/guides/local-development/cli/getting-started).
|
|
|
|
## Test email flows locally
|
|
|
|
The Supabase CLI sends every email from local Auth to Mailpit, an email testing server that runs with your local stack. No email leaves your machine, so you can send to any address. Local Auth has no hourly email limit. For more information about Mailpit, see the [Mailpit repository on GitHub](https://github.com/axllent/mailpit).
|
|
|
|
1. In your project directory, run `supabase start` to start the local stack.
|
|
1. Run `supabase status` to get your local stack's connection details. Copy the following values from the output:
|
|
- **Project URL**: the local API URL, which is `http://127.0.0.1:54321` by default
|
|
- **Publishable**: the local publishable key, which starts with `sb_publishable_`
|
|
- **Mailpit**: the Mailpit URL, which is `http://127.0.0.1:54324` by default
|
|
1. Connect your app to the local stack. Your app's [Supabase client](/docs/reference/javascript/introduction) reads a project URL and a publishable key from environment variables, which usually hold your hosted project's values. Replace them with the **Project URL** and **Publishable** key you copied from `supabase status`:
|
|
|
|
```bash .env.local
|
|
NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
|
|
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=sb_publishable_...
|
|
```
|
|
|
|
Variable names depend on your framework. To test against your hosted project again, restore its project URL and publishable key.
|
|
|
|
1. In your app, request a magic link or a password recovery email.
|
|
1. In your browser, go to the **Mailpit** URL and open the email to get the link or code.
|
|
|
|
Local Auth limits how often it sends to the same address. By default, it sends one email per address per second. To change this, set `auth.email.max_frequency` in your config file (`supabase/config.toml` or `supabase/config.jsonc`).
|
|
|
|
Email confirmation is off by default in local development and on by default for hosted projects, so local sign-up doesn't send an email. To test the confirmation email locally, set `auth.email.enable_confirmations` to `true`, and then restart the local stack.
|
|
|
|
## Test email flows on a hosted project
|
|
|
|
Hosted projects send email through a built-in email service until you set up custom SMTP. The built-in service is for trying out Auth, and it has the following limits:
|
|
|
|
- It sends only to the email addresses of your organization's team members. Other addresses fail with the error code `email_address_not_authorized`.
|
|
- It sends <SharedData data="config">auth.rate_limits.email.inbuilt_smtp_per_hour.value</SharedData> emails per hour across the whole project while **Confirm email** is on. When the project reaches the limit, Auth returns a `429` error with the code `over_email_send_rate_limit` and the message `email rate limit exceeded`.
|
|
|
|
To send to any address and raise the limit, set up [custom SMTP](/docs/guides/auth/auth-smtp) or the [Send Email hook](/docs/guides/auth/auth-hooks/send-email-hook). You can then change the email limit in [**Authentication** > **Rate Limits**](/dashboard/project/_/auth/rate-limits). For more information about the limits, see [Rate limits](/docs/guides/auth/rate-limits).
|
|
|
|
<Admonition type="caution">
|
|
|
|
Turning off **Confirm email** lets anyone sign up with an email address they don't own, and Auth marks that address as confirmed. It also turns off the project's hourly email limit. If you turn it off while testing, turn it back on in [**Authentication** > **Sign In / Providers**](/dashboard/project/_/auth/providers) before you launch.
|
|
|
|
</Admonition>
|
|
|
|
## Test phone sign-in with test numbers
|
|
|
|
With a test phone number, you sign in with a fixed one-time password (OTP) that you choose. Auth doesn't send an SMS to a test number, and it accepts the fixed code as many times as you need.
|
|
|
|
Test numbers work for phone sign-up, sign-in, and phone number changes. They don't apply to [phone multi-factor authentication](/docs/guides/auth/auth-mfa/phone), which always sends a real SMS.
|
|
|
|
Before you add test numbers, enable the phone provider and configure an SMS provider. Auth requires an SMS provider even though it doesn't send anything to test numbers.
|
|
|
|
Write each phone number in international format, with the country code and without the `+` prefix or spaces. For example, write `+1 415 555 2671` as `14155552671`. Auth compares the number your app sends against this value, so a number without its country code doesn't match.
|
|
|
|
<Tabs scrollable size="small" type="underlined" defaultActiveId="dashboard" queryGroup="method">
|
|
<TabPanel id="dashboard" label="Dashboard">
|
|
|
|
1. Go to [**Authentication** > **Sign In / Providers**](/dashboard/project/_/auth/providers), and open **Phone**.
|
|
1. In **Test Phone Numbers and OTPs**, enter a comma-separated list of `<phone number>=<OTP>` pairs, such as `14155552671=123456`.
|
|
1. In **Test OTPs Valid Until**, choose when the test numbers stop working. The Dashboard requires this date.
|
|
1. Click **Save**.
|
|
|
|
</TabPanel>
|
|
<TabPanel id="local" label="Local development">
|
|
|
|
1. In your config file, turn on phone sign-up, enable an SMS provider, and add each test number and its code. These sections exist in the default file, so edit them in place:
|
|
|
|
```toml supabase/config.toml
|
|
[auth.sms]
|
|
enable_signup = true
|
|
|
|
[auth.sms.twilio]
|
|
enabled = true
|
|
account_sid = "placeholder"
|
|
message_service_sid = "placeholder"
|
|
auth_token = "placeholder"
|
|
|
|
[auth.sms.test_otp]
|
|
14155552671 = "123456"
|
|
```
|
|
|
|
Auth doesn't use the provider credentials for test numbers, so placeholder values work.
|
|
|
|
1. Restart the local stack:
|
|
|
|
```bash
|
|
supabase stop && supabase start
|
|
```
|
|
|
|
Local test numbers don't expire.
|
|
|
|
</TabPanel>
|
|
<TabPanel id="management-api" label="Management API">
|
|
|
|
Update the project's Auth configuration with the test numbers and the date they stop working. Replace `YYYY-MM-DDTHH:MM:SSZ` with that date in UTC:
|
|
|
|
```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"
|
|
|
|
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 '{
|
|
"sms_test_otp": "14155552671=123456",
|
|
"sms_test_otp_valid_until": "YYYY-MM-DDTHH:MM:SSZ"
|
|
}'
|
|
```
|
|
|
|
</TabPanel>
|
|
</Tabs>
|
|
|
|
Test numbers don't count toward the project's hourly SMS limit. Auth makes you wait between codes for the same number. The wait defaults to 5 seconds. Locally, change it with `auth.sms.max_frequency`.
|
|
|
|
<Admonition type="danger">
|
|
|
|
Anyone who knows a test number and its code can sign in as the user with that number. Remove test numbers before you launch, or set **Test OTPs Valid Until** to a date before launch.
|
|
|
|
`supabase config push` copies `auth.sms.test_otp` from your config file to your hosted project and sets the test numbers to expire after 10 years. Remove the section before you push to a production project.
|
|
|
|
</Admonition>
|
|
|
|
For the Auth settings to check before launch, see the [Production security checklist](/docs/guides/security/production-checklist#auth).
|