mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Problem The OAuth apps consent screen does not allow users to change the selected org. If the calling app didn't provide the org slug, we select the first available org from the users orgs. ## Solution Add an organization selector: <img width="436" height="570" alt="image" src="https://github.com/user-attachments/assets/a5579f2c-ff54-4d02-9d4a-ac75ed245719" /> ## Review instructions Requirements: - have multiple orgs - have a published app that needs projects selection and at least one authorization already granted - have the oauth example app ready Tests: - authorizing the app again on the same org it was before should preselect the projects - you should be able to select another org and if you do, that should clear the selected projects and you should see only this org projects in the options - reselecting the initially granted org should reselect the projects it had in the existing grant
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { createFileRoute, useNavigate } from '@tanstack/react-router'
|
|
import { useFlag, useParams } from 'common'
|
|
|
|
import { ApiAuthorizationScreen } from '@/components/interfaces/ApiAuthorization/ApiAuthorization'
|
|
import { OAuthAppsAuthorizeScreen } from '@/components/interfaces/Organization/OAuthApps/Consent'
|
|
import { withAuth } from '@/hooks/misc/withAuth'
|
|
import { buildStudioPageTitle } from '@/lib/page-title'
|
|
|
|
export const Route = createFileRoute('/authorize')({
|
|
component: Authorize,
|
|
})
|
|
|
|
function Authorize() {
|
|
return <APIAuthorizationPageWithAuth />
|
|
}
|
|
|
|
const PAGE_TITLE = buildStudioPageTitle({ section: 'Authorize API Access', brand: 'Supabase' })
|
|
|
|
function APIAuthorizationPage() {
|
|
const navigate = useNavigate()
|
|
const { auth_id, organization_slug, project_ref } = useParams()
|
|
const isScopedOAuthConsentEnabled = useFlag('enableScopedOAuthConsent')
|
|
|
|
if (isScopedOAuthConsentEnabled) {
|
|
return (
|
|
<>
|
|
<title>{PAGE_TITLE}</title>
|
|
<OAuthAppsAuthorizeScreen
|
|
key={`${auth_id}_${organization_slug ?? ''}_${project_ref ?? ''}`}
|
|
authId={auth_id}
|
|
organizationSlug={organization_slug}
|
|
projectRef={organization_slug && project_ref ? project_ref : undefined}
|
|
/>
|
|
</>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<title>{PAGE_TITLE}</title>
|
|
<ApiAuthorizationScreen
|
|
auth_id={auth_id}
|
|
organization_slug={organization_slug}
|
|
navigate={(destination) => void navigate({ href: destination })}
|
|
/>
|
|
</>
|
|
)
|
|
}
|
|
|
|
const APIAuthorizationPageWithAuth = withAuth(APIAuthorizationPage)
|