The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Feat: Adds Oauth client management (#34591)
Jonathan Summers-Muiraefb34fd9c5b
diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/AuthorizedAppRow.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/AuthorizedAppRow.tsxindex 57b21191e7c..f09b319cd5d 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/AuthorizedAppRow.tsx+++ b/apps/studio/components/interfaces/Organization/OAuthApps/AuthorizedAppRow.tsx@@ -11,7 +11,7 @@ export interface AuthorizedAppRowProps {onSelectRevoke: () => void}-const AuthorizedAppRow = ({ app, onSelectRevoke }: AuthorizedAppRowProps) => {+export const AuthorizedAppRow = ({ app, onSelectRevoke }: AuthorizedAppRowProps) => {return (<Table.tr><Table.td>@@ -45,5 +45,3 @@ const AuthorizedAppRow = ({ app, onSelectRevoke }: AuthorizedAppRowProps) => {</Table.tr>)}--export default AuthorizedAppRowdiff --git a/apps/studio/components/interfaces/Organization/OAuthApps/DeleteAppModal.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/DeleteAppModal.tsxindex e8472240b36..9f95d1da56f 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/DeleteAppModal.tsx+++ b/apps/studio/components/interfaces/Organization/OAuthApps/DeleteAppModal.tsx@@ -12,7 +12,7 @@ export interface DeleteAppModalProps {onClose: () => void}-const DeleteAppModal = ({ selectedApp, onClose }: DeleteAppModalProps) => {+export const DeleteAppModal = ({ selectedApp, onClose }: DeleteAppModalProps) => {const { slug } = useParams()const { mutate: deleteOAuthApp, isLoading: isDeleting } = useOAuthAppDeleteMutation({onSuccess: () => {@@ -64,5 +64,3 @@ const DeleteAppModal = ({ selectedApp, onClose }: DeleteAppModalProps) => {</Modal>)}--export default DeleteAppModaldiff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthAppRow.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthAppRow.tsxindex 5570d88e304..ea6ce8776b3 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthAppRow.tsx+++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthAppRow.tsx@@ -24,7 +24,7 @@ export interface OAuthAppRowProps {onSelectDelete: () => void}-const OAuthAppRow = ({ app, onSelectEdit, onSelectDelete }: OAuthAppRowProps) => {+export const OAuthAppRow = ({ app, onSelectEdit, onSelectDelete }: OAuthAppRowProps) => {const canUpdateOAuthApps = useCheckPermissions(PermissionAction.UPDATE, 'approved_oauth_apps')const canDeleteOAuthApps = useCheckPermissions(PermissionAction.DELETE, 'approved_oauth_apps')@@ -51,11 +51,6 @@ const OAuthAppRow = ({ app, onSelectEdit, onSelectDelete }: OAuthAppRowProps) =><CopyButton type="default" iconOnly text={app.client_id ?? ''} className="px-1" /></div></Table.td>- <Table.td>- <span className="font-mono" title={app.client_secret_alias}>- {app.client_secret_alias}...- </span>- </Table.td><Table.td><TimestampInfoutcTimestamp={app.created_at ?? ''}@@ -68,7 +63,7 @@ const OAuthAppRow = ({ app, onSelectEdit, onSelectDelete }: OAuthAppRowProps) =><DropdownMenuTrigger asChild><Button type="default" icon={<MoreVertical />} className="px-1" /></DropdownMenuTrigger>- <DropdownMenuContent align="end" side="bottom">+ <DropdownMenuContent align="end" side="bottom" className="w-32"><Tooltip><TooltipTrigger asChild><DropdownMenuItem@@ -116,5 +111,3 @@ const OAuthAppRow = ({ app, onSelectEdit, onSelectDelete }: OAuthAppRowProps) =></Table.tr>)}--export default OAuthAppRowdiff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.tsxindex c30653a310f..22e1b74c5cb 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.tsx+++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.tsx@@ -1,5 +1,5 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-import { X } from 'lucide-react'+import { Check, X } from 'lucide-react'import { useState } from 'react'import { useParams } from 'common'@@ -7,18 +7,19 @@ import { ScaffoldContainerLegacy } from 'components/layouts/Scaffold'import Table from 'components/to-be-cleaned/Table'import AlertError from 'components/ui/AlertError'import { ButtonTooltip } from 'components/ui/ButtonTooltip'+import CopyButton from 'components/ui/CopyButton'import NoPermission from 'components/ui/NoPermission'import ShimmeringLoader from 'components/ui/ShimmeringLoader'import { AuthorizedApp, useAuthorizedAppsQuery } from 'data/oauth/authorized-apps-query'import { OAuthAppCreateResponse } from 'data/oauth/oauth-app-create-mutation'import { OAuthApp, useOAuthAppsQuery } from 'data/oauth/oauth-apps-query'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'-import { Alert, Button, Input } from 'ui'-import AuthorizedAppRow from './AuthorizedAppRow'-import DeleteAppModal from './DeleteAppModal'-import OAuthAppRow from './OAuthAppRow'-import PublishAppModal from './PublishAppSidePanel'-import RevokeAppModal from './RevokeAppModal'+import { Button, cn } from 'ui'+import { AuthorizedAppRow } from './AuthorizedAppRow'+import { DeleteAppModal } from './DeleteAppModal'+import { OAuthAppRow } from './OAuthAppRow'+import { PublishAppSidePanel } from './PublishAppSidePanel'+import { RevokeAppModal } from './RevokeAppModal'// [Joshen] Note on nav UX// Kang Ming mentioned that it might be better to split Published Apps and Authorized Apps into 2 separate tabs@@ -111,7 +112,13 @@ const OAuthApps = () => {)}{createdApp !== undefined && (- <Alert withIcon variant="success" title="Successfully published a new application!">+ <div+ className={cn(+ 'flex items-center justify-between p-4 px-6 border first:rounded-t last:rounded-b',+ 'bg-background-alternative',+ 'rounded'+ )}+ ><div className="absolute top-4 right-4"><Buttontype="text"@@ -121,32 +128,31 @@ const OAuthApps = () => {/></div><div className="w-full space-y-4">- <p className="text-sm">- Ensure that you store the client secret securely - you will not be able to see it- again.- </p>- <div className="space-y-4">- <Input- copy- readOnly- size="small"- label="Client ID"- className="max-w-xl input-mono"- value={createdApp.client_id}- onChange={() => {}}- />- <Input- copy- readOnly- size="small"- label="Client secret"- className="max-w-xl input-mono"- value={createdApp.client_secret}- onChange={() => {}}- />+ <div className="flex flex-col gap-0">+ <div className="flex items-center gap-2">+ <Check size={14} className="text-brand" strokeWidth={3} />+ <p className="text-sm">You've created your new OAuth application.</p>+ </div>+ <p className="text-sm text-foreground-light">+ Ensure that you store the client secret securely - you will not be able to see+ it again.+ </p>+ </div>+ <div className="flex flex-col gap-1">+ <div className="flex items-center gap-2">+ <p className="text-sm text-foreground-light">Client ID</p>+ <p className="font-mono text-sm">{createdApp.client_id}</p>+ <CopyButton text={createdApp.client_secret} type="default" iconOnly />+ </div>++ <div className="flex items-center gap-2">+ <p className="text-sm text-foreground-light">Client Secret</p>+ <p className="font-mono text-sm">{createdApp.client_secret}</p>+ <CopyButton text={createdApp.client_secret} type="default" iconOnly />+ </div></div></div>- </Alert>+ </div>)}{isSuccessPublishedApps && (@@ -161,7 +167,6 @@ const OAuthApps = () => {<Table.th key="icon" className="w-[30px]"></Table.th>,<Table.th key="name">Name</Table.th>,<Table.th key="client-id">Client ID</Table.th>,- <Table.th key="client-secret">Client Secret</Table.th>,<Table.th key="created-at">Created at</Table.th>,<Table.th key="delete-action"></Table.th>,]}@@ -235,7 +240,7 @@ const OAuthApps = () => {</div></ScaffoldContainerLegacy>- <PublishAppModal+ <PublishAppSidePanelvisible={showPublishModal}selectedApp={selectedAppToUpdate}onClose={() => {diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/OAuthSecrets.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/OAuthSecrets.tsxnew file mode 100644index 00000000000..9026e2d63d1--- /dev/null+++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/OAuthSecrets.tsx@@ -0,0 +1,92 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'+import { useState } from 'react'++import { useParams } from 'common'+import { ButtonTooltip } from 'components/ui/ButtonTooltip'+import { InlineLink } from 'components/ui/InlineLink'+import { useClientSecretCreateMutation } from 'data/oauth-secrets/client-secret-create-mutation'+import { CreatedSecret, useClientSecretsQuery } from 'data/oauth-secrets/client-secrets-query'+import { OAuthApp } from 'data/oauth/oauth-apps-query'+import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'+import { Alert_Shadcn_, AlertTitle_Shadcn_, InfoIcon } from 'ui'+import { SecretRow } from './SecretRow'++interface Props {+ selectedApp?: OAuthApp+}++export const OAuthSecrets = ({ selectedApp }: Props) => {+ const { slug } = useParams()+ const [createdSecret, setCreatedSecret] = useState<CreatedSecret>()+ const canManageSecrets = useCheckPermissions(PermissionAction.UPDATE, 'oauth_apps')++ const { id: appId } = selectedApp ?? {}++ const { data } = useClientSecretsQuery({ slug, appId })+ const secrets = data?.client_secrets ?? []++ const { mutate: createSecret, isLoading: isCreatingSecret } = useClientSecretCreateMutation({+ onSuccess: (data) => setCreatedSecret(data),+ })++ const handleCreateSecret = () => {+ if (!slug) return console.error('Slug is required')+ if (!appId) return console.error('App ID is required')+ createSecret({ slug, appId })+ }++ return (+ <div className="flex flex-col gap-4">+ <div className="flex items-center justify-between">+ <div className="flex flex-col">+ <span className="text-sm text-foreground">Client secrets</span>+ <span className="text-sm text-foreground-light">+ For handling callbacks in the OAuth 2.0 flow. Learn more{' '}+ <InlineLink href="https://supabase.com/docs/guides/integrations/build-a-supabase-integration#handling-the-callback">+ here+ </InlineLink>+ .+ </span>+ </div>++ {canManageSecrets && (+ <ButtonTooltip+ type="default"+ disabled={!appId || secrets.length >= 5}+ onClick={handleCreateSecret}+ loading={isCreatingSecret}+ tooltip={{+ content: {+ side: 'bottom',+ text: secrets.length >= 5 ? 'You can only have up to 5 client secrets' : undefined,+ },+ }}+ >+ Generate new secret+ </ButtonTooltip>+ )}+ </div>++ {createdSecret && (+ <Alert_Shadcn_ variant="default">+ <InfoIcon />+ <AlertTitle_Shadcn_>+ Make sure to copy your new client secret now. You won't be able to see it again.+ </AlertTitle_Shadcn_>+ </Alert_Shadcn_>+ )}++ <div className="-space-y-px">+ {secrets+ .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())+ .map((secret) => {+ const isNew = createdSecret?.id === secret.id+ const _secret = isNew+ ? { ...secret, client_secret: createdSecret.client_secret }+ : secret+ return <SecretRow key={secret.id} secret={_secret} appId={appId} />+ })}+ </div>+ </div>+ )+}diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/SecretRow.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/SecretRow.tsxnew file mode 100644index 00000000000..f17a280cde7--- /dev/null+++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/SecretRow.tsx@@ -0,0 +1,125 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'+import dayjs from 'dayjs'+import { Check, Key, Trash } from 'lucide-react'+import { useState } from 'react'+import { toast } from 'sonner'++import { useParams } from 'common'+import { ButtonTooltip } from 'components/ui/ButtonTooltip'+import CopyButton from 'components/ui/CopyButton'+import { useClientSecretDeleteMutation } from 'data/oauth-secrets/client-secret-delete-mutation'+import { Secret, useClientSecretsQuery } from 'data/oauth-secrets/client-secrets-query'+import { useOrganizationMembersQuery } from 'data/organizations/organization-members-query'+import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'+import { cn } from 'ui'+import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'++export interface SecretRowProps {+ secret: Secret+ appId?: string+}++export const SecretRow = ({ secret, appId }: SecretRowProps) => {+ const { slug } = useParams()+ const [showDeleteModal, setShowDeleteModal] = useState(false)+ const canManageSecrets = useCheckPermissions(PermissionAction.UPDATE, 'oauth_apps')++ const { data } = useClientSecretsQuery({ slug, appId })+ const secrets = data?.client_secrets ?? []+ const isLast = secrets.length === 1++ const { data: members = [] } = useOrganizationMembersQuery({ slug })+ const generatedBy = members.find((x) => x.gotrue_id === secret.created_by)+ const generatedByName = generatedBy?.username ?? generatedBy?.primary_email ?? secret.created_by++ const { mutate: deleteSecret, isLoading: isDeleting } = useClientSecretDeleteMutation({+ onSuccess: () => {+ // Show success toast and close modal after successful deletion+ toast.success('Successfully deleted client secret')+ setShowDeleteModal(false)+ },+ })++ const handleDelete = () => {+ if (!slug) return console.error('Slug is required')+ if (!appId) return console.error('App ID is required')+ deleteSecret({ slug, appId, secretId: secret.id })+ }++ const isNew = secret.client_secret !== undefined++ return (+ <>+ <div+ className={cn(+ 'flex items-center justify-between p-4 border first:rounded-t last:rounded-b',+ isNew && 'bg-background-alternative'+ )}+ >+ <div className="flex flex-row gap-6 items-center">+ <Key size={16} strokeWidth={2} />+ <div className="flex flex-col gap-1">+ <div className="flex items-center gap-2">+ <div className="flex items-center gap-2">+ {isNew && <Check size={14} className="text-brand" strokeWidth={3} />}+ <p className="font-mono text-sm">+ {isNew ? secret.client_secret : `${secret.client_secret_alias}${'*'.repeat(36)}`}+ </p>+ {isNew && secret.client_secret && (+ <CopyButton text={secret.client_secret} type="default" iconOnly />+ )}+ </div>+ </div>+ <div className="flex flex-col gap-0">+ <p className="text-sm text-foreground-lighter">+ Added {isNew ? 'now' : dayjs(secret.created_at).fromNow()} by {generatedByName}+ </p>+ </div>+ </div>+ </div>+ <div className="flex items-center gap-2">+ <ButtonTooltip+ type="default"+ className="w-7"+ icon={<Trash />}+ disabled={!appId || !canManageSecrets || isLast}+ onClick={() => setShowDeleteModal(true)}+ tooltip={{+ content: {+ className: 'w-64 text-center',+ side: 'bottom',+ text: !canManageSecrets+ ? 'You need additional permissions to delete client secrets'+ : isLast+ ? 'You must have at least one client secret for the OAuth application to function.'+ : undefined,+ },+ }}+ />+ </div>+ </div>++ <ConfirmationModal+ visible={showDeleteModal}+ variant="destructive"+ title="Confirm to delete client secret"+ confirmLabel="Delete"+ confirmLabelLoading="Deleting"+ loading={isDeleting}+ onCancel={() => setShowDeleteModal(false)}+ onConfirm={handleDelete}+ disabled={isLast}+ alert={{+ title: 'This action cannot be undone',+ description: 'The client secret will be permanently removed and cannot be recovered.',+ }}+ >+ <p className="text-sm text-foreground-light">+ {isLast+ ? 'The last client secret cannot be deleted. Please generate a new secret before deleting this one.'+ : 'Are you sure you want to delete this client secret?'}+ </p>+ </ConfirmationModal>+ </>+ )+}diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/Scopes.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/Scopes.tsxindex 4e82c3db006..7bdf9dd0231 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/Scopes.tsx+++ b/apps/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/Scopes.tsx@@ -1,6 +1,7 @@import { OAuthScope } from '@supabase/shared-types/out/constants'import { ChevronDown } from 'lucide-react'import { Dispatch, PropsWithChildren, SetStateAction } from 'react'+import {Button,DropdownMenu,diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/index.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/index.tsxindex 984c74018f6..81c278cce61 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/index.tsx+++ b/apps/studio/components/interfaces/Organization/OAuthApps/PublishAppSidePanel/index.tsx@@ -27,6 +27,7 @@ import {cn,} from 'ui'import AuthorizeRequesterDetails from '../AuthorizeRequesterDetails'+import { OAuthSecrets } from '../OAuthSecrets/OAuthSecrets'import { ScopesPanel } from './Scopes'export interface PublishAppSidePanelProps {@@ -36,7 +37,7 @@ export interface PublishAppSidePanelProps {onCreateSuccess: (app: OAuthAppCreateResponse) => void}-const PublishAppSidePanel = ({+export const PublishAppSidePanel = ({visible,selectedApp,onClose,@@ -44,6 +45,7 @@ const PublishAppSidePanel = ({}: PublishAppSidePanelProps) => {const { slug } = useParams()const uploadButtonRef = useRef<any>()+const { mutate: createOAuthApp } = useOAuthAppCreateMutation({onSuccess: (res, variables) => {toast.success(`Successfully created OAuth app "${variables.name}"!`)@@ -57,7 +59,7 @@ const PublishAppSidePanel = ({},})const { mutate: updateOAuthApp } = useOAuthAppUpdateMutation({- onSuccess: (res, variables) => {+ onSuccess: (_, variables) => {toast.success(`Successfully updated OAuth app "${variables.name}"!`)onClose()setIsSubmitting(false)@@ -172,246 +174,254 @@ const PublishAppSidePanel = ({}return (- <>- <SidePanel- hideFooter- size="large"- visible={visible}- header={- selectedApp !== undefined ? 'Update OAuth application' : 'Publish a new OAuth application'- }- onCancel={() => onClose()}+ <SidePanel+ hideFooter+ size="large"+ visible={visible}+ header={+ selectedApp !== undefined ? 'Update OAuth application' : 'Publish a new OAuth application'+ }+ onCancel={() => onClose()}+ >+ <Form+ validateOnBlur+ className="h-full"+ initialValues={{ name: '', website: '' }}+ validate={validate}+ onSubmit={onSubmit}>- <Form- validateOnBlur- className="h-full"- initialValues={{ name: '', website: '' }}- validate={validate}- onSubmit={onSubmit}- >- {({ resetForm, values }: { resetForm: any; values: any }) => {- // [Joshen] although this "technically" is breaking the rules of React hooks- // it won't error because the hooks are always rendered in the same order- // eslint-disable-next-line react-hooks/rules-of-hooks- useEffect(() => {- if (visible && selectedApp !== undefined) {- const values = { name: selectedApp.name, website: selectedApp.website }- resetForm({ values, initialValues: values })- }- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [visible, selectedApp])+ {({ resetForm, values }: { resetForm: any; values: any }) => {+ // [Joshen] although this "technically" is breaking the rules of React hooks+ // it won't error because the hooks are always rendered in the same order+ // eslint-disable-next-line react-hooks/rules-of-hooks+ useEffect(() => {+ if (visible && selectedApp !== undefined) {+ const values = { name: selectedApp.name, website: selectedApp.website }+ resetForm({ values, initialValues: values })+ }+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [visible, selectedApp])- return (- <>- <div className="h-full flex flex-col">- <div className="flex-grow">- <SidePanel.Content>- <div className="py-4 flex items-start justify-between gap-10">- <div className="space-y-4 w-full">- <Input- id="name"- label="Application name"- descriptionText={selectedApp?.id && `ID: ${selectedApp.id}`}- />- <Input- id="website"- label="Website URL"- placeholder="https://my-website.com"- />- </div>- <div>- {iconUrl !== undefined ? (- <div- className={cn(- 'shadow transition group relative',- 'bg-center bg-cover bg-no-repeat',- 'mt-4 mr-4 space-y-2 rounded-full h-[120px] w-[120px] flex flex-col items-center justify-center'- )}- style={{- backgroundImage: iconUrl ? `url("${iconUrl}")` : 'none',- }}- >- <div className="absolute bottom-1 right-1">- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button type="default" className="px-1">- <Edit />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end" side="bottom">- <DropdownMenuItem- key="upload"- onClick={() => {- if (uploadButtonRef.current)- (uploadButtonRef.current as any).click()- }}- >- <p>Upload image</p>- </DropdownMenuItem>- <DropdownMenuItem- key="remove"- onClick={() => {- setIconFile(undefined)- setIconUrl(undefined)- }}- >- <p>Remove image</p>- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- </div>- </div>- ) : (- <div- className={cn(- 'border border-strong transition opacity-75 hover:opacity-100',- 'mt-4 mr-4 space-y-2 rounded-full h-[120px] w-[120px] flex flex-col items-center justify-center cursor-pointer'- )}- onClick={() => {- if (uploadButtonRef.current)- (uploadButtonRef.current as any).click()- }}- >- <Upload size={18} strokeWidth={1.5} className="text-foreground" />- <p className="text-xs text-foreground-light">Upload logo</p>- </div>- )}- <input- multiple- type="file"- ref={uploadButtonRef}- className="hidden"- accept="image/png, image/jpeg"- onChange={onFileUpload}- />- </div>- </div>- </SidePanel.Content>-- <SidePanel.Separator />-- <SidePanel.Content className="py-4">- <div className="mb-2 flex items-center justify-between">- <div>- <p className="prose text-sm">Authorization callback URLs</p>- <p className="text-sm text-foreground-light">- All URLs must use HTTPS, except for localhost- </p>- </div>- <Button onClick={() => setUrls(urls.concat({ id: uuidv4(), value: '' }))}>- Add URL- </Button>- </div>- <div className="space-y-2 pb-2">- {urls.map((url) => (- <Input- key={url.id}- value={url.value}- onChange={(event) => onUpdateUrl(url.id, event.target.value)}- placeholder="e.g https://my-website.com"- actions={[- urls.length > 1 ? (- <Button- key="remove-url"- type="default"- onClick={() => removeUrl(url.id)}- >- Remove- </Button>- ) : null,- ]}- />- ))}- {errors.urls && <p className="text-red-900 text-sm">{errors.urls}</p>}+ return (+ <>+ <div className="h-full flex flex-col">+ <div className="flex-grow">+ <SidePanel.Content>+ <div className="py-4 flex items-start justify-between gap-10">+ <div className="space-y-4 w-full">+ <Input+ id="name"+ label="Application name"+ descriptionText={selectedApp?.id && `ID: ${selectedApp.id}`}+ />+ <Input+ id="website"+ label="Website URL"+ placeholder="https://my-website.com"+ /></div>- </SidePanel.Content>- <SidePanel.Separator />- <div className="p-6 ">- <div className="flex items-start justify-between space-x-4 pb-4">- <div className="flex flex-col">- <span className="prose text-sm">Application permissions</span>- <span className="text-sm text-foreground-light">- The application permissions are organized in scopes and will be- presented to the user when adding an app to their organization and all- of its projects.- </span>- </div>- <DocsButton href="https://supabase.com/docs/guides/platform/oauth-apps/oauth-scopes" />+ <div>+ {iconUrl !== undefined ? (+ <div+ className={cn(+ 'shadow transition group relative',+ 'bg-center bg-cover bg-no-repeat',+ 'mt-4 mr-4 space-y-2 rounded-full h-[120px] w-[120px] flex flex-col items-center justify-center'+ )}+ style={{+ backgroundImage: iconUrl ? `url("${iconUrl}")` : 'none',+ }}+ >+ <div className="absolute bottom-1 right-1">+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button type="default" className="px-1">+ <Edit />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" side="bottom">+ <DropdownMenuItem+ key="upload"+ onClick={() => {+ if (uploadButtonRef.current)+ (uploadButtonRef.current as any).click()+ }}+ >+ <p>Upload image</p>+ </DropdownMenuItem>+ <DropdownMenuItem+ key="remove"+ onClick={() => {+ setIconFile(undefined)+ setIconUrl(undefined)+ }}+ >+ <p>Remove image</p>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </div>+ </div>+ ) : (+ <div+ className={cn(+ 'border border-strong transition opacity-75 hover:opacity-100',+ 'mt-4 mr-4 space-y-2 rounded-full h-[120px] w-[120px] flex flex-col items-center justify-center cursor-pointer'+ )}+ onClick={() => {+ if (uploadButtonRef.current) (uploadButtonRef.current as any).click()+ }}+ >+ <Upload size={18} strokeWidth={1.5} className="text-foreground" />+ <p className="text-xs text-foreground-light">Upload logo</p>+ </div>+ )}+ <input+ multiple+ type="file"+ ref={uploadButtonRef}+ className="hidden"+ accept="image/png, image/jpeg"+ onChange={onFileUpload}+ /></div>-- <ScopesPanel scopes={scopes} setScopes={setScopes} /></div>- </div>+ </SidePanel.Content><SidePanel.Separator />- <SidePanel.Content>- <div className="pt-2 pb-3 flex items-center justify-between">+ <SidePanel.Content className="py-4">+ <div className="mb-2 flex items-center justify-between">+ <div>+ <p className="text-foreground text-sm">Authorization callback URLs</p>+ <p className="text-sm text-foreground-light">+ All URLs must use HTTPS, except for localhost+ </p>+ </div><Buttontype="default"- onClick={() => setShowPreview(true)}- disabled={values.name.length === 0 || values.website.length === 0}+ onClick={() => setUrls(urls.concat({ id: uuidv4(), value: '' }))}>- Preview consent for users+ Add URL</Button>- <div className="flex items-center space-x-2">- <Button type="default" disabled={isSubmitting} onClick={() => onClose()}>- Cancel- </Button>- <Button htmlType="submit" loading={isSubmitting} disabled={isSubmitting}>- Confirm- </Button>- </div>+ </div>+ <div className="space-y-2 pb-2">+ {urls.map((url) => (+ <Input+ key={url.id}+ value={url.value}+ onChange={(event) => onUpdateUrl(url.id, event.target.value)}+ placeholder="e.g https://my-website.com"+ actions={[+ urls.length > 1 ? (+ <Button+ key="remove-url"+ type="default"+ onClick={() => removeUrl(url.id)}+ >+ Remove+ </Button>+ ) : null,+ ]}+ />+ ))}+ {errors.urls && <p className="text-red-900 text-sm">{errors.urls}</p>}</div></SidePanel.Content>- </div>- <Modal- hideFooter- className="!max-w-[600px]"- visible={showPreview}- onCancel={() => setShowPreview(false)}- >- <Modal.Content>- <div className="flex items-center justify-between">- <p>Authorize API access for {values.name}</p>- <Badge variant="brand">Preview</Badge>- </div>- </Modal.Content>- <Modal.Separator />- <Modal.Content>- <AuthorizeRequesterDetails- icon={iconUrl || null}- name={values.name}- domain={values.website}- scopes={scopes}- />- <div className="pt-4 space-y-2">- <p className="prose text-sm">Select an organization to grant API access to</p>- <div className="border border-control text-foreground-light rounded px-4 py-2 text-sm bg-surface-200">- Organizations that you have access to will be listed here+ {selectedApp !== undefined && (+ <>+ <SidePanel.Separator />+ <SidePanel.Content className="py-4">+ <OAuthSecrets selectedApp={selectedApp} />+ </SidePanel.Content>+ </>+ )}++ <SidePanel.Separator />+ <div className="p-6 ">+ <div className="flex items-start justify-between space-x-4 pb-4">+ <div className="flex flex-col">+ <span className="text-sm text-foreground">Application permissions</span>+ <span className="text-sm text-foreground-light">+ The application permissions are organized in scopes and will be presented+ to the user when adding an app to their organization and all of its+ projects.+ </span></div>+ <DocsButton href="https://supabase.com/docs/guides/platform/oauth-apps/oauth-scopes" /></div>- </Modal.Content>- <Modal.Separator />- <Modal.Content>- <div className="flex items-center justify-between">- <p className="prose text-xs">- This is what your users will see when authorizing with your app- </p>- <Button type="default" onClick={() => setShowPreview(false)}>- Close++ <ScopesPanel scopes={scopes} setScopes={setScopes} />+ </div>+ </div>++ <SidePanel.Separator />++ <SidePanel.Content>+ <div className="pt-2 pb-3 flex items-center justify-between">+ <Button+ type="default"+ onClick={() => setShowPreview(true)}+ disabled={values.name.length === 0 || values.website.length === 0}+ >+ Preview consent for users+ </Button>+ <div className="flex items-center space-x-2">+ <Button type="default" disabled={isSubmitting} onClick={() => onClose()}>+ Cancel</Button>+ <Button htmlType="submit" loading={isSubmitting} disabled={isSubmitting}>+ Confirm+ </Button>+ </div>+ </div>+ </SidePanel.Content>+ </div>++ <Modal+ hideFooter+ className="!max-w-[600px]"+ visible={showPreview}+ onCancel={() => setShowPreview(false)}+ >+ <Modal.Content>+ <div className="flex items-center justify-between">+ <p>Authorize API access for {values.name}</p>+ <Badge variant="brand">Preview</Badge>+ </div>+ </Modal.Content>+ <Modal.Separator />+ <Modal.Content>+ <AuthorizeRequesterDetails+ icon={iconUrl || null}+ name={values.name}+ domain={values.website}+ scopes={scopes}+ />+ <div className="pt-4 space-y-2">+ <p className="prose text-sm">Select an organization to grant API access to</p>+ <div className="border border-control text-foreground-light rounded px-4 py-2 text-sm bg-surface-200">+ Organizations that you have access to will be listed here</div>- </Modal.Content>- </Modal>- </>- )- }}- </Form>- </SidePanel>- </>+ </div>+ </Modal.Content>+ <Modal.Separator />+ <Modal.Content>+ <div className="flex items-center justify-between">+ <p className="prose text-xs">+ This is what your users will see when authorizing with your app+ </p>+ <Button type="default" onClick={() => setShowPreview(false)}>+ Close+ </Button>+ </div>+ </Modal.Content>+ </Modal>+ </>+ )+ }}+ </Form>+ </SidePanel>)}--export default PublishAppSidePaneldiff --git a/apps/studio/components/interfaces/Organization/OAuthApps/RevokeAppModal.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/RevokeAppModal.tsxindex 8913dabe0d7..77cd6af192f 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/RevokeAppModal.tsx+++ b/apps/studio/components/interfaces/Organization/OAuthApps/RevokeAppModal.tsx@@ -12,7 +12,7 @@ export interface RevokeAppModalProps {onClose: () => void}-const RevokeAppModal = ({ selectedApp, onClose }: RevokeAppModalProps) => {+export const RevokeAppModal = ({ selectedApp, onClose }: RevokeAppModalProps) => {const { slug } = useParams()const { mutate: revokeAuthorizedApp, isLoading: isDeleting } = useAuthorizedAppRevokeMutation({onSuccess: () => {@@ -64,5 +64,3 @@ const RevokeAppModal = ({ selectedApp, onClose }: RevokeAppModalProps) => {</Modal>)}--export default RevokeAppModaldiff --git a/apps/studio/data/oauth-secrets/client-secret-create-mutation.ts b/apps/studio/data/oauth-secrets/client-secret-create-mutation.tsnew file mode 100644index 00000000000..186ac5f8795--- /dev/null+++ b/apps/studio/data/oauth-secrets/client-secret-create-mutation.ts@@ -0,0 +1,49 @@+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'+import { handleError, post } from 'data/fetchers'+import { toast } from 'sonner'+import { ResponseError } from 'types'+import { clientSecretKeys } from './keys'++export type ClientSecretCreateVariables = {+ slug: string+ appId: string+}++export async function createClientSecret({ slug, appId }: ClientSecretCreateVariables) {+ const { data, error } = await post(+ '/platform/organizations/{slug}/oauth/apps/{app_id}/client-secrets',+ { params: { path: { slug, app_id: appId } } }+ )+ if (error) handleError(error)+ return data+}++export const useClientSecretCreateMutation = ({+ onSuccess,+ onError,+ ...options+}: Omit<+ UseMutationOptions<any, ResponseError, ClientSecretCreateVariables>,+ 'mutationFn'+> = {}) => {+ const queryClient = useQueryClient()++ return useMutation<any, ResponseError, ClientSecretCreateVariables>(+ (vars) => createClientSecret(vars),+ {+ async onSuccess(data, variables, context) {+ const { slug, appId } = variables+ await queryClient.invalidateQueries(clientSecretKeys.list(slug, appId))+ await onSuccess?.(data, variables, context)+ },+ async onError(data, variables, context) {+ if (onError === undefined) {+ toast.error(`Failed to create client secret: ${data.message}`)+ } else {+ onError(data, variables, context)+ }+ },+ ...options,+ }+ )+}diff --git a/apps/studio/data/oauth-secrets/client-secret-delete-mutation.ts b/apps/studio/data/oauth-secrets/client-secret-delete-mutation.tsnew file mode 100644index 00000000000..caea1911d1b--- /dev/null+++ b/apps/studio/data/oauth-secrets/client-secret-delete-mutation.ts@@ -0,0 +1,50 @@+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'+import { del, handleError } from 'data/fetchers'+import { toast } from 'sonner'+import { ResponseError } from 'types'+import { clientSecretKeys } from './keys'++export type ClientSecretDeleteVariables = {+ slug: string+ appId: string+ secretId: string+}++export async function deleteClientSecret({ slug, appId, secretId }: ClientSecretDeleteVariables) {+ const { error } = await del(+ '/platform/organizations/{slug}/oauth/apps/{app_id}/client-secrets/{secret_id}',+ { params: { path: { slug, app_id: appId, secret_id: secretId } } }+ )+ if (error) handleError(error)+ return true+}++export const useClientSecretDeleteMutation = ({+ onSuccess,+ onError,+ ...options+}: Omit<+ UseMutationOptions<boolean, ResponseError, ClientSecretDeleteVariables>,+ 'mutationFn'+> = {}) => {+ const queryClient = useQueryClient()++ return useMutation<boolean, ResponseError, ClientSecretDeleteVariables>(+ (vars) => deleteClientSecret(vars),+ {+ async onSuccess(data, variables, context) {+ const { slug, appId } = variables+ await queryClient.invalidateQueries(clientSecretKeys.list(slug, appId))+ await onSuccess?.(data, variables, context)+ },+ async onError(data, variables, context) {+ if (onError === undefined) {+ toast.error(`Failed to delete client secret: ${data.message}`)+ } else {+ onError(data, variables, context)+ }+ },+ ...options,+ }+ )+}diff --git a/apps/studio/data/oauth-secrets/client-secrets-query.ts b/apps/studio/data/oauth-secrets/client-secrets-query.tsnew file mode 100644index 00000000000..a07ea96e1b8--- /dev/null+++ b/apps/studio/data/oauth-secrets/client-secrets-query.ts@@ -0,0 +1,61 @@+import { useQuery, UseQueryOptions } from '@tanstack/react-query'++import { get, handleError } from 'data/fetchers'+import { ResponseError } from 'types'+import { clientSecretKeys } from './keys'++import { components } from 'api-types'++export type Secret =+ components['schemas']['ListOAuthAppClientSecretsResponseDto']['client_secrets'][0] & {+ client_secret?: components['schemas']['CreateOAuthAppClientSecretResponseDto']['client_secret']+ }++export type CreatedSecret = components['schemas']['CreateOAuthAppClientSecretResponseDto']++export interface SecretRowProps {+ secret: Secret+ appId?: string+ isNew?: boolean+}++type ClientSecretsVariables = {+ slug?: string+ appId?: string+}++export async function getClientSecrets(+ { slug, appId }: ClientSecretsVariables,+ signal?: AbortSignal+) {+ if (!slug) throw new Error('slug is required')+ if (!appId) throw new Error('appId is required')++ const { data, error } = await get(+ '/platform/organizations/{slug}/oauth/apps/{app_id}/client-secrets',+ {+ params: {+ path: { slug, app_id: appId },+ },+ signal,+ }+ )+ if (error) handleError(error)+ return data+}++export type ClientSecretsData = Awaited<ReturnType<typeof getClientSecrets>>+export type ClientSecretsError = ResponseError++export const useClientSecretsQuery = <TData = ClientSecretsData>(+ { slug, appId }: ClientSecretsVariables,+ { enabled = true, ...options }: UseQueryOptions<ClientSecretsData, ClientSecretsError, TData> = {}+) =>+ useQuery<ClientSecretsData, ClientSecretsError, TData>(+ clientSecretKeys.list(slug, appId),+ ({ signal }) => getClientSecrets({ slug, appId }, signal),+ {+ enabled: enabled && typeof slug !== 'undefined' && typeof appId !== 'undefined',+ ...options,+ }+ )diff --git a/apps/studio/data/oauth-secrets/keys.ts b/apps/studio/data/oauth-secrets/keys.tsnew file mode 100644index 00000000000..23b016fc036--- /dev/null+++ b/apps/studio/data/oauth-secrets/keys.ts@@ -0,0 +1,4 @@+export const clientSecretKeys = {+ list: (slug: string | undefined, appId: string | undefined) =>+ ['organizations', slug, 'oauth', 'apps', appId, 'client-secrets'] as const,+}diff --git a/apps/studio/data/projects/new-project.constants.ts b/apps/studio/data/projects/new-project.constants.tsindex aad9488de61..5eab2c5ff57 100644--- a/apps/studio/data/projects/new-project.constants.ts+++ b/apps/studio/data/projects/new-project.constants.ts@@ -14,6 +14,16 @@ export const instanceSizeSpecs: Record<cloud_providers: string[]}> = {+ // [Joshen] Just to fix the TS error since this size is now expected+ // Unsure the parameters here, so leaving cloud_providers blank for now to prevent it from showing up in new project page+ pico: {+ label: 'Pico',+ ram: '',+ cpu: '',+ priceHourly: 0,+ priceMonthly: 0,+ cloud_providers: [],+ },micro: {label: 'Micro',ram: '1 GB',diff --git a/packages/api-types/types/platform.d.ts b/packages/api-types/types/platform.d.tsindex d51b36dfa0e..cdc08c531ba 100644--- a/packages/api-types/types/platform.d.ts+++ b/packages/api-types/types/platform.d.ts@@ -1251,6 +1251,41 @@ export interface paths {patch?: nevertrace?: never}+ '/platform/organizations/{slug}/oauth/apps/{app_id}/client-secrets': {+ parameters: {+ query?: never+ header?: never+ path?: never+ cookie?: never+ }+ /** List oauth app client secrets */+ get: operations['OAuthAppClientSecretsController_listClientSecrets']+ put?: never+ /** Create oauth app client secret */+ post: operations['OAuthAppClientSecretsController_CreateClientSecret']+ delete?: never+ options?: never+ head?: never+ patch?: never+ trace?: never+ }+ '/platform/organizations/{slug}/oauth/apps/{app_id}/client-secrets/{secret_id}': {+ parameters: {+ query?: never+ header?: never+ path?: never+ cookie?: never+ }+ get?: never+ put?: never+ post?: never+ /** Remove oauth app client secret */+ delete: operations['OAuthAppClientSecretsController_RemoveClientSecret']+ options?: never+ head?: never+ patch?: never+ trace?: never+ }'/platform/organizations/{slug}/oauth/apps/{id}': {parameters: {query?: never@@ -4436,6 +4471,18 @@ export interface components {)[]website: string}+ CreateOAuthAppClientSecretResponseDto: {+ client_secret: string+ client_secret_alias: string+ /** Format: date-time */+ created_at: string+ /** Format: uuid */+ created_by: string+ /** Format: uuid */+ id: string+ /** Format: uuid */+ oauth_app_id: string+ }CreateOAuthAppResponse: {client_id: stringclient_secret: string@@ -4794,6 +4841,7 @@ export interface components {}/** @enum {string} */DesiredInstanceSize:+ | 'pico'| 'micro'| 'small'| 'medium'@@ -5602,6 +5650,19 @@ export interface components {project_ref: string}[]}+ ListOAuthAppClientSecretsResponseDto: {+ client_secrets: {+ client_secret_alias: string+ /** Format: date-time */+ created_at: string+ /** Format: uuid */+ created_by: string+ /** Format: uuid */+ id: string+ /** Format: uuid */+ oauth_app_id: string+ }[]+ }LoadBalancerDetailResponse: {databases: {identifier: string@@ -6802,9 +6863,7 @@ export interface components {redirectTo?: string}StorageBucketResponse: {- allowed_mime_types?: string[]created_at: string- file_size_limit?: numberid: stringname: stringowner: string@@ -6829,9 +6888,7 @@ export interface components {StorageObject: {bucket_id: stringbuckets: {- allowed_mime_types?: string[]created_at: string- file_size_limit?: numberid: stringname: stringowner: string@@ -7436,8 +7493,8 @@ export interface components {message: string}UpdateStorageBucketBody: {- allowed_mime_types?: string[] | null- file_size_limit?: number | null+ allowed_mime_types?: string[]+ file_size_limit?: numberpublic: boolean}UpdateStorageConfigBody: {@@ -10577,6 +10634,89 @@ export interface operations {}}}+ OAuthAppClientSecretsController_listClientSecrets: {+ parameters: {+ query?: never+ header?: never+ path: {+ app_id: string+ slug: string+ }+ cookie?: never+ }+ requestBody?: never+ responses: {+ 200: {+ headers: {+ [name: string]: unknown+ }+ content: {+ 'application/json': components['schemas']['ListOAuthAppClientSecretsResponseDto']+ }+ }+ 403: {+ headers: {+ [name: string]: unknown+ }+ content?: never+ }+ }+ }+ OAuthAppClientSecretsController_CreateClientSecret: {+ parameters: {+ query?: never+ header?: never+ path: {+ app_id: string+ slug: string+ }+ cookie?: never+ }+ requestBody?: never+ responses: {+ 201: {+ headers: {+ [name: string]: unknown+ }+ content: {+ 'application/json': components['schemas']['CreateOAuthAppClientSecretResponseDto']+ }+ }+ 403: {+ headers: {+ [name: string]: unknown+ }+ content?: never+ }+ }+ }+ OAuthAppClientSecretsController_RemoveClientSecret: {+ parameters: {+ query?: never+ header?: never+ path: {+ app_id: string+ secret_id: string+ slug: string+ }+ cookie?: never+ }+ requestBody?: never+ responses: {+ 200: {+ headers: {+ [name: string]: unknown+ }+ content?: never+ }+ 403: {+ headers: {+ [name: string]: unknown+ }+ content?: never+ }+ }+ }OAuthAppsController_updateOAuthApp: {parameters: {query?: never