Repository navigation
feat(studio): scoped access token prototype - #47783
kemaldotearth wants to merge 7 commits into
Conversation
Introduce the data model for the scoped access-token redesign:
- AccessToken.permissions.ts builds a permission catalog from the real
FgaPermissions, groups all ~40 resources into five UI categories
(Project, Database, Application Services, Infrastructure & Delivery,
Account & Organization), and layers editable risk metadata + copy.
- permission-scope-map.{json,ts}: checked-in cross-reference of scope →
Management API endpoints + MCP tools, with conjunctive (dual-scope)
enforcement helpers. Marked TODO to move behind a control-plane endpoint.
- Update access_token_created telemetry + add migration-admonition
localStorage key.
- Reference: apps/studio/.design/scoped-token-sheet-variant-d.html.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Rebuild scoped token creation as a two-step Sheet matching variant-d: - Step 1 Configure: token name + expiry Select (7-day default, Recommended badge, Custom date picker); resource-access radio cards (Single project / Organization) with account-level advanced admonition + confirm checkbox; permissions Accordion of the five categories, per-row None/Read/Read-write Select and a risk marker with Allows + MCP-tool tooltip. - Step 2 Review: capability summary grouped by category, computed overall risk, real Management API endpoints grouped per capability (dual-scope aware) + MCP tool chips, permanence admonition. - Footer step indicator; one-time token reveal success state. - Validation surfaces only on attempt (inline resource errors scroll into view; Create disabled with zero scopes). - Rename the scoped create hook to useScopedAccessTokenCreateMutation. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Merge classic and scoped tokens into a single "Tokens" table via a useMergedAccessTokens selector (tags each row classic/scoped, classic drives loading/error, scoped failures degrade gracefully). Classic rows get a neutral "Classic" badge; row actions route to the correct delete/view endpoint by kind. Remove the Classic/Scoped nav tabs. - Add a dismissible migration admonition (persisted via localStorage) and keep classic minting available as a secondary action. - /account/tokens/scoped now redirects to the merged /account/tokens. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Move the scope→endpoint/MCP map from a checked-in .json into a TS constants module (permission-scope-map.constants.ts) and delete the unused apps/studio/.design reference folder. - Remove the classic-token creation button; scoped generation is now the only creation entry point. Reword the migration admonition accordingly. - Fix the duplicate "Recommended" badge on the expiry trigger (SelectValue already mirrors the selected item's badge). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Restore multi-select for the resource-access selectors: the two modes now
pick one or more projects (project_refs[]) or one or more organizations
(organization_slugs[]) via the shared MultiSelector, instead of a single
org+project pair. Updates the form schema (organizationSlugs/projectRefs
arrays), inline validation ("select at least one …"), the review summary,
and the create payload.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…oped tokens" This reverts commit da59092.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎭 Playwright Test ResultsDetails
Flaky testsFeatures › database.spec.ts › Database › Schema Visualizer › table actions work as expected Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
| return { | ||
| tokens, | ||
| // Classic drives the primary states; a scoped fetch that is still loading shouldn't block the list. | ||
| isLoading: classic.isPending || (scopedEnabled && scoped.isPending), | ||
| isError: classic.isError, | ||
| error: classic.error, | ||
| isSuccess: classic.isSuccess, | ||
| } |
There was a problem hiding this comment.
The useMemo above won't help if the hook return value isn't wrapped in a memo too as we are recreating a new object here every time. I would return a useMemo inside which the tokens will be built, but return the hook result object
| <p className="text-xs text-foreground-light">{entry.description}</p> | ||
| </div> | ||
|
|
||
| <Select value={mode} onValueChange={(value) => onChange(value as PermissionMode)}> |
There was a problem hiding this comment.
a11y: this input has no label
| <div className="flex items-center gap-1.5"> | ||
| <span className="text-sm text-foreground">{category.name}</span> | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> |
There was a problem hiding this comment.
a11y: if you set the asChild prop, make sure the child is an interactive element, otherwise keyboard users won't ever see it
|
|
||
| return ( | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> |
There was a problem hiding this comment.
a11y: if you set the asChild prop, make sure the child is an interactive element, otherwise keyboard users won't ever see it
| <FormItemLayout name="expiresAt" label="Expires in"> | ||
| <div className="flex gap-2"> | ||
| <FormControl className="grow"> | ||
| <Select value={field.value} onValueChange={handleExpiryChange}> |
| </FormControl> | ||
|
|
||
| {field.value === 'custom' && ( | ||
| <DatePicker |
| </p> | ||
| </div> | ||
|
|
||
| <Input |
First stacked PR for scoped PAT extracted from the prototype #47783 to ease reviewing. Next stacked PR is #47979 This PR: - merge the two existing token lists (classic and scoped) into one - add an admonition about the scoped PAT migration (missing the docs URL) ## Notes It's not possible to create classic tokens anymore with the `scopedPAT` flag enabled. ## How to test ### With the `scopedPAT` enabled (default on staging) Go to https://studio-staging-git-scopedpat-merge-token-lists-supabase.vercel.app/dashboard/account/tokens. - You shouldn't see two tabs anymore - If you had classic tokens, they should have the _classic_ badge - You can create scoped tokens - You have a way to copy newly created tokens above the list upon form submission ### With the `scopedPAT` disabled (use the devtool to override) - You shouldn't see two tabs anymore - If you had classic tokens, they should **not** have the _classic_ badge - You can create classic tokens - You have a way to copy newly created tokens above the list upon form submission ## Screenshots Before: <img width="775" height="515" alt="image" src="https://github.com/user-attachments/assets/35733e7f-6e3e-40f9-ac5b-cfd7caf5d830" /> After: <img width="767" height="671" alt="image" src="https://github.com/user-attachments/assets/2fd86e6e-6dc6-46c8-9c89-cbfc553e4eb9" />
Second stacked PR for scoped PAT extracted from the prototype #47783 to ease reviewing. Previous stacked PR is #47886 Next stacked PR is #48003 This PR: - refactor the scoped token creation form in a multi-step fashion ## How to test Go to https://studio-staging-git-scopedpat-scoped-token-creat-80c55b-supabase.vercel.app/dashboard/account/tokens - Click the _Generate new token_ button - Try submitting immediately. It should display errors correctly - Configure everything except permissions and try submitting. It should display a warning about missing permissions - Configure the permissions and submit. It should display the review step - Try going back, modify anything and submit - Create the token. It should display the token value with a button to copy it and a checkbox to confirm the copy. You cannot close the sheet at this step until you check the box and click _Done_.
Third stacked PR for scoped PAT extracted from the prototype #47783 to ease reviewing. Previous stacked PR is #47979 Next stacked PR is #47999 This PR add a way to view the tokens permissions <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a “View permissions” option for scoped access tokens. * Scoped token permissions now open in a dedicated viewing panel. * Scoped token support is enabled by default. * **Bug Fixes** * Improved token deletion confirmation to clearly identify the selected token. * Deletion dialogs now close correctly after successful removal. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Fourth stacked PR for scoped PAT extracted from the prototype #47783 to ease reviewing. Previous stacked PR is #48003 Next stacked PR is #48002 This PR: - fix some accessibility issues - add unit tests <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added coverage for creating scoped access tokens at the project, organization, and account levels. * Verified validation for required fields, successful token creation, clipboard copying, and completion flow. * **Chores** * Added temporary browser console logging when viewing a scoped access token. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…n API specs (#48182) Fifth stacked PR for scoped PAT extracted from the prototype #47783 to ease reviewing. Previous stacked PR is #47999 Next stacked PR is #48359 This PR refactor how we get the map of which scopes enable which endpoint or mcp tool. Previously it was an hardcoded file. We now compute it from the OpenAPI specs of our API. This ensure the map stays up to date when the API changes. However, we don't have an always up-to-date equivalent for mcp tools so we duplicated code from platform that map the OAuth scopes they check with the FGA permissions. ## Notes The react-hook-form usage is not great. A follow up PR will fix it ## How to test - On https://studio-staging-git-scopedpat-scope-permissions-api-supabase.vercel.app/dashboard/account/tokens - Create a new token with a few permissions (their risk marker should be displayed: (_High risk_, _Medium risk_ or _Low risk_) - You should see the available endpoints and mcp tools in the review step <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added dynamic permission mapping for scoped access tokens, covering Management API endpoints and MCP tools. * Added a permissions endpoint with hosted-platform support and caching. * Updated scoped token creation and review screens to show capabilities based on granted permissions. * Added permission-aware risk indicators and tool visibility. * **Bug Fixes** * Improved authorization checks so endpoints and tools require all necessary scopes. * **Tests** * Added coverage for endpoint, scope, and MCP tool mapping behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
Closing this as we shipped and this was only ever a prototype. |
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Improvements to scoped access tokens sheet, starting point for new version. Reference PR for @djhi