Skip to content

Move policies from auth to database - #45143

Closed
SaxonF wants to merge 10 commits into
masterfrom
chore/move-policies
Closed

SaxonF wants to merge 10 commits into
masterfrom
chore/move-policies

Conversation

@SaxonF

@SaxonF SaxonF commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Proposal to move policies page from Auth to Database under an Access Control section along with Roles. This moves all existing files, applies redirects, and updates urls to point to the new route.

Summary by CodeRabbit

  • New Features

    • Added Database policies command shortcuts and navigation entries for RLS.
  • Documentation

    • Updated guides to direct users to Database > Policies for Row Level Security setup and testing.
  • Navigation & UI Updates

    • Moved policies access from Authentication to Database (new Access Control group).
    • Added permanent redirect from legacy auth policies URLs to database policies.
    • Updated dashboard links, menu labels, and commands to point to Database > Policies.

Review Change Stack

@vercel

vercel Bot commented Apr 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment May 15, 2026 5:55am
docs Ready Ready Preview, Comment, Open in v0 May 15, 2026 5:55am
learn Ready Ready Preview, Comment May 15, 2026 5:55am
studio-self-hosted Ready Ready Preview, Comment May 15, 2026 5:55am
studio-staging Ready Ready Preview, Comment May 15, 2026 5:55am
ui-library Ready Ready Preview, Comment May 15, 2026 5:55am
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 May 15, 2026 5:55am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored May 15, 2026 5:55am

Request Review

@coderabbitai

coderabbitai Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 7824fb5a-f524-4a23-9a0c-f337ae8451b3

📥 Commits

Reviewing files that changed from the base of the PR and between 8a3d20d and 311f5db.

📒 Files selected for processing (2)
  • apps/studio/components/layouts/AuthLayout/AuthLayout.utils.test.ts
  • apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts

📝 Walkthrough

Walkthrough

This PR moves RLS policy references from the Auth domain to the Database domain by updating docs links, component imports, navigation routes, layouts, menu structure, and a legacy redirect; one test import was adjusted to the Database policy utils.

Changes

Migrate RLS Policies from Auth to Database Module

Layer / File(s) Summary
Documentation guide link updates
apps/docs/content/guides/api/securing-your-api.mdx, apps/docs/content/guides/auth/general-configuration.mdx, apps/docs/content/guides/auth/oauth-server/token-security.mdx, apps/docs/content/guides/deployment/going-into-prod.mdx
Four guides now direct readers to the Database > Policies page instead of Authentication > Policies for RLS setup and policy management.
Policies component imports and dependencies
apps/studio/components/interfaces/Database/Policies/Policies.tsx, apps/studio/components/interfaces/Realtime/Policies.tsx, apps/studio/components/interfaces/Storage/Storage.types.ts, apps/studio/components/interfaces/Storage/StoragePolicies/StoragePolicies.tsx, apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesBucketRow.tsx, apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsx, apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditor.tsx, apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx, apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.utils.tsx
Components across Realtime, Storage, and Table Editor now import policy UI, types, and utilities from the Database.Policies module instead of Auth.Policies.
Navigation routing updates
apps/studio/components/interfaces/App/CommandMenu/CreateCommands.tsx, apps/studio/components/interfaces/App/CommandMenu/PolicySearchResults.tsx, apps/studio/components/interfaces/Auth/BasicAuthSettingsForm.tsx, apps/studio/components/interfaces/Integrations/Queues/QueueTab.tsx, apps/studio/components/interfaces/Linter/Linter.utils.tsx, apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx, apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx, apps/studio/components/ui/AIAssistantPanel/AIAssistant.utils.ts
Route paths, command menu entries, and navigation links for RLS policies are updated from /auth/policies to /database/policies across command menus, linter hints, and component navigation.
Page layout and layout wrapper migration
apps/studio/pages/project/[ref]/database/policies.tsx
Policies page is re-wired from AuthLayout to DatabaseLayout, with all component imports and domain dependencies switched from Auth to Database modules. Export renamed from AuthPoliciesPage to DatabasePoliciesPage.
Menu structure and command reorganization
apps/studio/components/layouts/AuthLayout/Auth.Commands.tsx, apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts, apps/studio/components/layouts/DatabaseLayout/Database.Commands.tsx, apps/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.tsx
Auth command menu reclassifies and routes policies to Database; auth menu adds external-link icon to policies entry. Database sidebar creates new "Access Control" section for policies (replacing Configuration group ownership) and adds new database command menu entries for policies navigation.
Legacy URL redirect configuration
apps/studio/next.config.ts
Permanent redirect rule added to route requests from the legacy /project/:ref/auth/policies path to the new /project/:ref/database/policies path.
Test import adjustments
apps/studio/components/interfaces/Auth/RLSTester/__tests__/RLSTesterResults.utils.test.ts, apps/studio/components/layouts/AuthLayout/AuthLayout.utils.test.ts, apps/studio/components/interfaces/Auth/RLSTester/__tests__/RLSTesterResults.test.ts, apps/studio/components/interfaces/Auth/RLSTester/__tests__/useTestQueryRLS.utils.test.ts
Test imports and a URL generation test updated to source Policy types and assert the Policies menu URL now point to the Database policies utilities and route.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • ivasilov
  • awaseem

