mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
> [!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>
215 lines
7.4 KiB
TypeScript
215 lines
7.4 KiB
TypeScript
import { useIntersectionObserver } from '@uidotdev/usehooks'
|
|
import { components } from 'api-types'
|
|
import { useEffect, useId } from 'react'
|
|
import { cn, RadioGroup, RadioGroupItem } from 'ui'
|
|
import {
|
|
MultiSelector,
|
|
MultiSelectorContent,
|
|
MultiSelectorInput,
|
|
MultiSelectorItem,
|
|
MultiSelectorList,
|
|
MultiSelectorTrigger,
|
|
} from 'ui-patterns/multi-select'
|
|
|
|
import type { OAuthDatabaseAccessReadiness } from '@/data/oauth-apps/oauth-apps-database-access-readiness-query'
|
|
|
|
export const MAX_SELECTED_PROJECTS = 10
|
|
|
|
export interface ProjectMultiSelectProps {
|
|
projects: components['schemas']['OrganizationProjectsResponse_Output']['projects']
|
|
selectedProjectRefs: string[]
|
|
selectedProjects: components['schemas']['OrganizationProjectsResponse_Output']['projects']
|
|
onChange: (selectedProjects: string[]) => void
|
|
maxSelected?: number
|
|
error?: string
|
|
flaggedRefs?: string[]
|
|
unavailableRefs?: string[]
|
|
readinessIssues?: Partial<Record<string, OAuthDatabaseAccessReadiness>>
|
|
allProjectsSelected?: boolean
|
|
onAllProjectsChange?: (selected: boolean) => void
|
|
onSearchChange: (query: string) => void
|
|
onLoadMore: () => void
|
|
}
|
|
|
|
export const ProjectMultiSelect = ({
|
|
projects,
|
|
selectedProjects,
|
|
selectedProjectRefs,
|
|
onChange,
|
|
maxSelected = MAX_SELECTED_PROJECTS,
|
|
error,
|
|
flaggedRefs = [],
|
|
unavailableRefs = [],
|
|
readinessIssues = {},
|
|
allProjectsSelected = false,
|
|
onAllProjectsChange,
|
|
onSearchChange,
|
|
onLoadMore,
|
|
}: ProjectMultiSelectProps) => {
|
|
const labelId = useId()
|
|
const hasFlagged = flaggedRefs.length > 0
|
|
const atCap = selectedProjects.length >= maxSelected
|
|
const showCounter = selectedProjects.length >= maxSelected - 2
|
|
const [sentinelRef, entry] = useIntersectionObserver({
|
|
threshold: 0,
|
|
rootMargin: '0px',
|
|
})
|
|
|
|
useEffect(() => {
|
|
if (entry?.isIntersecting) {
|
|
onLoadMore?.()
|
|
}
|
|
}, [entry, onLoadMore])
|
|
|
|
const handleValuesChange = (nextRefs: string[]) => {
|
|
if (nextRefs.length > maxSelected) return
|
|
onChange(nextRefs)
|
|
}
|
|
|
|
const renderProjectName = (ref: string, name: string) => (
|
|
<>
|
|
{Boolean(readinessIssues[ref]?.issues.length || readinessIssues[ref]?.enables_ssl) && (
|
|
<>
|
|
<span
|
|
className={cn(
|
|
'mr-1.5 inline-block size-1.5 rounded-full group-data-[state=open]:hidden',
|
|
Boolean(readinessIssues[ref]?.issues.length) ? 'bg-warning' : 'bg-foreground-muted/75'
|
|
)}
|
|
aria-hidden
|
|
/>
|
|
<span className="sr-only">Database setup notice: </span>
|
|
</>
|
|
)}
|
|
{name}
|
|
</>
|
|
)
|
|
|
|
return (
|
|
<div className="flex w-full flex-col gap-2">
|
|
<div className="flex items-center justify-between gap-2">
|
|
<h2
|
|
id={labelId}
|
|
className={cn('text-sm font-medium', hasFlagged ? 'text-destructive' : 'text-foreground')}
|
|
>
|
|
Projects
|
|
</h2>
|
|
{!allProjectsSelected && showCounter && (
|
|
<p className="text-xs text-foreground-lighter">
|
|
{selectedProjectRefs.length}/{maxSelected}
|
|
</p>
|
|
)}
|
|
</div>
|
|
|
|
{onAllProjectsChange && (
|
|
<RadioGroup
|
|
aria-labelledby={labelId}
|
|
value={allProjectsSelected ? 'all' : 'selected'}
|
|
onValueChange={(value) => onAllProjectsChange(value === 'all')}
|
|
className="gap-2 py-1"
|
|
>
|
|
<label
|
|
htmlFor={`${labelId}-all`}
|
|
className="flex cursor-pointer items-center gap-2 text-sm"
|
|
>
|
|
<RadioGroupItem id={`${labelId}-all`} value="all" />
|
|
All current and future projects
|
|
</label>
|
|
<label
|
|
htmlFor={`${labelId}-selected`}
|
|
className="flex cursor-pointer items-center gap-2 text-sm"
|
|
>
|
|
<RadioGroupItem id={`${labelId}-selected`} value="selected" />
|
|
Selected projects only
|
|
</label>
|
|
</RadioGroup>
|
|
)}
|
|
|
|
{!allProjectsSelected && (
|
|
<>
|
|
<MultiSelector
|
|
values={selectedProjectRefs}
|
|
onValuesChange={handleValuesChange}
|
|
onSearchChange={onSearchChange}
|
|
>
|
|
<MultiSelectorTrigger
|
|
id="projects"
|
|
aria-labelledby={labelId}
|
|
className="group"
|
|
aria-describedby="projects-description"
|
|
label="Select projects..."
|
|
badgeLimit={2}
|
|
deletableBadge
|
|
renderValue={(value) =>
|
|
renderProjectName(
|
|
value,
|
|
selectedProjects.find((project) => project.ref === value)?.name ?? value
|
|
)
|
|
}
|
|
/>
|
|
<MultiSelectorContent>
|
|
<MultiSelectorInput placeholder="Search projects" showResetIcon />
|
|
<MultiSelectorList emptyLabel="No projects found">
|
|
{projects.map((project) => {
|
|
const isSelected = selectedProjectRefs.some((ref) => ref === project.ref)
|
|
return (
|
|
<MultiSelectorItem
|
|
key={project.ref}
|
|
value={project.ref}
|
|
disabled={atCap && !isSelected}
|
|
>
|
|
<span className="flex min-w-0 flex-1 items-center justify-between gap-2">
|
|
<span>
|
|
{project.name}
|
|
{unavailableRefs.includes(project.ref) && (
|
|
<span className="text-foreground-lighter"> - Permission issues</span>
|
|
)}
|
|
</span>
|
|
{Boolean(readinessIssues[project.ref]?.issues.length) && (
|
|
<>
|
|
<span
|
|
className="size-1.5 shrink-0 rounded-full bg-warning"
|
|
aria-hidden
|
|
/>
|
|
<span className="sr-only">Blocks authorization</span>
|
|
</>
|
|
)}
|
|
{!readinessIssues[project.ref]?.issues.length &&
|
|
readinessIssues[project.ref]?.enables_ssl && (
|
|
<>
|
|
<span
|
|
className="size-1.5 shrink-0 rounded-full bg-foreground-muted/75"
|
|
aria-hidden
|
|
/>
|
|
<span className="sr-only">SSL enforcement will be enabled</span>
|
|
</>
|
|
)}
|
|
</span>
|
|
</MultiSelectorItem>
|
|
)
|
|
})}
|
|
<span ref={sentinelRef} />
|
|
</MultiSelectorList>
|
|
</MultiSelectorContent>
|
|
</MultiSelector>
|
|
</>
|
|
)}
|
|
|
|
<div id="projects-description" aria-live="polite">
|
|
{hasFlagged && flaggedRefs.length > 0 && (
|
|
<p className="text-xs text-destructive">
|
|
{selectedProjectRefs.length > 1
|
|
? `${flaggedRefs.length} of ${selectedProjectRefs.length} ${selectedProjectRefs.length === 1 ? 'project has' : 'projects have'} issues`
|
|
: `${flaggedRefs.length} project has issues`}
|
|
</p>
|
|
)}
|
|
{atCap && (
|
|
<p className="text-xs text-foreground-lighter">
|
|
Maximum reached. Deselect a project to choose a different one.
|
|
</p>
|
|
)}
|
|
{error && <p className="text-xs text-destructive">{error}</p>}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|