-
Notifications
You must be signed in to change notification settings - Fork 402
Stabilize support for MSC4326: Device masquerading for appservices #19033
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
Changes from all commits
1b891b0
4ab6e19
1df0881
4dc6ab2
0ee427d
76746e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Stabilized support for [MSC4326](https://github.com/matrix-org/matrix-spec-proposals/pull/4326): Device masquerading for appservices. Contributed by @tulir @ Beeper. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,12 +302,9 @@ async def get_appservice_user( | |
(the user_id URI parameter allows an application service to masquerade | ||
any applicable user in its namespace) | ||
- what device the application service should be treated as controlling | ||
(the device_id[^1] URI parameter allows an application service to masquerade | ||
(the device_id URI parameter allows an application service to masquerade | ||
as any device that exists for the relevant user) | ||
|
||
[^1] Unstable and provided by MSC3202. | ||
Must use `org.matrix.msc3202.device_id` in place of `device_id` for now. | ||
|
||
Returns: | ||
the application service `Requester` of that request | ||
|
||
|
@@ -319,7 +316,8 @@ async def get_appservice_user( | |
- The returned device ID, if present, has been checked to be a valid device ID | ||
for the returned user ID. | ||
""" | ||
DEVICE_ID_ARG_NAME = b"org.matrix.msc3202.device_id" | ||
# TODO: We can drop unstable support after 2026-01-01 (couple months after stable support) | ||
UNSTABLE_DEVICE_ID_ARG_NAME = b"org.matrix.msc3202.device_id" | ||
tulir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
app_service = self.store.get_app_service_by_token(access_token) | ||
if app_service is None: | ||
|
@@ -341,13 +339,11 @@ async def get_appservice_user( | |
else: | ||
effective_user_id = app_service.sender | ||
|
||
effective_device_id: Optional[str] = None | ||
|
||
if ( | ||
self.hs.config.experimental.msc3202_device_masquerading_enabled | ||
and DEVICE_ID_ARG_NAME in request.args | ||
): | ||
effective_device_id = request.args[DEVICE_ID_ARG_NAME][0].decode("utf8") | ||
effective_device_id_args = request.args.get( | ||
b"device_id", request.args.get(UNSTABLE_DEVICE_ID_ARG_NAME) | ||
) | ||
if effective_device_id_args: | ||
effective_device_id = effective_device_id_args[0].decode("utf8") | ||
# We only just set this so it can't be None! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is pre-existing but I don't understand this comment. As far as I can tell, this is user-provided input There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. It makes sense that it can't be Perhaps this was done to appease
I guess we can remove that check altogether. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll leave it for now since the diff no longer touches that line at all |
||
assert effective_device_id is not None | ||
device_opt = await self.store.get_device( | ||
|
@@ -359,6 +355,8 @@ async def get_appservice_user( | |
f"Application service trying to use a device that doesn't exist ('{effective_device_id}' for {effective_user_id})", | ||
Codes.UNKNOWN_DEVICE, | ||
) | ||
else: | ||
effective_device_id = None | ||
|
||
return create_requester( | ||
effective_user_id, app_service=app_service, device_id=effective_device_id | ||
|
Uh oh!
There was an error while loading. Please reload this page.