Skip to content

Commit 1aa87f0

Browse files
add allowlist
1 parent c660fe0 commit 1aa87f0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/sentry/api/authentication.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from collections.abc import Callable, Iterable
66
from typing import Any, ClassVar
77

8+
import sentry_sdk
89
from django.conf import settings
910
from django.contrib.auth.models import AnonymousUser
1011
from django.urls import resolve
@@ -19,7 +20,6 @@
1920
from rest_framework.exceptions import AuthenticationFailed
2021
from rest_framework.request import Request
2122
from sentry_relay.exceptions import UnpackError
22-
import sentry_sdk
2323

2424
from sentry import options
2525
from sentry.auth.services.auth import AuthenticatedToken
@@ -443,9 +443,11 @@ def authenticate_token(self, request: Request, token_str: str) -> tuple[Any, Any
443443
raise AuthenticationFailed("Unauthorized organization access.")
444444
else:
445445
# We want to limit org scoped tokens access to org level endpoints only
446-
raise AuthenticationFailed(
447-
"This token access is limited to organization endpoints."
448-
)
446+
# Or none org level endpoints that we added special treatments for
447+
if resolved_url.url_name not in ["sentry-api-0-organizations"]:
448+
raise AuthenticationFailed(
449+
"This token access is limited to organization endpoints."
450+
)
449451
else:
450452
sentry_sdk.capture_message(
451453
"Could not resolve organization for organization scoped token", level="warning"

0 commit comments

Comments
 (0)