Poem

🐰 I hopped through code, a tiny shuffle,

Swapped Auth for Database—no more scuffle.
Tests now point where policies play,
Links redirected, menus sway.
A little hop, a tidy patch—hooray! 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides a clear summary of the change (moving policies from Auth to Database under Access Control) but does not follow the provided repository template with sections like 'What kind of change', 'Current behavior', 'New behavior', or 'Additional context'. Update the description to follow the repository template with required sections: confirm CONTRIBUTING.md review, specify change type, link relevant issues, and provide screenshots or additional context.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Move policies from auth to database' is concise and directly reflects the main objective of the changeset—relocating the policies feature from the Auth module to the Database module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/move-policies

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@supabase

supabase Bot commented Apr 23, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@github-actions

github-actions Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  207 passed
skipped  5 skipped

Details

stats  212 tests across 23 suites
duration  4 minutes, 60 seconds
commit  311f5db

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Apr 24, 2026
@SaxonF
SaxonF marked this pull request as ready for review April 24, 2026 06:45
@SaxonF
SaxonF requested a review from a team as a code owner April 24, 2026 06:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/studio/components/interfaces/Integrations/Queues/QueueTab.tsx (1)

183-189: ⚠️ Potential issue | 🟡 Minor

Stale "Auth" label when linking to Database policies.

The link now routes to /project/${ref}/database/policies, but the button text still says "Auth policy/policies". Update the label to match the new location so the button and its destination stay consistent with the rest of the PR's rename.

Proposed fix
-                    href={`/project/${ref}/database/policies?search=${queueTable?.id}&schema=pgmq`}
-                  >
-                    Auth {queuePolicies.length > 1 ? 'policies' : 'policy'}
+                    href={`/project/${ref}/database/policies?search=${queueTable?.id}&schema=pgmq`}
+                  >
+                    RLS {queuePolicies.length > 1 ? 'policies' : 'policy'}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/studio/components/interfaces/Integrations/Queues/QueueTab.tsx` around
lines 183 - 189, The button label is stale ("Auth ...") in QueueTab.tsx while
the Link routes to the database policies page; update the Link/Button text to
reflect the new destination by replacing the "Auth {queuePolicies.length > 1 ?
'policies' : 'policy'}" fragment with "Database {queuePolicies.length > 1 ?
'policies' : 'policy'}" (the change should be made where the Link component
using
href={`/project/${ref}/database/policies?search=${queueTable?.id}&schema=pgmq`}
and the queuePolicies and queueTable?.id variables are referenced).
🧹 Nitpick comments (1)
apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts (1)

75-80: Point the Policies menu URL directly to the new database route.

The rightIcon now indicates this item navigates outside the Auth section, but url still resolves to /project/${ref}/auth/policies. Relying on the redirect works, but it adds an extra hop and means the ProductMenu will mark the item as "active" based on the old auth path rather than the real destination. Prefer linking to the canonical URL directly.

♻️ Suggested change
         {
           name: 'Policies',
           key: 'policies',
-          url: `${baseUrl}/policies`,
+          url: `/project/${ref}/database/policies`,
           rightIcon: ExternalLinkIcon,
           items: [],
         },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts` around lines
