-
Notifications
You must be signed in to change notification settings - Fork 417
MSC4326: Device masquerading for appservices #4326
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| # MSC4326: Device masquerading for appservices | ||
|
|
||
| *History*: This proposal is split off from [MSC3202: Encrypted Appservices](https://github.com/matrix-org/matrix-spec-proposals/pull/3202). | ||
|
|
||
| Appservices today can make requests as any (local) user in their namespace through [identity assertion](https://spec.matrix.org/v1.15/application-service-api/#identity-assertion). | ||
| To support end-to-end encryption and other similar device-centric functionality, appservices need to | ||
| be able to also pick the device ID they are speaking as. | ||
|
|
||
| This proposal adds device ID to the identity assertion appservices can already perform, leaving other | ||
| aspects of end-to-end encryption support to other MSCs like MSC3202 (mentioned above). | ||
|
|
||
|
|
||
| ## Proposal | ||
|
|
||
| To complement the (optional) `user_id` query string parameter during identity assertion, an also-optional | ||
| `device_id` parameter is also supported. The new `device_id` parameter is only available when `user_id` | ||
| is available to the caller - when authenticating using an `as_token`. | ||
|
|
||
| When both a `user_id` and `device_id` are provided, and both are known/registered, the server uses those | ||
| details for the remainder of the request. For many endpoints this means updating the "last seen IP" | ||
| and "last seen timestamp" for the device, though for some endpoints it may mean interacting with the | ||
| device specifically (such as when uploading one-time keys). | ||
|
|
||
| If the `device_id` does not already exist on the `user_id`, the server returns a `400 M_UNKNOWN_DEVICE` | ||
| standard error response. | ||
|
|
||
| If the `device_id` is present without a `user_id`, the `user_id` is assumed to be the appservice's | ||
| default sender (the user implied by `sender_localpart` in its registration). This is the same behaviour | ||
| as today when the appservice makes such requests. | ||
|
|
||
| If the `device_id` is present and the requester is not able to use identity assertion, the request | ||
| continues as though the `device_id` parameter was never present. This copies the behaviour of `user_id`. | ||
|
|
||
| ### Examples | ||
|
|
||
| *All examples assume the `user_id` is within the appservice's scope.* | ||
|
|
||
| User ID asserted, but not device ID: | ||
|
|
||
| ```text | ||
| GET /_matrix/client/v3/account/whoami?user_id=@alice:example.org | ||
| Authorization: Bearer as_token_here | ||
|
|
||
| { | ||
| "user_id": "@alice:example.org", | ||
| "is_guest": false | ||
| } | ||
| ``` | ||
|
|
||
| User ID and device ID asserted: | ||
|
|
||
| ```text | ||
| GET /_matrix/client/v3/account/whoami?user_id=@alice:example.org&device_id=ABC123 | ||
| Authorization: Bearer as_token_here | ||
|
|
||
| { | ||
| "user_id": "@alice:example.org", | ||
| "is_guest": false, | ||
| "device_id": "ABC123" | ||
| } | ||
| ``` | ||
|
|
||
| Just device ID asserted: | ||
|
|
||
| ```text | ||
| GET /_matrix/client/v3/account/whoami?device_id=ABC123 | ||
| Authorization: Bearer as_token_here | ||
|
|
||
| { | ||
| "user_id": "@the_appservice_sender:example.org", | ||
| "is_guest": false, | ||
| "device_id": "ABC123" | ||
| } | ||
| ``` | ||
|
|
||
| Nothing asserted: | ||
|
|
||
| ```text | ||
| GET /_matrix/client/v3/account/whoami | ||
| Authorization: Bearer as_token_here | ||
|
|
||
| { | ||
| "user_id": "@the_appservice_sender:example.org", | ||
| "is_guest": false | ||
| } | ||
| ``` | ||
|
|
||
| ## Potential issues | ||
|
|
||
| Appservices will need to create and manage their users' devices using another proposal or system. An | ||
| example is [MSC4190](https://github.com/matrix-org/matrix-spec-proposals/pull/4190). | ||
|
|
||
|
|
||
| ## Alternatives | ||
|
|
||
| None relevant. | ||
|
|
||
|
|
||
| ## Security considerations | ||
|
|
||
| The behaviour of `device_id` is largely copied from `user_id`, so should not increase or decrease an | ||
| appservice's capabilities beyond what it could already do. This is especially true for appservices | ||
| which cover "real" users in their namespaces: while they couldn't (and still can't) access data encrypted | ||
| before using something like [MSC3202](https://github.com/matrix-org/matrix-spec-proposals/pull/3202), | ||
| they could log out whatever devices they don't want and register new ones accordingly. | ||
|
|
||
|
|
||
| ## Unstable prefix | ||
|
|
||
| For historical reasons, unstable implementations of this proposal should use `org.matrix.msc3202.device_id` | ||
| instead of `device_id`. | ||
|
|
||
| `ORG.MATRIX.MSC4326.M_UNKNOWN_DEVICE` is used as the error code instead of `M_UNKNOWN_DEVICE`. | ||
|
|
||
| ## Dependencies | ||
|
|
||
| None relevant. Some MSCs depend on this MSC's functionality, however. |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Implementation requirements are met through MSC3202, specifically this bit of Synapse and the listed appservice/bot usage.