mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem A full docs E2E run with the anchor check from #52174 found 58 broken anchor links on 53 guide pages. Most point to renamed or removed headings. Fixing them sets a baseline of zero for the IA restructure. Closes DOCS-1516 ## Solution - Retarget each link to the section that covers it today, verified on production. - Add a custom id where links already use a hand-written slug, such as `#phx_join`. - Drop the anchor where no section fits. ## Preview links Rows with an anchor link straight to a new custom id, which is broken on live and works on the preview. For the rest, search the page for the phrase to find the changed link. | Live | Preview | Search for | Change | | --- | --- | --- | --- | | [with-react](https://supabase.com/docs/guides/getting-started/tutorials/with-react) | [with-react](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/getting-started/tutorials/with-react) | Row Level Security | `auth#row-level-security` → `database/postgres/row-level-security` (20 links, 15 files) | | [nextjs](https://supabase.com/docs/guides/auth/quickstarts/nextjs) | [nextjs](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/quickstarts/nextjs) | Supabase Auth docs | `auth#authentication` → `auth` | | [astrojs](https://supabase.com/docs/guides/auth/quickstarts/astrojs) | [astrojs](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/quickstarts/astrojs) | Supabase Auth docs | `auth#authentication` → `auth` | | [custom-domains](https://supabase.com/docs/guides/platform/custom-domains) | [custom-domains](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/custom-domains) | Owner or Admin permissions | `access-control#manage-team-members` → `#manage-organization-members` | | [network-restrictions](https://supabase.com/docs/guides/platform/network-restrictions) | [network-restrictions](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/network-restrictions) | Owner or Admin permissions | `access-control#manage-team-members` → `#manage-organization-members` | | [postgres-connection-logging](https://supabase.com/docs/guides/platform/postgres-connection-logging) | [postgres-connection-logging](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/postgres-connection-logging) | Owner or Admin permissions | `access-control#manage-team-members` → `#manage-organization-members` | | [ssl-enforcement](https://supabase.com/docs/guides/platform/ssl-enforcement) | [ssl-enforcement](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/ssl-enforcement) | Owner or Admin permissions | `access-control#manage-team-members` → `#manage-organization-members` | | [with-expo-react-native-social-sign-in](https://supabase.com/docs/guides/auth/quickstarts/with-expo-react-native-social-sign-in) | [with-expo-react-native-social-sign-in](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/quickstarts/with-expo-react-native-social-sign-in) | copied earlier | `#get-the-api-keys` → `#get-api-details` | | [with-expo-react-native-social-sign-in](https://supabase.com/docs/guides/auth/quickstarts/with-expo-react-native-social-sign-in) | [with-expo-react-native-social-sign-in](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/quickstarts/with-expo-react-native-social-sign-in) | Apple Developer Console | `auth-apple#configuration-web` → `#configuration-web-oauth` | | [with-expo-react-native-social-sign-in](https://supabase.com/docs/guides/auth/quickstarts/with-expo-react-native-social-sign-in) | [with-expo-react-native-social-sign-in](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/quickstarts/with-expo-react-native-social-sign-in) | Google Sign In | Dropped `#react-native`, a non-default tab | | [with-flutter](https://supabase.com/docs/guides/getting-started/tutorials/with-flutter) | [with-flutter](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/getting-started/tutorials/with-flutter) | copied earlier | `#get-the-api-keys` → `#get-api-details` | | [going-to-prod](https://supabase.com/docs/guides/ai/going-to-prod#hnsw-understanding-efconstruction--efsearch--and-m) | [going-to-prod](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/ai/going-to-prod#hnsw-understanding-efconstruction--efsearch--and-m) | HNSW, understanding | Custom id matching the links from `ai/choosing-compute-addon` | | [rag-with-permissions](https://supabase.com/docs/guides/ai/rag-with-permissions) | [rag-with-permissions](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/ai/rag-with-permissions) | query plan analyzer | `platform/performance#optimizing-poor-performing-queries` → `database/query-optimization#analyze-the-query-plan` | | [ivf-indexes](https://supabase.com/docs/guides/ai/vector-indexes/ivf-indexes) | [ivf-indexes](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/ai/vector-indexes/ivf-indexes) | Distance operators | `#distance-operators` → `ai/vector-indexes#distance-operators` | | [custom-claims-and-role-based-access-control-rbac](https://supabase.com/docs/guides/api/custom-claims-and-role-based-access-control-rbac) | [custom-claims-and-role-based-access-control-rbac](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/api/custom-claims-and-role-based-access-control-rbac) | local development | `auth-hooks#local-development` → `#developing` | | [native-mobile-deep-linking](https://supabase.com/docs/guides/auth/native-mobile-deep-linking) | [native-mobile-deep-linking](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/native-mobile-deep-linking) | password reset | `passwords#resetting-a-users-password-forgot-password` → `#resetting-a-password` | | [mcp-authentication](https://supabase.com/docs/guides/auth/oauth-server/mcp-authentication) | [mcp-authentication](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/oauth-server/mcp-authentication) | authorization UI | `getting-started#build-your-authorization-endpoint` → `#build-your-authorization-ui` | | [passwords](https://supabase.com/docs/guides/auth/passwords) | [passwords](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/passwords) | implicit flow | `sessions#implicit-flow`, `sessions#pkce-flow` → `sessions/implicit-flow`, `sessions/pkce-flow` | | [redirect-urls](https://supabase.com/docs/guides/auth/redirect-urls) | [redirect-urls](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/redirect-urls) | third-party providers | Dropped the `auth-signinwithoauth` example anchor | | [users](https://supabase.com/docs/guides/auth/users) | [users](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/auth/users) | User Identity | `auth-identity-linking#the-user-identity` → `identities#the-user-identity-object` | | [upgrading](https://supabase.com/docs/guides/platform/upgrading#upgrading-to-pg_graphql-160) | [upgrading](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/upgrading#upgrading-to-pg_graphql-160) | Upgrading to pg_graphql | Custom id matching the link from `database/extensions/pg_graphql` | | [import-data](https://supabase.com/docs/guides/database/import-data) | [import-data](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/database/import-data) | disk management | `database-size#disk-management` → `#disk-size` | | [multigres](https://supabase.com/docs/guides/database/multigres) | [multigres](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/database/multigres) | Private Alpha | Dropped the link. `getting-started/features` redirects to `/features` | | [data-deletion](https://supabase.com/docs/guides/database/postgres/data-deletion) | [data-deletion](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/database/postgres/data-deletion) | Check for blocked queries | `#monitoring-locks` → `#check-for-blocked-queries` | | [postgres-log-config](https://supabase.com/docs/guides/database/postgres/postgres-log-config) | [postgres-log-config](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/database/postgres/postgres-log-config) | Supavisor | `connecting-to-postgres#poolers` → `pooling-and-limits#shared-pooler` and `#dedicated-pooler` | | [partner-catalog](https://supabase.com/docs/guides/integrations/partner-catalog) | [partner-catalog](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/integrations/partner-catalog) | Project GraphQL API | `api#graphql-api-overview` → `graphql` | | [vercel-marketplace](https://supabase.com/docs/guides/integrations/vercel-marketplace) | [vercel-marketplace](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/integrations/vercel-marketplace) | How your Vercel team maps | `#permissions` → `#how-your-vercel-team-maps-to-supabase` | | [managing-config](https://supabase.com/docs/guides/local-development/managing-config) | [managing-config](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/local-development/managing-config) | Managing secrets for branches | `branching#managing-secrets-for-branches` → `branching/configuration#managing-secrets-for-branches` | | [reports](https://supabase.com/docs/guides/observability/reports) | [reports](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/observability/reports) | Query Performance Advisory | `performance#examine-query-performance` → `#examining-query-performance` | | [backups](https://supabase.com/docs/guides/platform/backups) | [backups](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/backups) | legacy logical backup | `backup-restore#backup-database-using-the-cli` → `#back-up-database-using-the-cli` | | [backups](https://supabase.com/docs/guides/platform/backups#pitr-restoration-process) | [backups](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/backups#pitr-restoration-process) | Restoration process | Custom id matching the link from `read-replicas/getting-started` | | [branching](https://supabase.com/docs/guides/platform/manage-your-usage/branching) | [branching](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/manage-your-usage/branching) | persistent branches | `branching#persistent-branches` → `#how-branching-works` | | [point-in-time-recovery](https://supabase.com/docs/guides/platform/manage-your-usage/point-in-time-recovery) | [point-in-time-recovery](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/manage-your-usage/point-in-time-recovery) | backup frequency | `backups#frequency-of-backups` → `backups` | | [read-replicas](https://supabase.com/docs/guides/platform/read-replicas) | [read-replicas](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/platform/read-replicas) | IPv4 add-on | `ipv4-address#read-replicas` → `#read-replicas-and-ipv4-add-on` | | [protocol](https://supabase.com/docs/guides/realtime/protocol#access-token) | [protocol](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/realtime/protocol#access-token) | access_token | Custom id matching the link from `realtime/authorization` | | [postgres-changes](https://supabase.com/docs/guides/realtime/postgres-changes#negating-a-filter-not) | [postgres-changes](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/realtime/postgres-changes#negating-a-filter-not) | Negating a filter | Custom id matching the existing in-page link | | [protocol](https://supabase.com/docs/guides/realtime/protocol#phx_join) | [protocol](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/realtime/protocol#phx_join) | phx_join | Custom id matching the existing in-page link | | [reports](https://supabase.com/docs/guides/realtime/reports) | [reports](https://docs-git-docs-fix-broken-anchors-supabase.vercel.app/docs/guides/realtime/reports) | Broadcast via REST API | `broadcast#broadcast-via-rest-api` → `#broadcast-using-the-rest-api` | <details> <summary>The 15 files with Row Level Security links</summary> - `_partials/quickstart_intro.mdx`, used by the framework tutorials - `auth/phone-login` - `auth/quickstarts/with-expo-react-native-social-sign-in` - `database/postgres/column-level-security` - `getting-started/tutorials/`: `with-flutter`, `with-ionic-angular`, `with-ionic-react`, `with-ionic-vue`, `with-kotlin`, `with-nuxt-3`, `with-redwoodjs`, `with-solidjs`, `with-svelte`, `with-swift`, `with-vue-3` </details> ## Review instructions 1. Open a few live and preview links side by side, and click the changed link on each to confirm the preview lands on the right section. 2. From a checkout of `docs/e2e-anchor-links`, run the anchor check against the preview with the changed pages, as described in `e2e/docs/README.md`: `DOCS_E2E_PAGE_PATHS=<changed /docs/... paths> PLAYWRIGHT_BASE_URL=https://docs-git-docs-fix-broken-anchors-supabase.vercel.app pnpm exec playwright test --grep-invert @a11y` 3. Confirm the anchor check reports no failures. ## 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)
163 lines
5.5 KiB
Plaintext
163 lines
5.5 KiB
Plaintext
---
|
|
id: 'column-level-security'
|
|
title: 'Column Level Security'
|
|
description: 'Secure your data using Postgres Column Level Security.'
|
|
---
|
|
|
|
Postgres's [Row Level Security (RLS)](https://www.postgresql.org/docs/current/ddl-rowsecurity.html) gives you granular control over who can access rows of data. However, it doesn't give you control over which columns they can access within rows. Sometimes you want to restrict access to specific columns in your database. Column Level Privileges allows you to do that.
|
|
|
|
<Admonition type="caution">
|
|
|
|
This is an advanced feature. We do not recommend using column-level privileges for most users. Instead, we recommend using RLS policies in combination with a dedicated table for handling user roles.
|
|
|
|
</Admonition>
|
|
|
|
<Admonition type="caution">
|
|
|
|
Restricted roles cannot use the wildcard operator (`*`) on the affected table. Instead of using `SELECT * FROM <restricted_table>;` or its API equivalent, you must specify the column names explicitly.
|
|
|
|
</Admonition>
|
|
|
|
## Policies at the row level
|
|
|
|
Policies in Row Level Security (RLS) are used to restrict access to rows in a table. Think of them like adding a `WHERE` clause to every query.
|
|
|
|
For example, assume you have a `posts` table with the following columns:
|
|
|
|
- `id`
|
|
- `user_id`
|
|
- `title`
|
|
- `content`
|
|
- `created_at`
|
|
- `updated_at`
|
|
|
|
You can restrict updates to the user who created it using [RLS](/docs/guides/database/postgres/row-level-security), with the following policy:
|
|
|
|
```sql
|
|
create policy "Allow update for owners" on posts for
|
|
update
|
|
using ((select auth.uid()) = user_id);
|
|
```
|
|
|
|
However, this gives the post owner full access to update the row, including all of the columns.
|
|
|
|
## Privileges at the column level
|
|
|
|
To restrict access to columns, you can use [Privileges](https://www.postgresql.org/docs/current/ddl-priv.html).
|
|
|
|
There are two types of privileges in Postgres:
|
|
|
|
1. **table-level**: Grants the privilege on all columns in the table.
|
|
2. **column-level** Grants the privilege on a specific column in the table.
|
|
|
|
You can have both types of privileges on the same table. If you have both, and you revoke the column-level privilege, the table-level privilege will still be in effect.
|
|
|
|
By default, our table will have a table-level `UPDATE` privilege, which means that the `authenticated` role can update all the columns in the table.
|
|
|
|
```sql
|
|
revoke
|
|
update
|
|
on table public.posts
|
|
from
|
|
authenticated;
|
|
|
|
grant
|
|
update
|
|
(title, content) on table public.posts to authenticated;
|
|
```
|
|
|
|
In the above example, we are revoking the table-level `UPDATE` privilege from the `authenticated` role and granting a column-level `UPDATE` privilege on the `title` and `content` columns.
|
|
|
|
If we want to restrict access to updating the `title` column:
|
|
|
|
```sql
|
|
revoke
|
|
update
|
|
(title) on table public.posts
|
|
from
|
|
authenticated;
|
|
```
|
|
|
|
This time, we are revoking the column-level `UPDATE` privilege of the `title` column from the `authenticated` role. We didn't need to revoke the table-level `UPDATE` privilege because it's already revoked.
|
|
|
|
## Manage column privileges in the Dashboard
|
|
|
|
<Admonition type="caution">
|
|
|
|
Column-level privileges are a powerful tool, but they're also quite advanced and in many cases, not the best fit for common access control needs. For that reason, we've intentionally moved the UI for this feature under the Feature Preview section in the dashboard.
|
|
|
|
</Admonition>
|
|
|
|
You can view and edit the privileges in the [Supabase Studio](/dashboard/project/_/database/column-privileges).
|
|
|
|

|
|
|
|
## Manage column privileges in migrations
|
|
|
|
While you can manage privileges directly from the Dashboard, as your project grows you may want to manage them in your migrations. Read about database migrations in the [Local Development](/docs/guides/deployment/database-migrations) guide.
|
|
|
|
<StepHikeCompact>
|
|
|
|
<StepHikeCompact.Step step={1}>
|
|
<StepHikeCompact.Details title="Create a migration file">
|
|
|
|
To get started, generate a [new migration](/docs/reference/cli/supabase-migration-new) to store the SQL needed to create your table along with row and column-level privileges.
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
|
|
```bash
|
|
supabase migration new create_posts_table
|
|
```
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
</StepHikeCompact.Step>
|
|
</StepHikeCompact>
|
|
|
|
<StepHikeCompact>
|
|
|
|
<StepHikeCompact.Step step={2}>
|
|
<StepHikeCompact.Details title="Add the SQL to your migration file">
|
|
This creates a new migration: supabase/migrations/\<timestamp\>
|
|
_create_posts_table.sql.
|
|
|
|
To that file, add the SQL to create this `posts` table with row and column-level privileges.
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
```sql
|
|
create table
|
|
posts (
|
|
id bigint primary key generated always as identity,
|
|
user_id text,
|
|
title text,
|
|
content text,
|
|
created_at timestamptz default now(),
|
|
updated_at timestamptz default now()
|
|
);
|
|
|
|
-- Add row-level security
|
|
create policy "Allow update for owners" on posts for
|
|
update
|
|
using ((select auth.uid()) = user_id);
|
|
|
|
-- Add column-level security
|
|
revoke
|
|
update
|
|
(title) on table public.posts
|
|
from
|
|
authenticated;
|
|
```
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
</StepHikeCompact.Step>
|
|
</StepHikeCompact>
|
|
|
|
## Considerations when using column-level privileges
|
|
|
|
- If you turn off a column privilege you won't be able to use that column at all.
|
|
- All operations (insert, update, delete) as well as using `select *` will fail.
|