Files
supabase/apps/studio/components/interfaces/Storage/StorageMenuV2.tsx
T
Drew McLellanandFrancesco Sansalvadore d98c277790 feat(studio): rotate Storage URL signing keys FE-4433 (#52165)
## Problem

Rotating a project's Storage URL signing key currently needs a support
ticket, so customers can't rotate on their own timeline or keep a
standby key until their signed URLs have migrated.

Linear:
[FE-4433](https://linear.app/supabase/issue/FE-4433/allow-users-to-rotate-storage-url-signing-keys-via-ui)

## Solution

Adds a URL signing keys page at `/project/{ref}/storage/signing-keys`,
linked from the Storage menu. It builds on the design prototype from
`feat/storage-rotate-signing-keys` and follows the current JWT Keys page
styling.

- Active key, standby key, and revoked keys are shown in separate
tables, so there is only ever one active key. The UI allows one standby
key at a time.
- Create a standby key (ES256 by default, HS512 optional), rotate the
standby key to active, revoke a standby key, or move a revoked key back
to standby.
- The key list reports JWK types (`EC`, `oct`), which are mapped to
ES256 and HS512 labels. Unrecognized types fall back to the raw value.
- Telemetry: `storage_url_signing_key_created` and
`storage_url_signing_key_updated` (with a `change` property), fired when
the action succeeds.
- A "Created at" column is not included yet because the keys endpoint
doesn't return it. It will follow in a later PR.

<img width="1272" height="846" alt="Screenshot 2026-10-23 at 11 43 45"
src="https://github.com/user-attachments/assets/980742ed-6c4e-43d1-b170-847e550fde4c"
/>


## Review instructions

1. Open the preview and go to Storage > URL signing keys on a project.
2. Create a standby key, then rotate it to active. The previous active
key should move to standby.
3. Revoke the standby key (type its ID to confirm), then move it back to
standby from the revoked table.
4. Compare the table styling with Project Settings > JWT Keys.
5. Check that creating a standby key and moving a revoked key to standby
are disabled while a standby key exists.

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

---------

Co-authored-by: Francesco Sansalvadore <f.sansalvadore@gmail.com>
2026-10-26 16:39:39 +00:00

142 lines
4.9 KiB
TypeScript

import { useParams } from 'common'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { Badge, Menu } from 'ui'
import { BUCKET_TYPES } from './Storage.constants'
import { useStorageV2Page } from './Storage.utils'
import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import {
useIsAnalyticsBucketsEnabled,
useIsVectorBucketsEnabled,
} from '@/data/config/project-storage-config-query'
import { useDeploymentMode } from '@/hooks/misc/useDeploymentMode'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { SHORTCUT_IDS, type ShortcutId } from '@/state/shortcuts/registry'
import { useShortcut } from '@/state/shortcuts/useShortcut'
const BUCKET_TYPE_SHORTCUTS: Record<keyof typeof BUCKET_TYPES, ShortcutId> = {
files: SHORTCUT_IDS.NAV_STORAGE_FILES,
analytics: SHORTCUT_IDS.NAV_STORAGE_ANALYTICS,
vectors: SHORTCUT_IDS.NAV_STORAGE_VECTORS,
}
export const StorageMenuV2 = () => {
const router = useRouter()
const { ref } = useParams()
const page = useStorageV2Page()
const { isCli, isPlatform } = useDeploymentMode()
const { storageAnalytics, storageVectors } = useIsFeatureEnabled([
'storage:analytics',
'storage:vectors',
])
const isAnalyticsBucketsEnabled = useIsAnalyticsBucketsEnabled({ projectRef: ref })
const isVectorBucketsEnabled = useIsVectorBucketsEnabled({ projectRef: ref })
const showAnalytics = isPlatform && storageAnalytics
const showVectors = (isPlatform && storageVectors) || isCli
useShortcut(SHORTCUT_IDS.NAV_STORAGE_FILES, () => router.push(`/project/${ref}/storage/files`))
useShortcut(
SHORTCUT_IDS.NAV_STORAGE_ANALYTICS,
() => router.push(`/project/${ref}/storage/analytics`),
{ enabled: showAnalytics }
)
useShortcut(
SHORTCUT_IDS.NAV_STORAGE_VECTORS,
() => router.push(`/project/${ref}/storage/vectors`),
{ enabled: showVectors }
)
useShortcut(SHORTCUT_IDS.NAV_STORAGE_S3, () => router.push(`/project/${ref}/storage/s3`), {
enabled: isPlatform,
})
useShortcut(
SHORTCUT_IDS.NAV_STORAGE_SIGNING_KEYS,
() => router.push(`/project/${ref}/storage/signing-keys`),
{ enabled: isPlatform }
)
const bucketTypes = Object.entries(BUCKET_TYPES).filter(([key]) => {
if (key === 'analytics') return showAnalytics
if (key === 'vectors') return showVectors
return true
})
return (
<Menu type="pills" className="my-2 md:my-4 flex grow flex-col">
<div className="space-y-4">
<div className="md:mx-3">
<Menu.Group title={<span className="uppercase font-mono">Manage</span>} />
{bucketTypes.map(([type, config]) => {
const isSelected = page === type
const isAlphaEnabled =
(type === 'analytics' && isAnalyticsBucketsEnabled) ||
(type === 'vectors' && isVectorBucketsEnabled)
const shortcutId = BUCKET_TYPE_SHORTCUTS[type as keyof typeof BUCKET_TYPES]
const item = (
<Link href={`/project/${ref}/storage/${type}`}>
<Menu.Item rounded active={isSelected}>
<div className="flex items-center justify-between">
<p className="truncate">{config.displayName}</p>
{isAlphaEnabled && <Badge variant="success">New</Badge>}
</div>
</Menu.Item>
</Link>
)
return (
<div key={type}>
{shortcutId ? (
<ShortcutTooltip shortcutId={shortcutId} side="right" delayDuration={1000}>
{item}
</ShortcutTooltip>
) : (
item
)}
</div>
)
})}
</div>
{isPlatform && (
<>
<div className="h-px w-[calc(100%-1.5rem)] mx-auto md:w-full bg-border" />
<div className="md:mx-3">
<Menu.Group title={<span className="uppercase font-mono">Configuration</span>} />
<ShortcutTooltip
shortcutId={SHORTCUT_IDS.NAV_STORAGE_S3}
side="right"
delayDuration={1000}
>
<Link href={`/project/${ref}/storage/s3`}>
<Menu.Item rounded active={page === 's3'}>
<p className="truncate">S3</p>
</Menu.Item>
</Link>
</ShortcutTooltip>
<ShortcutTooltip
shortcutId={SHORTCUT_IDS.NAV_STORAGE_SIGNING_KEYS}
side="right"
delayDuration={1000}
>
<Link href={`/project/${ref}/storage/signing-keys`}>
<Menu.Item rounded active={page === 'signing-keys'}>
<p className="truncate">URL signing keys</p>
</Menu.Item>
</Link>
</ShortcutTooltip>
</div>
</>
)}
</div>
</Menu>
)
}