Files
supabase/apps/studio/components/interfaces/Auth/OAuthApps/NewOAuthAppModal.tsx
Drew McLellan 2c871b42b7 fix(studio): show OAuth app client secret in a blocking modal (#53167)
## Problem

After creating a confidential OAuth app or regenerating its client
secret, the credentials appeared in a small dismissible banner above the
apps table. The secret can't be retrieved again, so a missed banner
meant regenerating the secret and breaking existing integrations.

## Change

- Replace `NewOAuthAppBanner` with `NewOAuthAppModal`, following the
pattern of the S3 access key `CreateCredentialModal`.
- The modal shows the client ID and client secret with copy buttons and
states the secret won't be shown again.
- It can only be closed with Done. Outside clicks, Escape and the close
button are blocked.
- Public apps (no client secret) and plain edits behave as before: no
modal.
- Create and both regenerate entry points (row menu and sheet) feed the
same modal, so no data-layer changes.

Step 1:
<img width="420" height="251" alt="Image"
src="https://github.com/user-attachments/assets/74430837-90fd-49e9-9441-234abc97588a"
/>

Step 2:
<img width="420" height="375" alt="Image"
src="https://github.com/user-attachments/assets/92ab3786-8bd1-46cf-a4b4-b2643f288e65"
/>

## Testing

- Added `NewOAuthAppModal.test.tsx`: credentials and warning render, no
modal for public or missing apps, only Done dismisses.
- Manual: Authentication → OAuth Apps → create a confidential app, and
regenerate from the row menu and the sheet.

Closes #53116
Linear: FE-4976
2026-11-09 16:30:11 +00:00

72 lines
2.2 KiB
TypeScript

import type { OAuthClient } from '@supabase/supabase-js'
import { toast } from 'sonner'
import {
Button,
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogSection,
DialogSectionSeparator,
DialogTitle,
} from 'ui'
import { Input } from 'ui-patterns/DataInputs/Input'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
interface NewOAuthAppModalProps {
oauthApp: OAuthClient | undefined
onClose: () => void
}
/**
* Shows the credentials of a newly created OAuth app, or of an app whose secret was regenerated.
* The client secret can't be retrieved again, so the modal can only be dismissed with "Done".
*/
export const NewOAuthAppModal = ({ oauthApp, onClose }: NewOAuthAppModalProps) => {
const isOpen = !!oauthApp?.client_secret
return (
<Dialog open={isOpen}>
<DialogContent
size="small"
hideClose
onInteractOutside={(e) => e.preventDefault()}
onEscapeKeyDown={(e) => e.preventDefault()}
>
<DialogHeader>
<DialogTitle>Save your client secret</DialogTitle>
<DialogDescription>
Copy the client ID and secret for {oauthApp?.client_name} now. The secret won't be shown
again. If you lose it, regenerate it from the app's settings.
</DialogDescription>
</DialogHeader>
<DialogSectionSeparator />
<DialogSection className="flex flex-col gap-4">
<FormItemLayout label="Client ID" isReactForm={false}>
<Input
copy
readOnly
className="input-mono"
value={oauthApp?.client_id}
onCopy={() => toast.success('Client ID copied to clipboard')}
/>
</FormItemLayout>
<FormItemLayout label="Client secret" isReactForm={false}>
<Input
copy
readOnly
className="input-mono"
value={oauthApp?.client_secret}
onCopy={() => toast.success('Client secret copied to clipboard')}
/>
</FormItemLayout>
</DialogSection>
<DialogFooter>
<Button onClick={onClose}>Done</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}