Files
Danny White 9052601faf fix(studio): validate direct database access permissions (#54506)
## Problem

Direct database access requires Database management read access, but
OAuth app settings currently allow saving an invalid combination. The
consent screen’s readiness checks then fail.

## Solution

Show an inline error when direct database access lacks Database
management read access, and prevent saving through the button, keyboard
shortcut, or form submission. Both controls stay editable, and neither
changes the other automatically.

| After |
| --- |
| <img width="1280" height="1103" alt="OAuth Apps Organization Settings
Office Supabase (1)"
src="https://github.com/user-attachments/assets/6cfd203b-d320-46da-b7b5-9ede2e9d814c"
/> |
| _Immediate inline error, cleared as soon as it’s corrected._ |
| <img width="1280" height="1103" alt="OAuth Apps Organization Settings
Office Supabase"
src="https://github.com/user-attachments/assets/f2637d92-c149-4d1a-9d83-130e0f54ce66"
/> |
| _Follow-up footer pattern if that error (or any inline error) is
ignored._ |

## Review instructions

1. Open the [staging
preview](https://studio-staging-git-dnywh-trusted-partner-permis-56807c-supabase.vercel.app/dashboard)
→ Organization → OAuth Apps. Edit an organisation-bound app, or select
**Publish OAuth app**. If your organisation is not a Trusted Partner,
use the DevTools steps below first.
2. Select Direct database access, then set Database management to No
access or Write. Check that the inline error explains that “Database
management” requires at least read access and Confirm stays enabled.
Click Confirm: saving should be blocked and “Fix the errors above to
continue.” should appear in red above the footer actions.
3. Select Database management Read only or Read and write. Check that
the inline and footer errors clear. Confirm should remain enabled.
4. Repeat in the opposite order, or remove Direct database access.
Neither control should change automatically.


<details>
<summary>Review without a Trusted Partner organisation (Chrome
DevTools)</summary>

1. In the Studio dev toolbar’s **Flags** tab, enable
`enableScopedOAuthPublish` if needed.
2. Open Chrome DevTools → **Network**, then open **Publish OAuth app**
or edit an existing app.
3. Select the **GET** request whose URL ends in
`/platform/organizations/YOUR_ORG_SLUG`, without `/oauth/apps` after it.
Its response contains your organisation’s name and slug.
4. Right-click the request → **Override content**. Choose a local folder
and click **Allow**. Add `"is_trusted_partner": true` to the top-level
JSON object, or change the existing value to `true`. Keep every other
field and save with **Cmd/Ctrl+S**.
5. Reload with DevTools open and reopen the app form. For a new app,
choose **An owner, once for the whole organization** under
**Authorization**. Fill in the required name, website and callback URL
so other validation does not interfere.
6. Under **Application permissions**, select **Direct database access →
Read only** while **Database management** has **No access**. Check that
the inline error appears and **Confirm** stays enabled. Click
**Confirm** and check that saving is blocked, with “Fix the errors above
to continue.” in red above the footer actions.
7. Set **Database management → Read only** or **Read and write**. Check
that the inline and footer errors clear, while **Confirm** remains
enabled. Change it to **Write** and check that the error returns.
Neither permission should change automatically.
8. Set **Direct database access → No access**. Check that the inline and
footer errors clear. Cancel the form without saving.
9. Turn off **Sources → Overrides → Enable Local Overrides** and reload
when finished.

The override only changes the response in your browser. It does not
grant backend Trusted Partner eligibility, so use it to review the UI
validation. Saving an app with direct database access requires a
genuinely eligible organisation.

</details>
2026-12-03 13:39:50 +07:00
..