Skip to content

Commit 10a4a7f

Browse files
runningcodeclaude
andcommitted
fix(preprod): Allow org auth tokens to access build install-details
The public install-details endpoint inherited OrganizationPermission which only accepts org:read scope. Org auth tokens used in CI have org:ci scope, so sentry-cli build download failed while build upload worked. Switch to OrganizationReleasePermission which accepts org:ci, matching the permission class used by the upload endpoints. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d32591e commit 10a4a7f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/sentry/preprod/api/endpoints/public/organization_preprod_artifact_install_details.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from sentry.api.api_owners import ApiOwner
99
from sentry.api.api_publish_status import ApiPublishStatus
1010
from sentry.api.base import cell_silo_endpoint
11-
from sentry.api.bases.organization import OrganizationEndpoint
11+
from sentry.api.bases.organization import OrganizationEndpoint, OrganizationReleasePermission
1212
from sentry.apidocs.constants import RESPONSE_FORBIDDEN, RESPONSE_NOT_FOUND
1313
from sentry.apidocs.examples.preprod_examples import PreprodExamples
1414
from sentry.apidocs.parameters import GlobalParams
@@ -30,6 +30,7 @@ class OrganizationPreprodArtifactPublicInstallDetailsEndpoint(OrganizationEndpoi
3030
publish_status = {
3131
"GET": ApiPublishStatus.PUBLIC,
3232
}
33+
permission_classes = (OrganizationReleasePermission,)
3334
rate_limits = RateLimitConfig(
3435
limit_overrides={
3536
"GET": {

tests/sentry/preprod/api/endpoints/public/test_organization_preprod_artifact_install_details.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from django.urls import reverse
22

3+
from sentry.models.orgauthtoken import OrgAuthToken
34
from sentry.preprod.models import PreprodArtifact
5+
from sentry.silo.base import SiloMode
46
from sentry.testutils.cases import APITestCase
7+
from sentry.testutils.silo import assume_test_silo_mode
8+
from sentry.utils.security.orgauthtoken_token import generate_token, hash_token
59

610

711
class OrganizationPreprodArtifactPublicInstallDetailsEndpointTest(APITestCase):
@@ -162,3 +166,19 @@ def test_ios_artifact_invalid_signature(self):
162166
assert data["isInstallable"] is False
163167
assert data["installUrl"] is None
164168
assert data["isCodeSignatureValid"] is False
169+
170+
def test_org_auth_token_with_org_ci_scope(self):
171+
"""Org auth tokens with org:ci scope can access install details (used by sentry-cli build download)."""
172+
token_str = generate_token(self.organization.slug, "")
173+
with assume_test_silo_mode(SiloMode.CONTROL):
174+
OrgAuthToken.objects.create(
175+
organization_id=self.organization.id,
176+
name="CI Token",
177+
token_hashed=hash_token(token_str),
178+
scope_list=["org:ci"],
179+
)
180+
181+
response = self.client.get(self._get_url(), HTTP_AUTHORIZATION=f"Bearer {token_str}")
182+
assert response.status_code == 200
183+
data = response.json()
184+
assert data["buildId"] == str(self.preprod_artifact.id)

0 commit comments

Comments
 (0)