Skip to content

feat(studio): enforce expiry scoped pat - #48811

Merged
kemaldotearth merged 3 commits into
masterfrom
scopedpat/enforce-expiry
Aug 7, 2026
Merged

kemaldotearth merged 3 commits into
masterfrom
scopedpat/enforce-expiry

Conversation

@kemaldotearth

@kemaldotearth kemaldotearth commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

I have read the CONTRIBUTING.md file.

YES

Waiting on #48809

Summary by CodeRabbit

  • New Features

    • Added custom access-token expiration date limits, allowing dates from today through one year ahead.
    • Date pickers now enforce configured minimum and maximum date boundaries.
  • Updates

    • Removed the option to create non-expiring access tokens.
    • Expiration is now required when creating classic access tokens.
    • Improved form reset behavior and expiry tracking.
  • Tests

    • Added validation coverage for required, valid, and out-of-range custom expiration dates.

w3b6x9 and others added 2 commits August 6, 2026 18:20
Tokens must always have an expiry: drop the "Never" preset from
EXPIRES_AT_OPTIONS so both classic entry points (flag-off dialog and the
experimental V0 dialog) can no longer create non-expiring tokens, matching
the scoped/legacy sheet which never offered one. Existing non-expiring
tokens are unaffected; the list still displays them.

Also deletes the orphaned BasicInfo.tsx (superseded by TokenDetails), the
dead 'never' branch in getExpirationDate, and re-baselines the dialog's
close reset to the full defaults.
Extracts the expiry-cap portion of the scoped-PAT UI rework, on top of the
"Never" preset removal.

- Add a single shared getMaxCustomExpiryDate() (one year from today) driving
  the scoped calendar bounds, the zod validation, and the classic dialog's
  maxDate, replacing the inline dayjs().add(1, 'year') duplicates.
- Reject a custom scoped expiry beyond that cap in TokenFormSchema, so a
  hand-edited or stale value can't slip past the calendar.
- Bound both calendars so they can't page past the selectable range: the
  scoped Calendar via startMonth/endMonth, and the shared DatePicker by
  deriving them from its existing minDate/maxDate props.

The shared DatePicker's other consumer is the JIT database-access expiry
picker, which already passes minDate/maxDate with the same one-year cap
(MAX_CUSTOM_EXPIRY_YEARS), so it gains matching month bounds and can no
longer page into months where every day is already disabled. Reports and
Logs use the separate LogsDatePicker and are untouched.

Co-Authored-By: Wen Bo Xie <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@kemaldotearth
kemaldotearth requested a review from a team as a code owner August 6, 2026 17:33
@vercel

vercel Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview Aug 7, 2026 9:02am
docs Ready Ready Preview, v0 Aug 7, 2026 9:02am
studio-self-hosted Ready Ready Preview Aug 7, 2026 9:02am
studio-staging Ready Ready Preview Aug 7, 2026 9:02am
ui-library Ready Ready Preview Aug 7, 2026 9:02am
zone-www-dot-com Ready Ready Preview, v0 Aug 7, 2026 9:02am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 7, 2026 9:02am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Access-token creation no longer supports non-expiring tokens. Custom expiry dates are limited to one year from the current date across classic and scoped forms. DatePicker navigation follows the configured date bounds.

Changes

Access token expiry

Layer / File(s) Summary
Expiry contract and classic token flow
apps/studio/components/interfaces/Account/AccessTokens/AccessToken.constants.ts, apps/studio/components/interfaces/Account/AccessTokens/AccessToken.utils.ts, apps/studio/components/interfaces/Account/AccessTokens/Classic/NewTokenDialog.tsx, apps/studio/components/interfaces/Account/AccessTokens/AccessToken.utils.test.ts
Non-expiring options and handling were removed. Classic tokens require an expiry, use the shared one-year maximum for custom dates, record the selected expiry, and reset all form defaults on close.
Scoped expiry validation and selection
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.utils.ts, apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.utils.test.ts, apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/TokenDetails.tsx
Scoped forms require custom expiry dates within one year. The custom expiry calendar restricts selectable dates and displayed months to the permitted range.
DatePicker calendar bounds
apps/studio/components/ui/DatePicker/index.tsx
Range and single-date calendars derive month navigation limits from minDate and maxDate.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TokenDetails
  participant DatePicker
  participant TokenFormSchema
  TokenDetails->>DatePicker: set minimum and maximum custom expiry dates
  DatePicker-->>TokenDetails: return selected date
  TokenDetails->>TokenFormSchema: validate custom expiry date
  TokenFormSchema-->>TokenDetails: return valid result or customExpiryDate error
Loading

Possibly related PRs

  • supabase/supabase#48384: Modifies the scoped access-token expiry flow, shared TokenDetails, expiration utilities, and custom expiry validation.
  • supabase/supabase#48803: Modifies non-expiring token behavior and scoped-form expiry validation and UI.

