Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Revert to using a dummy device ID for appservices user_ips recordings
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin Gliech <quenting@element.io>
  • Loading branch information
sandhose committed Aug 17, 2022
1 parent 1670733 commit f74ff1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,21 @@ async def _wrapped_get_user_by_req(
if ip_addr and (
not requester.app_service or self._track_appservice_user_ips
):
# XXX(quenting): I'm 95% confident that we could skip setting the
# device_id to "dummy-device" for appservices, and that the only impact
# would be that some rows which whould not deduplicate in the 'user_ips'
# table during the transition
recorded_device_id = (
"dummy-device"
if requester.device_id is None and requester.app_service is not None
else requester.device_id
)
await self.store.insert_client_ip(
user_id=requester.authenticated_entity,
access_token=access_token,
ip=ip_addr,
user_agent=user_agent,
device_id=requester.device_id,
device_id=recorded_device_id,
)

# Track also the puppeted user client IP if enabled and the user is puppeting
Expand Down
4 changes: 3 additions & 1 deletion synapse/handlers/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ async def check_username(
400, "User ID already taken.", errcode=Codes.USER_IN_USE
)
if guest_access_token:
user_data = await self.store.get_user_by_access_token(guest_access_token)
user_data = await self.store.get_user_by_access_token(
guest_access_token
)
if not user_data.is_guest or user_data.user.localpart != localpart:
raise AuthError(
403,
Expand Down

0 comments on commit f74ff1f

Please sign in to comment.