-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(auth): Return auth error if application is requesting a wrong org #81193
Conversation
a09ec51
to
9c162e6
Compare
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #81193 +/- ##
=======================================
Coverage 80.35% 80.35%
=======================================
Files 7221 7220 -1
Lines 319612 319588 -24
Branches 20783 20783
=======================================
- Hits 256821 256802 -19
+ Misses 62396 62391 -5
Partials 395 395 |
Adding scoping_organization_id to both ApiTokenReplica and SystemToken. The reason is that we want to limit auth tokens that are scoped to a specific organizations to any other organization. Context on why we need this is here: #81193
5901cc4
to
4a5d219
Compare
src/sentry/api/authentication.py
Outdated
) | ||
# We want to limit org scoped tokens access to org level endpoints only | ||
# Or none org level endpoints that we added special treatments for | ||
if resolved_url.url_name not in ["sentry-api-0-organizations"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's safe to allowlist usage of this endpoint even though the endpoint is not specific to one organization because this case is already handled in the endpoint code: https://github.com/getsentry/sentry/blob/master/src/sentry/api/endpoints/organization_index.py#L98
So basically if I call this endpoint to list organizations of one person with a token that only has access to one of them the endpoint only returns that one.
I should add it's also important and required to allowlist this endpoint because for a partner who doesn't store any sentry data like organization id, this is the only way to get the organization id they want to query on.
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Adding scoping_organization_id to both ApiTokenReplica and SystemToken. The reason is that we want to limit auth tokens that are scoped to a specific organizations to any other organization. Context on why we need this is here: #81193
#81193) If an application is organization scope application, their tokens will only have access to one organization of a user. So we should return auth error if: 1. They're calling an API on an organization that is not the same as the org in the token 2. They're calling an API that is not limited to one organization, for example list all user's project [In a previous PR](#80012) I added some logging to make sure this doesn't break other integrations. It actually does, so I have to limit this to token.scoping_organization_id vs token.organization_id
If an application is organization scope application, their tokens will only have access to one organization of a user. So we should return auth error if:
In a previous PR I added some logging to make sure this doesn't break other integrations. It actually does, so I have to limit this to token.scoping_organization_id vs token.organization_id