Files
supabase/apps/studio/components/interfaces/Organization/OAuthApps/OAuthAppsRevokeDialogContent.tsx
Danny WhiteandJoshen Lim 05cbf8ca50 feat(studio): show Trusted Partner access in Authorized Apps (#53705)
## Problem

Organisation admins need to see authorised apps’ direct database access.
[DEPR-731](https://linear.app/supabase/issue/DEPR-731)

## Solution

- Show the approved direct-access level in Authorized apps.
- Show permissions and project coverage in **View access**.

| After |
| --- |
| <img width="1280" height="813" alt="OAuth Apps Organization Settings
Basket Supabase"
src="https://github.com/user-attachments/assets/d2bbc682-6e6f-462f-b5c2-3a2a8ff813ba"
/> |
| Authorized apps list showing read-only direct access |
| <img width="1280" height="813" alt="OAuth Apps Organization Settings
Basket Supabase (4)"
src="https://github.com/user-attachments/assets/24506547-461a-44e0-880f-6ade23fd734c"
/> |
| Authorized apps list showing read-write direct access |
| <img width="1280" height="813" alt="OAuth Apps Organization Settings
Basket Supabase (1)"
src="https://github.com/user-attachments/assets/53ac2662-9fb7-4cfc-b118-31ef5778b339"
/> |
| View access sheet with permission groups and project coverage |
| <img width="1280" height="813" alt="OAuth Apps Organization Settings
Basket Supabase (3)"
src="https://github.com/user-attachments/assets/a21cefa7-c656-4b5c-bb0c-075c724350f9"
/> |
| View access sheet with permission groups and project coverage |
| <img width="424" height="297" alt="CleanShot 2026-12-02 at 15 09 39"
src="https://github.com/user-attachments/assets/e1f83068-21a8-43c4-9ca8-dcf6a3164b01"
/> |
| Added second paragraph for revoking access to apps with direct
database access. This “existing connections will close shortly” is only
accurate one CTRL-2141 merges, as discussed
[here](https://github.com/supabase/supabase/pull/53705/changes#r4764576735).
|

## Review instructions

1. Open the [staging
preview](https://studio-staging-git-dnywh-depr-731-authorized-apps-supabase.vercel.app/dashboard),
select a test organisation and open **Apps**
(`/dashboard/org/{slug}/apps`). Enable `enableScopedOAuthManage` in the
Studio dev toolbar’s **Flags** tab if needed.
2. Open Chrome DevTools → **Network** and reload. Select the **GET**
request ending in `/platform/organizations/{slug}/oauth/approvals`.
3. Right-click that request → **Override content**. Choose a local
folder and click **Allow**. For an existing organisation-bound app, add
`database_token_access:read` to `attributes.org_grant.approved_scopes`.
Keep every other field, save with **Cmd/Ctrl+S**, then reload with
DevTools open.
4. Open the app’s **View access**. Override the **GET** request ending
in `/platform/organizations/{slug}/oauth/approvals/{app_id}/grants`. Add
the same scope to the matching grant’s `attributes.approved_scopes`.
Save and reload.
5. Check read-only direct access in the list and access sheet. Change
the scope to `database_token_access:write` in both overrides, save and
reload. Check read-write access and compare it with a standard app.
6. Compare the grants response’s existing `attributes.projects` list
with `null` for all projects. Save and reload after each change. Check
permission groups, project coverage and the app ID in **View access**.
7. Open **Revoke access**, check the existing OAuth access explanation,
then choose **Cancel**.
8. Disable **Sources → Overrides → Enable Local Overrides**. Repeat with
real authorised staging apps.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-12-02 14:05:39 +07:00

102 lines
2.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 { useParams } from 'common'
import { ComponentProps } from 'react'
import { toast } from 'sonner'
import {
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
Button,
} from 'ui'
import { AlertError } from '@/components/ui/AlertError'
import { OAuthApproval } from '@/data/oauth-apps/oauth-apps-approvals-query'
import { useOAuthAppRevokeMutation } from '@/data/oauth-apps/oauth-apps-revoke-mutation'
import { getOAuthDatabaseTokenAccess } from '@/data/oauth-apps/types'
export interface OAuthAppsRevokeDialogProps extends ComponentProps<typeof AlertDialogContent> {
approval?: OAuthApproval
onClose: (revoked: boolean) => void
}
export const OAuthAppsRevokeDialogContent = ({
approval,
onClose,
onEscapeKeyDown,
...props
}: OAuthAppsRevokeDialogProps) => {
const { slug } = useParams()
const {
mutate: revokeApp,
isPending,
isError,
error,
reset,
} = useOAuthAppRevokeMutation({
onSuccess: () => {
toast.success(`Revoked access for ${approval?.attributes.app.name}`)
onClose(true)
},
onError: () => {
// Do nothing, we just want to avoid the default toast.
// Error is displayed in the AlertError below
},
})
if (!approval) return null
const hasDirectDatabaseAccess = !!getOAuthDatabaseTokenAccess(
approval.attributes.org_grant?.approved_scopes
)
return (
<AlertDialogContent
size="small"
{...props}
onEscapeKeyDown={(event) => {
onEscapeKeyDown?.(event)
if (isPending) event.preventDefault()
}}
>
<AlertDialogHeader>
<AlertDialogTitle>Revoke access</AlertDialogTitle>
<AlertDialogDescription asChild>
<div className="space-y-4">
<p>
“{approval.attributes.app.name}” will lose access for this organization and all its
members on its next request.
</p>
{hasDirectDatabaseAccess && (
<p>
Database access will be revoked. New connections are blocked immediately, and
existing connections will close shortly. The app’s database role and any objects it
created are not deleted.
</p>
)}
</div>
</AlertDialogDescription>
</AlertDialogHeader>
{isError && <AlertError subject="Failed to revoke access" error={error} />}
<AlertDialogFooter>
<AlertDialogCancel asChild>
<Button variant="default" disabled={isPending} onClick={() => reset()}>
Cancel
</Button>
</AlertDialogCancel>
<Button
variant="danger"
loading={isPending}
onClick={() => {
if (approval && slug) revokeApp({ slug, appId: approval.id })
}}
>
Revoke
</Button>
</AlertDialogFooter>
</AlertDialogContent>
)
}