75 - 80, The Policies menu item (name: 'Policies', key: 'policies') currently
uses url: `${baseUrl}/policies` which points to the auth route and causes an
extra redirect; update its url to the canonical database route (e.g.
`/project/${ref}/database/policies`) so the ProductMenu links directly to the DB
policies page and active state matches the real destination.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/studio/components/interfaces/Integrations/Queues/QueueTab.tsx`:
- Around line 183-189: The button label is stale ("Auth ...") in QueueTab.tsx
while the Link routes to the database policies page; update the Link/Button text
to reflect the new destination by replacing the "Auth {queuePolicies.length > 1
? 'policies' : 'policy'}" fragment with "Database {queuePolicies.length > 1 ?
'policies' : 'policy'}" (the change should be made where the Link component
using
href={`/project/${ref}/database/policies?search=${queueTable?.id}&schema=pgmq`}
and the queuePolicies and queueTable?.id variables are referenced).

---

Nitpick comments:
In `@apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts`:
- Around line 75-80: The Policies menu item (name: 'Policies', key: 'policies')
currently uses url: `${baseUrl}/policies` which points to the auth route and
causes an extra redirect; update its url to the canonical database route (e.g.
`/project/${ref}/database/policies`) so the ProductMenu links directly to the DB
policies page and active state matches the real destination.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: bdaf3eb0-b80a-402e-8931-fbefcebbf7d8

📥 Commits

Reviewing files that changed from the base of the PR and between 1ab7251 and 1df11ad.

📒 Files selected for processing (62)
  • apps/docs/content/guides/api/securing-your-api.mdx
  • apps/docs/content/guides/auth/general-configuration.mdx
  • apps/docs/content/guides/auth/oauth-server/token-security.mdx
  • apps/docs/content/guides/deployment/going-into-prod.mdx
  • apps/studio/components/interfaces/App/CommandMenu/CreateCommands.tsx
  • apps/studio/components/interfaces/App/CommandMenu/PolicySearchResults.tsx
  • apps/studio/components/interfaces/Auth/BasicAuthSettingsForm.tsx
  • apps/studio/components/interfaces/Database/Policies/Policies.constants.ts
  • apps/studio/components/interfaces/Database/Policies/Policies.tsx
  • apps/studio/components/interfaces/Database/Policies/Policies.types.ts
  • apps/studio/components/interfaces/Database/Policies/Policies.utils.test.ts
  • apps/studio/components/interfaces/Database/Policies/Policies.utils.ts
  • apps/studio/components/interfaces/Database/Policies/PoliciesDataContext.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditor/PolicyAllowedOperation.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditor/PolicyDefinition.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditor/PolicyEditorFooter.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditor/PolicyName.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditor/PolicyRoles.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditor/index.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorModal/PolicyEditorModal.constants.ts
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorModal/PolicyEditorModalTitle.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorModal/index.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorPanel/LockedQuerySection.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorPanel/PolicyDetailsV2.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorPanel/PolicyEditorPanel.utils.ts
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorPanel/PolicyEditorPanelHeader.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorPanel/PolicyTemplates.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorPanel/QueryError.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorPanel/RLSCodeEditor.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyEditorPanel/index.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyReview.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicySelection.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyTableRow/PolicyRow.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyTableRow/PolicyTableRow.types.ts
  • apps/studio/components/interfaces/Database/Policies/PolicyTableRow/PolicyTableRow.utils.test.ts
  • apps/studio/components/interfaces/Database/Policies/PolicyTableRow/PolicyTableRow.utils.ts
  • apps/studio/components/interfaces/Database/Policies/PolicyTableRow/PolicyTableRowHeader.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyTableRow/index.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyTemplates/PolicyTemplates.constants.ts
  • apps/studio/components/interfaces/Database/Policies/PolicyTemplates/TemplatePreview.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyTemplates/TemplatesList.tsx
  • apps/studio/components/interfaces/Database/Policies/PolicyTemplates/index.tsx
  • apps/studio/components/interfaces/Integrations/Queues/QueueTab.tsx
  • apps/studio/components/interfaces/Linter/Linter.utils.tsx
  • apps/studio/components/interfaces/Realtime/Policies.tsx
  • apps/studio/components/interfaces/Storage/Storage.types.ts
  • apps/studio/components/interfaces/Storage/StoragePolicies/StoragePolicies.tsx
  • apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesBucketRow.tsx
  • apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsx
  • apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditor.tsx
  • apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
  • apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
  • apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.utils.tsx
  • apps/studio/components/layouts/AuthLayout/Auth.Commands.tsx
  • apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
  • apps/studio/components/layouts/DatabaseLayout/Database.Commands.tsx
  • apps/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.tsx
  • apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx
  • apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx
  • apps/studio/components/ui/AIAssistantPanel/AIAssistant.utils.ts
  • apps/studio/next.config.ts
  • apps/studio/pages/project/[ref]/database/policies.tsx

@ChrisChinchilla ChrisChinchilla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, would also help the confusion people have around anon with auth and Postgres roles.

@SaxonF
SaxonF requested a review from a team as a code owner May 15, 2026 04:40

@joshenlim joshenlim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one issue that i found regarding keyboard shortcuts

we should remove the one on auth policies
Image

and add one for database policies
Image

@joshenlim

Copy link
Copy Markdown
Member

Closing in favor of #47433

@joshenlim joshenlim closed this Jun 30, 2026
joshenlim added a commit that referenced this pull request Jun 30, 2026
## Context

Previous PR was [here](#45143)
but it got stale with lots of conflicts so figured it'll be easier redo
it off the latest master

Moves policies page from Auth to Database under an Access Control
section along with Roles. This moves all existing files, applies
redirects, and updates urls to point to the new route

<img width="274" height="412" alt="image"
src="https://github.com/user-attachments/assets/7952c185-64ae-4355-ba36-45397efe1787"
/>

<img width="453" height="471" alt="image"
src="https://github.com/user-attachments/assets/04b3dcb3-48a5-4049-9893-d01109fb46a9"
/>


## To test
- [ ] Verify that policies now live under Database correctly

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a quick navigation shortcut to open **Database > Policies
(RLS)**.
* **Bug Fixes**
* Updated Policies and RLS-related links across the product to open the
**Database policies** area (menus, command palette, context actions,
alerts, and link-outs).
* Added a permanent redirect from the old **auth policies** URL to the
new **database policies** URL.
* **Documentation**
* Updated RLS Dashboard and security checklist instructions to reference
**Database > Policies**.
* **Tests**
  * Adjusted automated tests to validate the new Policies route.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants