-
Notifications
You must be signed in to change notification settings - Fork 401
MSC2966: Usage of OAuth 2.0 Dynamic Client Registration in Matrix #2966
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
turt2live
merged 35 commits into
matrix-org:main
from
sandhose:msc/sandhose/oauth2-dynamic-registration
Apr 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
1b1bcdd
OAuth 2.0 Dynamic Registration MSC
sandhose d923a45
contacts is required non-empty
hughns 2bdcc4a
Make client_uri mandatory
hughns d4caa5a
Merge branch 'matrix-org:main' into msc/sandhose/oauth2-dynamic-regis…
sandhose 32c9ead
Rework MSC
sandhose 1ba6ce9
Mention the `token_endpoint_auth_method` client metadata
sandhose 6eb5fdf
Update proposals/2966-oauth2-dynamic-registration.md
sandhose a67a2e8
State that the homeserver should display the tos_uri and policy_uri
sandhose d9fd175
Make the wording for the refresh token clearer
sandhose a7ddac2
Clarify that native callbacks with no slashes are allowed
sandhose 4deb3c8
Give an example where the server ignores an unsupported grant type
sandhose 0e2f0f1
Add security considerations
sandhose 2a20e6d
must -> MUST, should -> SHOULD, may -> MAY
sandhose c7e55ec
Clarify the client should store the client_id
sandhose fe4ef69
Simplify definition of client_uri, already covered by the RFC
sandhose 24d0ab8
Explain the point of the MSC earlier
sandhose fae9c29
Remove empty section
sandhose f3d30e9
Explicitly state that the client_uri is required
sandhose a65bd6b
Apply suggestions from code review
sandhose 1768d54
Fix the web/native client sub-sub-sub sections
sandhose a98b2ba
Clarify the localhost port-less redirect URIs
sandhose 6e32a71
The server should return a 201 on successful registration
sandhose 8b2f387
Explain better the restrictions on URIs
sandhose 03ba6f2
Allow custom ports in the redirect URI
sandhose 6b03a53
Client regs won't grow exponentially
sandhose b6abea5
Explain how to mitigate the problem of client registrations growing o…
sandhose 650a449
Add missing metadata in the dynamic registration response
sandhose 15a3c87
Make 'metadata localization' its own sub-sub-sub-sub-section
sandhose 4d7ff6c
Server may still deduplicate registrations
sandhose a0e8b37
Suggest different strategies to mitigate the growing number of client…
sandhose 1f489ee
Let the server delete client registrations that have no active sessions
sandhose ee36393
Really, shoud MUST do a new client reg
sandhose 55433db
Make sure the summary doesn't sound authoritative
sandhose 70f017c
Put the links at the end of the file
sandhose dbb6163
Explain what is Matrix-specific, what is not
sandhose 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,99 @@ | ||
# MSC2966: Usage of OAuth 2.0 Dynamic Client Registration in Matrix | ||
|
||
[MSC2964](https://github.com/matrix-org/matrix-doc/pull/2964) defines how client should login against a Matrix server using OAuth 2.0. | ||
It assumes the client is known to the authentication server. | ||
|
||
This MSC specifies how Matrix clients should leverage OAuth 2.0 Dynamic Client Registration Protocol ([RFC 7591](https://tools.ietf.org/html/rfc7591)) to register themselves before initiating the login flow. | ||
|
||
sandhose marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Proposal | ||
|
||
If a Matrix server wants to be used by any third-party client, its authentication server must allow dynamic registration of OAuth 2.0 clients. | ||
The client registration endpoint is advertised in the OIDC discovery document and can be used as per [RFC 7591 sec. 3](https://tools.ietf.org/html/rfc7591#section-3). | ||
turt2live marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Client metadata | ||
|
||
When registering itself, a client must provide a list of metadata about itself. | ||
|
||
As per [RFC 7591 sec. 2.2](https://tools.ietf.org/html/rfc7591#section-2.2), some of those metadata values may be localized. | ||
|
||
```json | ||
{ | ||
"client_name": "Digital mailbox", | ||
"client_name#en-US": "Digital mailbox", | ||
"client_name#en-GB": "Digital postbox", | ||
"client_name#fr": "Boîte aux lettres numérique" | ||
} | ||
``` | ||
|
||
Some of those metadatas are optional in the RFC but required in this context. | ||
|
||
| Name | Description | Behaviour | Localizable | | ||
| ---------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | ----------- | | ||
| `client_name` | Human-readable name of the client to be presented to the user | Required | Yes | | ||
| `client_uri` | URL of a web page providing information about the client | Optional | Yes | | ||
| `logo_uri` | URL that references a logo for the client | Optional | Yes | | ||
| `contacts` | Array of strings representing ways to contact people responsible for this client, typically email addresses | Required | No | | ||
| `tos_uri` | URL that points to a human-readable terms of service document for the client | Required | Yes | | ||
| `policy_uri` | URL that points to a human-readable policy document for the client | Required | Yes | | ||
sandhose marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `redirect_uris` | Array of redirection URIs for use in redirect-based flows | Required with the `authorization_code` grant ype | No | | ||
turt2live marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `response_types` | Array of the OAuth 2.0 response types that the client may use | Defaults to `["code"]` | No | | ||
| `grant_types` | Array of OAuth 2.0 grant types that the client may use | Defaults to `["authorization_code"]` | No | | ||
|
||
Other metadata registered in the IANA [OAuth Dynamic Client Registration Metadata](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#client-metadata) registry might be used and supported by Matrix servers and clients. | ||
|
||
### User consent | ||
|
||
When authorizing a third-party client for the first time, the authorization server must ask for explicit user consent and display as much information, preferably localized, about the client as possible. | ||
This includes informations about the publisher, the clients terms of service and its policy. | ||
|
||
The consent screen must include a human-readable list of the scopes requested by the client. | ||
|
||
### Metadata signature | ||
|
||
To securely identify themselves, clients must send a digitally signed version of their metadata. | ||
This is done by encoding the client metadata in a JWT and signing it. | ||
sandhose marked this conversation as resolved.
Show resolved
Hide resolved
sandhose marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
In addition the client metadata mentioned earlier, the JWT payload must include the following: | ||
|
||
- `iss`: the entity signing the token. This must allow the authorization server to discover the JWT keys of the issuer. | ||
- `iat`: the timestamp when the JWT was signed | ||
- `exp`: a timestamp after which the JWT isn't valid anymore | ||
- `software_id`: a random string uniquely identifying this instance. A random UUIDv4 is suggested for this field | ||
|
||
This allows client to securely update their metadata without being considered as a new client and re-asking user consent. | ||
|
||
The `software_id` is used to uniquely identify a client and ensure the same `client_id` is returned on subsequent registration. | ||
Each `software_id` is tied to the issuer (`iss`) and therefore subsequent registration must be signed by the same issuer. | ||
|
||
The issuer keys can be retrieved using its [OIDC discovery document](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata) (`<iss>/.well-known/openid-configuration`) or its [authorization server metadata](https://tools.ietf.org/html/rfc8414) (`<iss>/.well-known/oauth-authorization-server`). | ||
The issuer does not have to be an actual authorization server, but its metadata can include human-readable informations about the issuer. | ||
Those informations can be displayed on the user consent screen to tell the user about the client's publisher. | ||
|
||
The JWT payload may also include a `software_version` claim denoting the version of the client being registered. | ||
This field should be treated as an opaque string by the authorization server. | ||
|
||
A Matrix server may choose to only allow signed client to be registered. | ||
It might also have an list of trusted issuers for software statements and only allow those to restrict third-party clients. | ||
|
||
## Potential issues | ||
|
||
It is unclear how metadata updates should be handled. | ||
If a client changes its `redirect_uris`, should the old ones be considered for a period of time? | ||
If multiple versions of the same client coexist at the same time, should older versions of the software be able to override the metadata of the newer version? | ||
|
||
If an authorization server allows unsigned clients, the number of client registration might explode exponentially. | ||
turt2live marked this conversation as resolved.
Show resolved
Hide resolved
|
||
At the same time, only allowing signed clients can make client development significantly harder. | ||
|
||
## Alternatives | ||
|
||
None relevant. | ||
|
||
## Security considerations | ||
|
||
Nothing prevents intentional collisions in `software_id`. | ||
An attacker could register a `software_id` of another client before its first registration, blocking it from registration. | ||
The registration endpoint should be rate-limited and the failed registration monitored by server administrators to detect such abuses. | ||
|
||
## Unstable prefix | ||
|
||
None relevant. |
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:
web
flownative
flowThere 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.
Known working clients with the web flow:
Known working clients with the native flow:
Server supporting both:
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.
I haven't dug too far to find all the PRs or original implementations, but did find these points of evidence: