Files
supabase-vercel-tedd[bot] caf7baaf08 docs(auth): show RLS policies that match the Firebase user ID (#53992)
## Problem

The Firebase Auth guide sets up the client, the integration, the `role`
claim, and the issuer check, but never shows how to limit rows to the
signed-in Firebase user. The obvious helper, `auth.uid()`, fails with
Firebase UIDs.

Related to
[FDBKIN-16284](https://linear.app/supabase/issue/FDBKIN-16284/provide-a-clear-process-for-connecting-firebase-auth-to-supabase-rls)
Closes
[DOCS-1796](https://linear.app/supabase/issue/DOCS-1796/show-how-to-write-rls-policies-that-match-the-firebase-user-id)

## Solution

Adds a short "Write RLS policies for Firebase users" section to the
Firebase Auth guide. It explains that `sub` holds the Firebase `uid`,
shows a select policy that compares a `text` column with `(select
auth.jwt()->>'sub')`, and says to use `auth.jwt()->>'sub'` in place of
`auth.uid()`, which casts `sub` to `uuid`. The snippet uses the same
shape and placeholder as the page's other policies and the custom OIDC
guide. It points self-hosters to the restrictive issuer policy.

## How to verify

1. Open
https://docs-git-tedd-docs-1796-supabase.vercel.app/docs/guides/auth/third-party/firebase-auth#write-rls-policies-for-firebase-users.
2. The section sits between "Add a new Third-Party Auth integration to
your project" and the self-hosting restrictive policy section.
3. The SQL snippet creates a select policy on `table_name` for
`authenticated` using `user_id = (select auth.jwt()->>'sub')`.
4. The text says `user_id` must be a `text` column, and to use
`auth.jwt()->>'sub'` in place of `auth.uid()`, which fails with `invalid
input syntax for type uuid`.
5. The text asks only self-hosters to add the restrictive issuer policy.
6. The links to the RLS guide, the `role` claim section, and the
restrictive issuer policy section go to the right headings.

## Checks

Ran `pnpm exec oxfmt --check` on the changed file. Checked `auth.uid()`
against the `supabase/auth` migration
`20220224000811_update_auth_functions.up.sql` (it casts `sub` to
`uuid`), and the `sub` claim against Firebase's ID token docs. Skipped
`pnpm build:guides-markdown`, which needs GitHub credentials that the
build environment didn't have.

## Checklist

- [x] I have read the [Contributing
Guidelines](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] I have checked that the change works in the preview deployment

## Feedback for Tedd

To ask Tedd for a change to this PR, reply in Tedd's session on
[DOCS-1796](https://linear.app/supabase/issue/DOCS-1796/show-how-to-write-rls-policies-that-match-the-firebase-user-id).
Tedd doesn't read comments on this PR.

---------

Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
2026-11-24 20:02:27 -07:00
..