Repository navigation
ref(users): Narrow request.user in user, auth and relocation endpoints - #129418
Merged
Merged
Conversation
Contributor
Sentry Snapshot Testing
|
gricha
force-pushed
the
ref/sa-narrow-users
branch
from
November 1, 2026 04:24
1680b0e to
27d5e3b
Compare
gricha
force-pushed
the
ref/sa-narrow-users
branch
from
November 1, 2026 04:57
27d5e3b to
f761ad0
Compare
gricha
force-pushed
the
ref/sa-narrow-users
branch
2 times, most recently
from
November 2, 2026 20:14
1d5622f to
9154896
Compare
gricha
force-pushed
the
ref/sa-narrow-users
branch
3 times, most recently
from
November 2, 2026 20:35
9c5f789 to
e6bd2e1
Compare
gricha
marked this pull request as ready for review
November 2, 2026 20:57
gricha
force-pushed
the
ref/sa-narrow-users
branch
from
November 2, 2026 22:08
e6bd2e1 to
d31da16
Compare
gricha
force-pushed
the
ref/sa-narrow-users
branch
2 times, most recently
from
November 2, 2026 23:08
0c74149 to
828069c
Compare
gricha
force-pushed
the
ref/sa-narrow-users
branch
2 times, most recently
from
November 2, 2026 23:31
7fa9fa4 to
ef4805a
Compare
gricha
force-pushed
the
ref/sa-narrow-users
branch
3 times, most recently
from
November 3, 2026 04:03
80a5541 to
eb1401f
Compare
gricha
force-pushed
the
ref/sa-narrow-users
branch
from
November 3, 2026 04:41
eb1401f to
96e6f45
Compare
cvxluo
approved these changes
Nov 3, 2026
cvxluo
left a comment
Contributor
There was a problem hiding this comment.
lgtm though prob want a security review for this one
Member
Author
|
good point, i'll see if I can get Michelle's eye on it! |
michelletran-sentry
approved these changes
Nov 3, 2026
gricha
force-pushed
the
ref/sa-narrow-users
branch
from
November 3, 2026 19:53
96e6f45 to
38ace18
Compare
gricha
force-pushed
the
ref/sa-narrow-users
branch
from
November 3, 2026 20:09
38ace18 to
db4d84f
Compare
User, auth, auth_v2 and relocation code reads the caller through `sentry.auth.principal`: person-only paths (passwords, 2FA, account merge, relocation creator) use `require_user()`, self checks in user permissions use `is_acting_user()`, "mine" lookups (relocation list, `id:me`) use `owned_by_acting_user()`, and logs use `acting_user_id()`. `access.from_user()`, `normalize_valid_user()` and `SessionSerializer.serialize()` take a service account (type-only). - A service account gets an empty relocation list instead of 403 (new test); creating or retrying one is 403 `user-required`. User and auth_v2 endpoints are control-silo. - An API key deleting a user's last primary authenticator with backup codes gets 401 instead of a 500. - Users and agents see no change.
gricha
force-pushed
the
ref/sa-narrow-users
branch
from
November 3, 2026 20:51
db4d84f to
4aa6817
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User, auth, auth_v2 and relocation code reads the caller through
sentry.auth.principal: person-only paths (passwords, 2FA, account merge, relocation creator) userequire_user(), self checks in user permissions useis_acting_user(), "mine" lookups (relocation list) useowned_by_acting_user(),id:meadds the caller's id only when there is one, and logs useacting_user_id().access.from_user(),normalize_valid_user()andSessionSerializer.serialize()take a service account (type-only). Session auth flags are skipped for a service account (has_user()), as they are for anonymous callers; before, setting them raised.Also fixes the account on backup-code removal: when an admin removes another user's last authenticator, the recovery-code removal was logged under the admin's user id (
account=request.user). It now records the owner, like the other removal calls; the actor stays the caller.test_superuser_removing_last_authenticator_logs_the_ownerfails without it (assert [3, 2] == [2, 2]). Found by Warden.Password change checks for a user before saving the new password, so a caller with no user (system auth) gets 401 without changing anything.
user-required. User and auth_v2 endpoints are control-silo.Left:
user_authenticator_details.pypasses the caller tocapture_security_activityon a path API keys reach, so it stays on #129402's mypy allowlist.