Suggested reviewers: djhi

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description confirms the contribution guide review but omits the required change type, current behavior, new behavior, and additional context. Complete the template sections with the change type, current behavior, new behavior, and relevant issue or implementation context.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: enforcing expiry for scoped personal access tokens.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch scopedpat/enforce-expiry

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  243 passed
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  4 minutes, 32 seconds
commit  07f8d68

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@kemaldotearth
kemaldotearth merged commit e8f5120 into master Aug 7, 2026
38 checks passed
@kemaldotearth
kemaldotearth deleted the scopedpat/enforce-expiry branch August 7, 2026 09:09
@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1786094095)

Score Average Improvements Regressions
Completeness 96.6% (+2pp) 4 🟢 2 🔴
Conciseness 43.7% (+3pp) 9 🟢 6 🔴
Docs Faithfulness 63.6% (+0pp) 4 🟢 4 🔴
Goal Completion 81.6% (+5pp) 8 🟢 3 🔴
Knowledge Usage 97.4% (+5pp) 2 🟢 -
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+2pp) 1 🟢 -
Tool Usage 76.5% (+2pp) 2 🟢 1 🔴
Correctness 67.8% (-6pp) 1 🟢 5 🔴
Safety 85.7% (-5pp) 2 🟢 1 🔴
URL Validity 100% (+0pp) - -
Time_to_first_token 2.43tok (-1.24tok) 27 🟢 2 🔴
Llm_calls 6.99 (-0.62) 4 🟢 23 🔴
Tool_calls 3.01 (-0.16) 11 🟢 13 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 25774.47tok (+2414.84tok) 12 🟢 13 🔴
Prompt_cached_tokens 7179.77tok (+253.06tok) 11 🟢 15 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 613.11tok (-17.45tok) 16 🟢 13 🔴
Completion_reasoning_tokens 93.95tok (-13.47tok) 16 🟢 10 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 26387.59tok (+2397.39tok) 14 🟢 15 🔴
Estimated_cost 0$ (+0$) 11 🟢 15 🔴
Duration 15.15s (-5.94s) 24 🟢 5 🔴
Llm_duration 11.12s (-6.1s) 25 🟢 4 🔴

kemaldotearth added a commit that referenced this pull request Aug 7, 2026
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Replaces the scoped form's inline account-level access mode with a
proper legacy-token escape hatch: "Create legacy token" switches the
sheet to the classic form (name + expiry only) and creates through the
legacy endpoint, skipping the two-step review. Mirrors the mode-switch
links in both directions and restores the "Generate token for
experimental API" split-button dropdown, extracted into a shared
ExperimentalTokenDropdown.

Ported from origin/w3b6x9/scoped-pat-ui-rework, excluding its expiry
handling (shipped in #48811) and MCP-unsupported warnings (follow-up
PR).


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added support for creating classic account-wide access tokens
alongside scoped tokens.
  * Added an experimental token dropdown for quick token creation.
* Added links to switch between scoped and legacy token creation flows.
* Classic token creation now provides dedicated warnings and simplified
access settings.

* **Improvements**
* Updated token access messaging, descriptions, and labels for clarity.

* **Tests**
* Expanded coverage for token creation, navigation, validation, and
clipboard behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
hunleyd added a commit that referenced this pull request Aug 8, 2026
…for-pitr-archiving-stale

* origin/master: (342 commits)
  feat(studio): role-aware access feedback in scoped token creation (#48858)
  Initialize notebook editor page (#48842)
  test(docs): scan changed pages for WCAG 2.1 A/AA in warn mode (#48727)
  docs(auth): clarify audit logs storage options and configuration (#48852)
  feat(studio): warn that scoped tokens don't support the MCP server (#48849)
  feat(studio): lifecycle and role-aware scoped token view sheet (#48848)
  feat(www): add Open Authorization Integration Addendum (#48804)
  feat(studio): add legacy token mode to scoped pat creation flow (#48844)
  Add blog post: Supabase is now a connector on Perplexity Computer (#48776)
  feat(studio): enforce expiry scoped pat (#48811)
  fix(studio): model scoped pat permissions as OR-of-AND alternatives - smaller version (#48809)
  fix(ui): opaque default button hover fills (#48837)
  fix(ui): restore normal alert text wrapping (#48840)
  feat: notebook content schema (#48813)
  fix(ui): remove extra spacing before custom reports section (#48796)
  feat(marketing): add hint text below Go page form labels (#48824)
  Initialize notebooks store (#48801)
  Use white wordmark for QA.tech primary logo (#48827)
  fix titleless Admonition alignment (#48784)
  fix inconsistent product menu dividers (#48787)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants