Files
supabase/apps/docs/content/guides/auth/third-party/custom-oidc.mdx
Colum Ferry 95cf9a78a7 docs(cli): show config examples in TOML and JSONC (#53449)
## 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)
2026-11-20 14:34:59 +00:00

110 lines
5.0 KiB
Plaintext

---
id: 'auth-third-party-custom-oidc'
title: 'Custom OIDC provider'
subtitle: 'Use any OIDC-compliant identity provider with your Supabase project'
---
Any identity provider that supports OpenID Connect (OIDC) can be used as a third-party authentication provider alongside Supabase Auth, or standalone, with your Supabase project. Use this guide for a provider that is not in the list of [supported providers](/docs/guides/auth/third-party/overview).
## Getting started
1. Check that your provider meets the [requirements](#requirements).
2. Add a Third-Party Auth integration with your provider's issuer URL in the [Dashboard](#add-the-integration-in-the-dashboard) or with the [Management API](#add-the-integration-with-the-management-api).
3. Add the `role` claim to the JWTs your provider issues.
4. Set up the [Supabase client](/docs/reference/javascript/introduction) in your application.
## Requirements
Your provider must meet the [limitations](/docs/guides/auth/third-party/overview#limitations) of third-party auth:
1. It exposes an OIDC Issuer Discovery URL, served at `<issuer>/.well-known/openid-configuration`.
2. It signs JWTs with an asymmetric key and includes a `kid` header parameter. Symmetrically signed JWTs, such as HS256, are not supported.
3. Its JWTs contain a `role` claim. See [Assign the role claim](#assign-the-role-claim).
The issuer URL must use HTTPS. Your project reads the signing keys from the `jwks_uri` listed in the discovery document.
## Add the integration in the Dashboard
1. In the Dashboard, go to **Authentication** > **Sign In / Providers** > [**Third-Party Auth**](/dashboard/project/_/auth/third-party).
2. Click **Add provider** and select **Custom OIDC**.
3. Enter your provider's issuer URL in **Issuer URL**, for example `https://login.example.com`.
4. Click **Add provider**.
The provider appears in the Third-Party Auth list with its issuer URL. To remove it, delete it from the same list.
## Add the integration with the Management API
Create a [personal access token](/docs/guides/platform/personal-access-tokens), then call the [create third-party auth integration](/docs/reference/api/v1-create-project-tpa-integration) endpoint with your provider's issuer URL in the `oidc_issuer_url` field. To list or remove integrations, use the [list](/docs/reference/api/v1-list-project-tpa-integrations) and [delete](/docs/reference/api/v1-delete-project-tpa-integration) endpoints.
## Supabase CLI
Custom OIDC providers are not available in the [Supabase CLI](/docs/guides/local-development/cli/getting-started). There is no config file option for them.
## Assign the role claim
Your Supabase project inspects the `role` claim in every JWT sent to it, to assign the correct [Postgres role](/docs/guides/database/postgres/roles) when using the Data API, Storage or Realtime authorization. Without a `role` claim, requests run as the `anon` role.
Set `role` to `authenticated` for signed-in users. Use your provider's custom claims or token template feature to add it. See your provider's documentation for the steps.
## Set up the Supabase client library
Pass an `accessToken` async function that returns your provider's JWT for the current user, or `null` if there is no signed-in user:
```typescript
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
'https://<supabase-project>.supabase.co',
'SUPABASE_PUBLISHABLE_KEY',
{
accessToken: async () => {
return getAccessTokenFromYourProvider()
},
}
)
```
Replace `getAccessTokenFromYourProvider` with the call your provider's SDK offers to get the current user's JWT.
## Using RLS policies
After the client sends your provider's JWT, use RLS policies to secure access to your project's database, Storage objects and Realtime channels.
### Identify the user
The `sub` claim identifies the user. `auth.uid()` casts `sub` to `uuid`, so it fails if your provider issues subjects that are not UUIDs. Read the claim directly instead:
```sql
create policy "Users can read their own rows"
on table_name
for select
to authenticated
using (user_id = (select auth.jwt()->>'sub'));
```
Here `user_id` must be a `text` column.
### Restrict access by issuer
Your project trusts every issuer you add, and `sub` values from different issuers can collide. If you use more than one issuer, or you also use Supabase Auth, add a restrictive policy that checks the `iss` claim:
```sql
create policy "Restrict access to trusted issuers"
on table_name
as restrictive
to authenticated
using (
(auth.jwt()->>'iss' = 'https://<project-ref>.supabase.co/auth/v1')
or
(auth.jwt()->>'iss' = 'https://login.example.com')
);
```
<Admonition type="danger">
Postgres has two types of policies: permissive and restrictive. This example uses a restrictive policy, so make sure you don't omit the `as restrictive` clause.
</Admonition>
For more on restrictive policies and on sharing the check across tables, Storage and Realtime, see the [Firebase Auth guide](/docs/guides/auth/third-party/firebase-auth#adding-an-extra-layer-of-security-to-your-projects-rls-policies-self-hosting-only).