Skip to content

feat: OAuth client scopes#27707

Closed
supalarry wants to merge 41 commits intolauris/cal-7035-fix-invalidate-old-refresh-tokensfrom
lauris/cal-7030-feat-oauth-client-scopes
Closed

feat: OAuth client scopes#27707
supalarry wants to merge 41 commits intolauris/cal-7035-fix-invalidate-old-refresh-tokensfrom
lauris/cal-7030-feat-oauth-client-scopes

Conversation

@supalarry
Copy link
Contributor

@supalarry supalarry commented Feb 6, 2026

Fixes #26475


Summary by cubic

Adds OAuth client scopes across API, UI, and docs with strict scope-based endpoint access. Token and refresh responses now include a space-delimited scope; the authorize page validates state and requested scopes against the client’s registered scopes.

  • New Features

    • Add OAuthClient.scopes[] and new AccessScope values; parse comma/space-delimited scope; include scope in token/refresh responses.
    • Enforce endpoint access via ThirdPartyPermissionsGuard using scope↔permission mapping; V2 docs/OpenAPI accept OAuth bearer tokens and list scopes.
    • UI/TRPC require scopes on create/submit, show scope selection, return client scopes for authorization, and validate requested scopes; legacy clients hide scopes and can update without scopes.
    • Broadening a client’s scopes sets status to PENDING for re-approval (write implies read when checking expansion).
    • Return invalid_scope (RFC 6749) when requested scopes are invalid or exceed the client’s registered scopes.
  • Migration

    • Prisma migration adds new AccessScope values and the OAuthClient.scopes[] column.
    • New clients must select at least one scope; legacy clients continue to work and can opt in later.

Written for commit aaa4ac9. Summary will update on new commits.


Open with Devin

@supalarry supalarry requested a review from a team as a code owner February 6, 2026 12:38
@paragon-review
Copy link

paragon-review bot commented Feb 6, 2026

Paragon Review Unavailable

Hi @supalarry! To enable Paragon reviews on this repository, please register at https://home.polarity.cc

Once registered, connect your GitHub account and Paragon will automatically review your pull requests.

@linear
Copy link

linear bot commented Feb 6, 2026

@github-actions github-actions bot added the ❗️ migrations contains migration files label Feb 6, 2026
@graphite-app graphite-app bot added consumer core area: core, team members only labels Feb 6, 2026
@graphite-app graphite-app bot requested a review from a team February 6, 2026 12:38
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 28 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/trpc/server/routers/viewer/oAuth/updateClient.handler.ts">

<violation number="1" location="packages/trpc/server/routers/viewer/oAuth/updateClient.handler.ts:68">
P1: Security: Scope changes by owners should trigger reapproval. The `scopes` field is added to `hasAnyFieldsChanged()` but NOT to `triggersReapprovalForOwnerEdit()`. This allows OAuth client owners to escalate their client's permissions without admin oversight. Similar to how `redirectUri` changes require reapproval, scope modifications should also set status to PENDING.

The `triggersReapprovalForOwnerEdit()` call below (lines 79-93) needs to include `scopes` in both `currentClient` and `proposedUpdates` to maintain the approval workflow for permission changes.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 7 additional findings.

Open in Devin Review

@calcom calcom deleted a comment from devin-ai-integration bot Feb 6, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/api/v2/src/modules/auth/guards/permissions/permissions.guard.spec.ts">

<violation number="1" location="apps/api/v2/src/modules/auth/guards/permissions/permissions.guard.spec.ts:152">
P3: Fix typo in test description: "compatability" → "compatibility" for clearer test naming.</violation>

<violation number="2" location="apps/api/v2/src/modules/auth/guards/permissions/permissions.guard.spec.ts:163">
P3: Fix typo in test description: "compatability" → "compatibility" for clearer test naming.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/web/modules/settings/oauth/view/OAuthClientDetailsDialog.tsx">

<violation number="1" location="apps/web/modules/settings/oauth/view/OAuthClientDetailsDialog.tsx:285">
P2: Legacy clients with empty scopes can no longer be updated because scope selection is hidden while the submit handler requires at least one scope. Allow scope selection when editing legacy clients (or bypass the required-scope check) so updates aren’t permanently blocked.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session


✅ No changes pushed

@CarinaWolli CarinaWolli self-requested a review February 24, 2026 13:58
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/web/playwright/oauth/oauth-authorize-approval-status.e2e.ts">

<violation number="1" location="apps/web/playwright/oauth/oauth-authorize-approval-status.e2e.ts:457">
P3: Unknown-scope errors map to the OAuth "invalid_scope" error, so this expectation will fail (or mask a regression). Update the assertion to expect invalid_scope.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

@supalarry supalarry closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer core area: core, team members only ❗️ migrations contains migration files ready-for-e2e size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants