Skip to content

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Nov 29, 2025

Ramble / context: user driven permission syncing uses the access_token stored on the Account object that is acquired when the user signs in with GitHub/GitLab/whatever. Access tokens have a associated scopes (e.g., read:user, repo, etc.). For permission syncing, we require additional oauth scopes from the base ones we usually request.

When enabling permission syncing on a existing deployment, this will result in 403 errors since the existing oauth scopes are insufficient for the api requests we are making. Signing out of the account and re-signing in resolves the issue since the new oauth scopes will be requested.

This PR originally attempted to automate the process by automatically signing out the account when the scopes changed, but this was deemed to be too complicated and fragile. Instead, I've added improved error messages and documanted the issue in the docs.

Fixes #638
Fixes SOU-98


Note

Improves reliability and clarity of user-driven permission syncing by validating OAuth scopes and ensuring refreshed tokens are stored.

  • Backend: In accountPermissionSyncer, fetch and validate OAuth scopes (repo for GitHub, read_api for GitLab) via new helpers (getOAuthScopesForAuthenticatedUser in github.ts/gitlab.ts); throw explicit errors and prompt re-auth when tokens/scopes are insufficient.
  • Web auth: On signIn event, explicitly update Account with latest OAuth token fields to persist refreshed credentials.
  • Docs: Add warning to permission-syncing.mdx explaining scope-related errors when enabling on existing deployments and the need to re-authenticate.
  • Changelog: Notes improved error messaging for OAuth scope issues.

Written by Cursor Bugbot for commit 13c4c9c. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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 and usage tips.

@brendan-kellam brendan-kellam marked this pull request as ready for review November 30, 2025 01:41
@github-actions

This comment has been minimized.

@brendan-kellam
Copy link
Contributor Author

test

@brendan-kellam brendan-kellam requested review from msukkari and removed request for msukkari November 30, 2025 01:47
@brendan-kellam brendan-kellam marked this pull request as draft November 30, 2025 01:48
@brendan-kellam brendan-kellam force-pushed the bkellam/fix_638 branch 2 times, most recently from 6554248 to d022066 Compare December 2, 2025 04:18
…atically signing out accounts when oauth scopes change. The system is pretty fragile, so I'm going to take the safer approach and just add document this as a known issue.
…of automatically signing out accounts when oauth scopes change. The system is pretty fragile, so I'm going to take the safer approach and just add document this as a known issue."

This reverts commit 84b1cf4.
@brendan-kellam brendan-kellam marked this pull request as ready for review January 14, 2026 05:11
@brendan-kellam brendan-kellam changed the title fix(web): Fix #638 fix(web): Document 403 errors with user driven permission syncing when scope changes occur Jan 14, 2026
@brendan-kellam brendan-kellam merged commit 871ae78 into main Jan 14, 2026
11 checks passed
@brendan-kellam brendan-kellam deleted the bkellam/fix_638 branch January 14, 2026 05:36
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

const scopes = await getGitLabOAuthScopesForAuthenticatedUser(api);
if (!scopes.includes('read_api')) {
throw new Error(`OAuth token with scopes [${scopes.join(', ')}] is missing the 'read_api' scope required for permission syncing.`);
}
Copy link

Choose a reason for hiding this comment

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

GitLab scope check rejects valid api scope tokens

Medium Severity

The GitLab scope validation only checks for the exact read_api scope, but GitLab's api scope is a superset that includes all read_api permissions. Users who configured their OAuth application with api scope (for other integrations or by preference) would be incorrectly rejected with a confusing error stating they're missing read_api, even though their token has sufficient permissions to list projects.

Fix in Cursor Fix in Web

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.

[bug] User driven permission syncing will fail with 403 Unauthorized for accounts created before permission syncing was enabled

2 participants