Files
supabase/apps/studio/components/interfaces/Organization/OAuthApps/Consent/DatabaseAccessProjectIssues.tsx
Danny WhiteandJoshen Lim 4dbb966b2e feat(studio): show Trusted Partner access on OAuth consent (#53583)
> [!WARNING]
> Live readiness checks require
[CTRL-2277](https://linear.app/supabase/issue/CTRL-2277) in the target
environment; production deployment is pending.

## Problem

Trusted Partner consent must explain direct database access and project
blockers before authorisation.
[DEPR-732](https://linear.app/supabase/issue/DEPR-732)

## Solution

- Show Direct database access alongside the requested permissions.
- Check selected projects, or every project page for organisation-wide
grants.
- Separate blocking issues from SSL notices; block authorisation during
loading or errors and offer retry.

| After |
| --- |
| <img width="1280" height="1323" alt="Authorize API Access Supabase"
src="https://github.com/user-attachments/assets/adb6367a-bace-4b62-81b5-68ba4c11396c"
/> |
| Consent screen with Direct database access (previously “Table data”)
and Database management |
| <img width="1280" height="1323" alt="Authorize API Access Supabase"
src="https://github.com/user-attachments/assets/0c35900c-1059-49cd-b1c5-4e0cf5441b9b"
/> |
| Selected-project blockers and the separate SSL notice |
| <img width="1280" height="1323" alt="95741"
src="https://github.com/user-attachments/assets/1fbef4f0-0433-4c93-b390-84d210dfb665"
/> |
| Organisation-wide blockers _without_ project-removal actions |

## Review instructions

1. Open the [staging consent
screen](https://studio-staging-git-dnywh-depr-732-trusted-partn-f24cfb-supabase.vercel.app/dashboard/authorize?auth_id=11666aa8-7f7e-4705-b33a-981903fd682e).
Enable `enableScopedOAuthConsent` in the dev toolbar’s **Flags** tab if
needed.
2. Open Chrome DevTools → **Network** and reload. Select the **GET**
request ending in `/platform/oauth/authorizations/{id}`.
3. Right-click that request → **Override content**. Choose a local
folder and click **Allow**. Add `database_token_access:read` and
`database_token_access:write` to `scopes`. Use only the read scope to
check read-only access. Keep every other field, save with
**Cmd/Ctrl+S**, then reload with DevTools open.
4. Select projects. Override each **GET** request ending in
`/platform/organizations/{slug}/oauth/authorizations/{id}/projects/{ref}/database-access`.
Use `{"issues":[],"enables_ssl":false}` for ready projects, then
`{"issues":[],"enables_ssl":true}` for an SSL notice. Save and reload
after each change. Check Direct database access and Database management
are separate, and SSL alone allows authorisation.
5. Change a readiness response to
`{"issues":["postgres_upgrade_required","platform_unsupported"],"enables_ssl":true}`.
Save and reload. Check blockers prevent authorisation, SSL stays
separate, and removing a blocked project clears its blockers.
6. Set `project_scoping_mode: false` in the authorisation override. Save
and reload. Check any blocked project prevents organisation-wide
authorisation, with no project-removal actions.
7. Block a database-access request in Network and reload. Check
authorisation stays disabled. Unblock it and choose **Retry checks**.
8. For a returning app, override `existing_grant.approved_scopes` in the
request ending in `/preflight`. Save and reload. Check added, removed
and unchanged permissions.
9. Disable **Sources → Overrides → Enable Local Overrides**. Repeat
ready and blocked project checks with a real staging authorisation
before approving live readiness behaviour.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-12-02 16:19:30 +07:00

58 lines
1.9 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { XIcon } from 'lucide-react'
import { Admonition } from 'ui-patterns/Admonition'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import type { OAuthDatabaseAccessIssue } from '@/data/oauth-apps/oauth-apps-database-access-readiness-query'
const issueMessages: Record<OAuthDatabaseAccessIssue, string> = {
postgres_upgrade_required: 'Needs Postgres 17 or later.',
project_unavailable: 'Database is currently unavailable.',
platform_unsupported: 'Direct database access is not supported on this project’s platform.',
unknown: 'This project can’t be checked right now. Contact support if this persists.',
}
export function DatabaseAccessProjectIssues({
projects,
onRemove,
}: {
projects: {
ref: string
name: string
issues: OAuthDatabaseAccessIssue[]
}[]
onRemove?: (ref: string) => void
}) {
return (
<Admonition
type="warning"
title="These projects require changes"
description={onRemove ? 'Fix or remove them to continue.' : 'Fix them to continue.'}
>
<div className="mt-1 divide-y text-xs">
{projects.map(({ ref, name, issues }) => (
<div key={ref} className="flex items-center justify-between gap-2 py-2">
<div className="min-w-0 leading-normal">
<div className="font-medium text-foreground">{name}</div>
<ul className="list-disc pl-4">
{issues.map((issue) => (
<li key={issue}>{issueMessages[issue]}</li>
))}
</ul>
</div>
{onRemove && (
<ButtonTooltip
variant="text"
size="tiny"
aria-label={`Remove ${name}`}
onClick={() => onRemove(ref)}
icon={<XIcon />}
tooltip={{ content: { side: 'top', text: 'Remove project' } }}
/>
)}
</div>
))}
</div>
</Admonition>
)
}