Skip to content

Conversation

@runningcode
Copy link
Contributor

@runningcode runningcode commented Nov 7, 2025

Summary

Fixes two related issues with the project:distribution scope for Custom Integration tokens:

  1. Creation Error: Users couldn't add the project:distribution permission when creating Custom Integration tokens, getting the error: "Requested permission of project:distribution exceeds requester's permission. Please contact an administrator to make the requested change."
Screenshot 2025-11-07 at 18 01 11
  1. Client Secret Masked: Even if users bypassed the creation error, the client secret was immediately masked as **** instead of being visible.
Screenshot 2025-11-07 at 18 20 03

Root Cause

The project:distribution scope is a specialized token-only scope that is intentionally not included in any user role (including owner). This design allows distribution tokens to be used in apps that are distributed without risking accidentally leaking a token with broader permissions.

However, two pieces of validation logic were checking if the user personally had these scopes:

  1. SentryAppParser.validate_scopes() - Blocked creation if the user didn't have the requested scopes
  2. SentryApp.show_auth_info() - Hid the client secret if the user didn't have all the integration's scopes

Changes

  • Added SENTRY_TOKEN_ONLY_SCOPES constant in server.py to define scopes that can be granted to integration tokens even if the user doesn't have them
  • Updated SentryAppParser.validate_scopes() to skip permission checks for token-only scopes
  • Updated SentryApp.show_auth_info() to exclude token-only scopes when determining if the client secret should be visible
  • Added project:distribution to SENTRY_SCOPE_SETS for documentation
  • Added test coverage for token-only scope validation and visibility

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 7, 2025
…ation tokens

The project:distribution scope is a specialized token-only scope that is
not included in any user role (including owner). However, the validation
logic for creating Custom Integration tokens was checking if the user had
the scope in their role first, causing it to fail.

Additionally, the show_auth_info method was preventing the client secret
from being visible when an integration had token-only scopes, because it
checked if the user had all the scopes in the integration.

This change introduces SENTRY_TOKEN_ONLY_SCOPES to define scopes that can
be granted to integration tokens even if the user doesn't have them, and
updates both the validation and visibility logic to handle these scopes
properly. This allows users to:
1. Create integration tokens with the project:distribution scope
2. View the client secret for integrations with token-only scopes
@runningcode runningcode force-pushed the no/fix-project-distribution-scope-validation branch from 926694a to b4a0657 Compare November 7, 2025 17:28
@runningcode runningcode marked this pull request as ready for review November 7, 2025 17:30
@runningcode runningcode requested review from a team as code owners November 7, 2025 17:30
Copy link
Contributor

@michelletran-sentry michelletran-sentry left a comment

Choose a reason for hiding this comment

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

Generally LGTM!

@runningcode runningcode merged commit 9deb0e3 into master Nov 10, 2025
69 checks passed
@runningcode runningcode deleted the no/fix-project-distribution-scope-validation branch November 10, 2025 16:01
Jesse-Box pushed a commit that referenced this pull request Nov 12, 2025
…ation tokens (#102967)

## Summary

Fixes two related issues with the `project:distribution` scope for
Custom Integration tokens:

1. **Creation Error**: Users couldn't add the `project:distribution`
permission when creating Custom Integration tokens, getting the error:
*"Requested permission of project:distribution exceeds requester's
permission. Please contact an administrator to make the requested
change."*
<img width="1266" height="241" alt="Screenshot 2025-11-07 at 18 01 11"
src="https://github.com/user-attachments/assets/a7fdee78-182b-4f0c-a9da-be0b6d89d520"
/>

2. **Client Secret Masked**: Even if users bypassed the creation error,
the client secret was immediately masked as `****` instead of being
visible.
<img width="604" height="223" alt="Screenshot 2025-11-07 at 18 20 03"
src="https://github.com/user-attachments/assets/66f50d31-06bd-4454-9f7e-c280a9f6ab9e"
/>

## Root Cause

The `project:distribution` scope is a specialized token-only scope that
is intentionally not included in any user role (including owner). This
design allows distribution tokens to be used in apps that are
distributed without risking accidentally leaking a token with broader
permissions.

However, two pieces of validation logic were checking if the user
personally had these scopes:

1. **`SentryAppParser.validate_scopes()`** - Blocked creation if the
user didn't have the requested scopes
2. **`SentryApp.show_auth_info()`** - Hid the client secret if the user
didn't have all the integration's scopes

## Changes

- Added `SENTRY_TOKEN_ONLY_SCOPES` constant in `server.py` to define
scopes that can be granted to integration tokens even if the user
doesn't have them
- Updated `SentryAppParser.validate_scopes()` to skip permission checks
for token-only scopes
- Updated `SentryApp.show_auth_info()` to exclude token-only scopes when
determining if the client secret should be visible
- Added `project:distribution` to `SENTRY_SCOPE_SETS` for documentation
- Added test coverage for token-only scope validation and visibility
andrewshie-sentry pushed a commit that referenced this pull request Nov 13, 2025
…ation tokens (#102967)

## Summary

Fixes two related issues with the `project:distribution` scope for
Custom Integration tokens:

1. **Creation Error**: Users couldn't add the `project:distribution`
permission when creating Custom Integration tokens, getting the error:
*"Requested permission of project:distribution exceeds requester's
permission. Please contact an administrator to make the requested
change."*
<img width="1266" height="241" alt="Screenshot 2025-11-07 at 18 01 11"
src="https://github.com/user-attachments/assets/a7fdee78-182b-4f0c-a9da-be0b6d89d520"
/>

2. **Client Secret Masked**: Even if users bypassed the creation error,
the client secret was immediately masked as `****` instead of being
visible.
<img width="604" height="223" alt="Screenshot 2025-11-07 at 18 20 03"
src="https://github.com/user-attachments/assets/66f50d31-06bd-4454-9f7e-c280a9f6ab9e"
/>

## Root Cause

The `project:distribution` scope is a specialized token-only scope that
is intentionally not included in any user role (including owner). This
design allows distribution tokens to be used in apps that are
distributed without risking accidentally leaking a token with broader
permissions.

However, two pieces of validation logic were checking if the user
personally had these scopes:

1. **`SentryAppParser.validate_scopes()`** - Blocked creation if the
user didn't have the requested scopes
2. **`SentryApp.show_auth_info()`** - Hid the client secret if the user
didn't have all the integration's scopes

## Changes

- Added `SENTRY_TOKEN_ONLY_SCOPES` constant in `server.py` to define
scopes that can be granted to integration tokens even if the user
doesn't have them
- Updated `SentryAppParser.validate_scopes()` to skip permission checks
for token-only scopes
- Updated `SentryApp.show_auth_info()` to exclude token-only scopes when
determining if the client secret should be visible
- Added `project:distribution` to `SENTRY_SCOPE_SETS` for documentation
- Added test coverage for token-only scope validation and visibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants