mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem Fixes #53845. The SAML SSO guide's `organization_settings` RLS example has several problems. - It compares `sso_provider_id` (`uuid`) to `auth.jwt()#>>'{amr,0,provider}'` (`text`), so creating the policy fails with `operator does not exist: uuid = text`. - It reads `amr[0]`. After an MFA step, `amr[0]` can be the MFA entry, which has no `provider`, so the expression returns null and the policy rejects the matching row. - It never enables RLS and shows only a restrictive policy, which does not grant access on its own. ## Solution Make the example self-contained: - Enable RLS on the table. - Add a permissive `SELECT` policy for authenticated users. - Keep a restrictive policy that finds the `sso/saml` entry in `amr`, reads its `provider`, and casts it to `uuid`. - Update the `auth.jwt()` provider reference in the same section to point to this lookup. This keeps the comparison as `uuid = uuid` and does not assume the SSO entry is first. This changes one example and the related `auth.jwt()` reference in one `.mdx` file. ## Verification Tested against `supabase/postgres:17.6.1.143` with the real `auth.jwt()` definition. Before, creating the policy fails: ``` using ( sso_provider_id = (select auth.jwt()#>>'{amr,0,provider}') ); ERROR: operator does not exist: uuid = text ``` After, the policy creates. With the MFA entry first (`amr` has `totp`, then `sso/saml`), the MFA-first SSO user sees only their organization's row. With the SSO entry first, the same user sees the same row. A user without an SSO entry sees no rows. Prettier passes on the file. ## Review instructions 1. Open `apps/docs/content/guides/auth/enterprise-sso/auth-sso-saml.mdx`. 2. Confirm the table enables RLS, the example has a permissive `SELECT` policy and a restrictive provider policy, the provider lookup finds the `sso/saml` entry and casts it to `uuid`, and the `auth.jwt()` reference points to that lookup. 3. Run the example against a project or local database, including a user with an MFA entry before the SSO entry. The user should see only their organization's row. ## Checklist - [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) I used AI to help debug and verify this, but I reviewed the change and am submitting the PR myself. --------- Co-authored-by: Nik Richers <nrichers@gmail.com>