Skip to content

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
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 Jan 14, 2021
d923a45
contacts is required non-empty
hughns Sep 7, 2023
2bdcc4a
Make client_uri mandatory
hughns Sep 7, 2023
d4caa5a
Merge branch 'matrix-org:main' into msc/sandhose/oauth2-dynamic-regis…
sandhose Sep 3, 2024
32c9ead
Rework MSC
sandhose Sep 12, 2024
1ba6ce9
Mention the `token_endpoint_auth_method` client metadata
sandhose Dec 9, 2024
6eb5fdf
Update proposals/2966-oauth2-dynamic-registration.md
sandhose Dec 9, 2024
a67a2e8
State that the homeserver should display the tos_uri and policy_uri
sandhose Jan 16, 2025
d9fd175
Make the wording for the refresh token clearer
sandhose Jan 16, 2025
a7ddac2
Clarify that native callbacks with no slashes are allowed
sandhose Jan 16, 2025
4deb3c8
Give an example where the server ignores an unsupported grant type
sandhose Jan 16, 2025
0e2f0f1
Add security considerations
sandhose Jan 17, 2025
2a20e6d
must -> MUST, should -> SHOULD, may -> MAY
sandhose Jan 22, 2025
c7e55ec
Clarify the client should store the client_id
sandhose Jan 22, 2025
fe4ef69
Simplify definition of client_uri, already covered by the RFC
sandhose Jan 22, 2025
24d0ab8
Explain the point of the MSC earlier
sandhose Mar 5, 2025
fae9c29
Remove empty section
sandhose Mar 5, 2025
f3d30e9
Explicitly state that the client_uri is required
sandhose Mar 5, 2025
a65bd6b
Apply suggestions from code review
sandhose Mar 5, 2025
1768d54
Fix the web/native client sub-sub-sub sections
sandhose Mar 5, 2025
a98b2ba
Clarify the localhost port-less redirect URIs
sandhose Mar 5, 2025
6e32a71
The server should return a 201 on successful registration
sandhose Mar 5, 2025
8b2f387
Explain better the restrictions on URIs
sandhose Mar 13, 2025
03ba6f2
Allow custom ports in the redirect URI
sandhose Mar 13, 2025
6b03a53
Client regs won't grow exponentially
sandhose Mar 13, 2025
b6abea5
Explain how to mitigate the problem of client registrations growing o…
sandhose Mar 13, 2025
650a449
Add missing metadata in the dynamic registration response
sandhose Mar 18, 2025
15a3c87
Make 'metadata localization' its own sub-sub-sub-sub-section
sandhose Mar 25, 2025
4d7ff6c
Server may still deduplicate registrations
sandhose Mar 25, 2025
a0e8b37
Suggest different strategies to mitigate the growing number of client…
sandhose Mar 25, 2025
1f489ee
Let the server delete client registrations that have no active sessions
sandhose Mar 26, 2025
ee36393
Really, shoud MUST do a new client reg
sandhose Mar 26, 2025
55433db
Make sure the summary doesn't sound authoritative
sandhose Mar 31, 2025
70f017c
Put the links at the end of the file
sandhose Mar 31, 2025
dbb6163
Explain what is Matrix-specific, what is not
sandhose Mar 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions proposals/2966-oauth2-dynamic-registration.md
Copy link
Member

@turt2live turt2live Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation requirements:

  • Client using web flow
  • Client using native flow
  • Server supporting both flows (may be two different servers)

Copy link
Member Author

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:

  • Element Web

Known working clients with the native flow:

  • Element Desktop
  • Element X iOS
  • Element X Android

Server supporting both:

  • Synapse with Matrix Authentication Service
  • Dendrite with Matrix Authentication Service (PR)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

## 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).

### 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 |
| `redirect_uris` | Array of redirection URIs for use in redirect-based flows | Required with the `authorization_code` grant ype | No |
| `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.

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.
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.