Compare commits

...

3 commits

Author SHA1 Message Date
Tulir Asokan 2f2049b854
Merge fe6c97f498 into c8c2110c3b 2026-01-21 01:09:36 +05:00
Kévin Commaille c8c2110c3b
Spec Account management for OAuth 2.0 API (#2270)
Some checks are pending
Spec / 🔎 Validate OpenAPI specifications (push) Waiting to run
Spec / 🔎 Check Event schema examples (push) Waiting to run
Spec / 🔎 Check OpenAPI definitions examples (push) Waiting to run
Spec / 🔎 Check JSON Schemas inline examples (push) Waiting to run
Spec / ⚙️ Calculate baseURL for later jobs (push) Waiting to run
Spec / 🐍 Build OpenAPI definitions (push) Blocked by required conditions
Spec / 📢 Run towncrier for changelog (push) Waiting to run
Spec / 📖 Build the spec (push) Blocked by required conditions
Spec / 🔎 Validate generated HTML (push) Blocked by required conditions
Spec / 📖 Build the historical backup spec (push) Blocked by required conditions
Spec / Create release (push) Blocked by required conditions
Spell Check / Spell Check with Typos (push) Waiting to run
* Spec Account management for OAuth 2.0 API

As per MSC4191.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Add changelog

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Fix field name

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Bump Matrix version

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Apply suggestions from code review

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Remove justification

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Add fields to example

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Use definition shortcode for account management server metadata

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Use definition shortcode for account management URL query parameters

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Apply suggestion for account management actions

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Add copyright and license

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Remove enum for actions

It doesn't make sense to have the action schema in a separate file now
that only the `type` is shared.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Use "server" instead of "homeserver"

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2026-01-20 11:06:45 -07:00
Tulir Asokan fe6c97f498 Specify basic validation for federation membership endpoints
Signed-off-by: Tulir Asokan <tulir@maunium.net>
2025-12-21 15:31:36 +02:00
13 changed files with 278 additions and 10 deletions

View file

@ -0,0 +1 @@
Add the account management capabilities for the OAuth 2.0 authentication API, as per [MSC4191](https://github.com/matrix-org/matrix-spec-proposals/pull/4191).

View file

@ -0,0 +1 @@
Specified input validation for PDUs passed to federation membership endpoints.

View file

@ -645,7 +645,7 @@ manage their account like [changing their password](#password-management),
[deactivating their account](#account-deactivation). [deactivating their account](#account-deactivation).
With the OAuth 2.0 API, all account management is done via the homeserver's web With the OAuth 2.0 API, all account management is done via the homeserver's web
UI. UI that can be accessed by users via the [account management URL](#oauth-20-account-management).
### Legacy API ### Legacy API
@ -2271,6 +2271,46 @@ The server SHOULD return one of the following responses:
- For other errors, the server returns a `400 Bad Request` response with error - For other errors, the server returns a `400 Bad Request` response with error
details details
#### Account management {id="oauth-20-account-management"}
{{% added-in v="1.18" %}}
All account management is done via the homeserver's web UI.
This specification defines extensions to the [OAuth Authorization Server
Metadata registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#authorization-server-metadata)
to offer clients a way to deep-link to the account management capabilities of
the homeserver to allow the user to complete the account management operations
in a browser.
##### Account management URL discovery
The [OAuth 2.0 authorization server metadata](#server-metadata-discovery) is
extended to include the following **optional** fields.
{{% definition path="schemas/oauth2-account-management-server-metadata" %}}
##### Account management URL parameters
The account management URL MAY accept the following minimum query parameters.
{{% definition path="schemas/oauth2-account-management-url" %}}
##### Account management URL actions
Account management actions are unique to the application. They SHOULD follow the
[Common Namespaced Identifier Grammar](/appendices/#common-namespaced-identifier-grammar)
where feasible. The Matrix-specific actions are:
| Action | Description |
|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `org.matrix.profile` | The user wishes to view/edit their profile (name, avatar, contact details). |
| `org.matrix.devices_list` | The user wishes to view a list of their devices. |
| `org.matrix.device_view` | The user wishes to view the details of a specific device. A `device_id` SHOULD be provided. |
| `org.matrix.device_delete` | The user wishes to delete/log out a specific device. A `device_id` SHOULD be provided. |
| `org.matrix.account_deactivate` | The user wishes to deactivate their account. |
| `org.matrix.cross_signing_reset` | The user wishes to reset their cross-signing identity. Servers SHOULD use this action in the URL of the [`m.oauth`](#oauth-authentication) UIA type. |
### Account moderation ### Account moderation
#### Account locking #### Account locking

View file

@ -139,6 +139,32 @@ paths:
items: items:
type: string type: string
description: A prompt value that the server supports. description: A prompt value that the server supports.
account_management_uri:
x-addedInMatrixVersion: "1.18"
type: string
format: uri
description: |-
The URL where the user is able to access the account management capabilities
of the homeserver.
This is an extension [defined in this specification](/client-server-api/#oauth-20-account-management).
account_management_actions_supported:
x-addedInMatrixVersion: "1.18"
type: array
description: |-
List of actions that the account management URL supports.
This is an extension [defined in this specification](/client-server-api/#oauth-20-account-management).
items:
type: string
enum:
- "org.matrix.profile"
- "org.matrix.devices_list"
- "org.matrix.device_view"
- "org.matrix.device_delete"
- "org.matrix.account_deactivate"
- "org.matrix.cross_signing_reset"
description: An action that the account management URL supports.
required: required:
- issuer - issuer
- authorization_endpoint - authorization_endpoint
@ -159,6 +185,15 @@ paths:
"grant_types_supported": ["authorization_code", "refresh_token"], "grant_types_supported": ["authorization_code", "refresh_token"],
"response_modes_supported": ["query", "fragment"], "response_modes_supported": ["query", "fragment"],
"code_challenge_methods_supported": ["S256"], "code_challenge_methods_supported": ["S256"],
"account_management_uri": "https://account.example.com/manage",
"account_management_actions_supported": [
"org.matrix.profile",
"org.matrix.devices_list",
"org.matrix.device_view",
"org.matrix.device_delete",
"org.matrix.account_deactivate",
"org.matrix.cross_signing_reset",
],
} }
tags: tags:
- Session management - Session management

View file

@ -172,6 +172,17 @@ paths:
} }
"400": "400":
description: |- description: |-
The `M_INVALID_PARAM` error code is used to indicate one or more of the following:
* The invite event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`.
* The `membership` field inside the event content is not `invite`.
* The event sender is not a user ID on the origin server.
* The `state_key` is not a user ID on the receiving server.
Servers MUST apply the validation above to the invite event before
signing it regardless of room version.
The `M_MISSING_PARAM` error code is used to indicate one or more of The `M_MISSING_PARAM` error code is used to indicate one or more of
the following: the following:
@ -186,9 +197,9 @@ paths:
Servers MAY apply the validation above to room versions 1 through 11, Servers MAY apply the validation above to room versions 1 through 11,
and SHOULD apply the validation above to all other room versions. and SHOULD apply the validation above to all other room versions.
If `M_MISSING_PARAM` is returned and the request is associated with a If `M_MISSING_PARAM` or `M_INVALID_PARAM` is returned and the request
Client-Server API request, the Client-Server API request SHOULD fail is associated with a Client-Server API request, the Client-Server API
with a 5xx error rather than being passed through. request SHOULD fail with a 5xx error rather than being passed through.
content: content:
application/json: application/json:
schema: schema:

View file

@ -154,6 +154,17 @@ paths:
The error should be passed through to clients so that they The error should be passed through to clients so that they
may give better feedback to users. may give better feedback to users.
The `M_INVALID_PARAM` error code is used to indicate one or more of the following:
* The invite event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`.
* The `membership` field inside the event content is not `invite`.
* The event sender is not a user ID on the origin server.
* The `state_key` is not a user ID on the receiving server.
Servers MUST apply the validation above to the invite event before
signing it regardless of room version.
The `M_MISSING_PARAM` error code is used to indicate one or more of The `M_MISSING_PARAM` error code is used to indicate one or more of
the following: the following:
@ -168,9 +179,9 @@ paths:
Servers MAY apply the validation above to room versions 1 through 11, Servers MAY apply the validation above to room versions 1 through 11,
and SHOULD apply the validation above to all other room versions. and SHOULD apply the validation above to all other room versions.
If `M_MISSING_PARAM` is returned and the request is associated with a If `M_MISSING_PARAM` or `M_INVALID_PARAM` is returned and the request
Client-Server API request, the Client-Server API request SHOULD fail is associated with a Client-Server API request, the Client-Server API
with a 5xx error rather than being passed through. request SHOULD fail with a 5xx error rather than being passed through.
content: content:
application/json: application/json:
schema: schema:

View file

@ -36,7 +36,7 @@ paths:
type: string type: string
- in: path - in: path
name: userId name: userId
description: The user ID the join event will be for. description: The user ID the join event will be for. This MUST be a user ID on the origin server.
required: true required: true
example: "@someone:example.org" example: "@someone:example.org"
schema: schema:
@ -388,6 +388,43 @@ paths:
} }
} }
] ]
"400":
description: |-
The request is invalid in some way.
The `M_INVALID_PARAM` error code is used to indicate one or more of the following:
* The join event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`.
* The `membership` field inside the event content is not `join`.
* The event sender is not a user ID on the origin server.
* The `state_key` is not equal to the `sender`.
Servers MUST apply the validation above to the join event.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_INVALID_PARAM",
"error": "Not a join event."
}
"403":
description: |-
The room that the joining server is attempting to join does not permit the user
to join.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_FORBIDDEN",
"error": "You are not invited to this room"
}
servers: servers:
- url: "{protocol}://{hostname}{basePath}" - url: "{protocol}://{hostname}{basePath}"
variables: variables:

View file

@ -247,6 +247,16 @@ paths:
The error should be passed through to clients so that they The error should be passed through to clients so that they
may give better feedback to users. may give better feedback to users.
The `M_INVALID_PARAM` error code is used to indicate one or more of the following:
* The join event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`.
* The `membership` field inside the event content is not `join`.
* The event sender is not a user ID on the origin server.
* The `state_key` is not equal to the `sender`.
Servers MUST apply the validation above to the join event.
New in `v1.2`, the following error conditions might happen: New in `v1.2`, the following error conditions might happen:
If the room is [restricted](/client-server-api/#restricted-rooms) If the room is [restricted](/client-server-api/#restricted-rooms)

View file

@ -36,7 +36,7 @@ paths:
type: string type: string
- in: path - in: path
name: userId name: userId
description: The user ID the knock event will be for. description: The user ID the knock event will be for. This MUST be a user ID on the origin server.
required: true required: true
example: "@someone:example.org" example: "@someone:example.org"
schema: schema:
@ -330,6 +330,27 @@ paths:
"$ref": "./examples/invite_or_knock_state.json" "$ref": "./examples/invite_or_knock_state.json"
} }
} }
"400":
description: |-
The `M_INVALID_PARAM` error code is used to indicate one or more of the following:
* The knock event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`.
* The `membership` field inside the event content is not `knock`.
* The event sender is not a user ID on the origin server.
* The `state_key` is not equal to the `sender`.
Servers MUST apply the validation above to the knock event.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_INVALID_PARAM",
"error": "Not a knock event."
}
"403": "403":
description: |- description: |-
The knocking server or user is not permitted to knock on the room, such as when the The knocking server or user is not permitted to knock on the room, such as when the

View file

@ -36,7 +36,7 @@ paths:
type: string type: string
- in: path - in: path
name: userId name: userId
description: The user ID the leave event will be for. description: The user ID the leave event will be for. This MUST be a user ID on the origin server.
required: true required: true
example: "@someone:example.org" example: "@someone:example.org"
schema: schema:
@ -249,6 +249,27 @@ paths:
200, 200,
{} {}
] ]
"400":
description: |-
The `M_INVALID_PARAM` error code is used to indicate one or more of the following:
* The leave event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`.
* The `membership` field inside the event content is not `leave`.
* The event sender is not a user ID on the origin server.
* The `state_key` is not equal to the `sender`.
Servers MUST apply the validation above to the leave event.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_INVALID_PARAM",
"error": "Not a leave event."
}
servers: servers:
- url: "{protocol}://{hostname}{basePath}" - url: "{protocol}://{hostname}{basePath}"
variables: variables:

View file

@ -134,6 +134,27 @@ paths:
examples: examples:
response: response:
value: {} value: {}
"400":
description: |-
The `M_INVALID_PARAM` error code is used to indicate one or more of the following:
* The leave event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`.
* The `membership` field inside the event content is not `leave`.
* The event sender is not a user ID on the origin server.
* The `state_key` is not equal to the `sender`.
Servers MUST apply the validation above to the leave event.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_INVALID_PARAM",
"error": "Not a leave event."
}
servers: servers:
- url: "{protocol}://{hostname}{basePath}" - url: "{protocol}://{hostname}{basePath}"
variables: variables:

View file

@ -0,0 +1,30 @@
# Copyright 2026 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
type: object
title: OAuth 2.0 Server Metadata Account Management Extension
properties:
account_management_uri:
type: string
format: uri
description: |-
The URL where the user is able to access the account management capabilities of the
server.
account_management_actions_supported:
type: array
description: |-
List of [actions](/client-server-api/#account-management-url-actions) that the account
management URL supports.
items:
type: string
description: An action that the account management URL supports.

View file

@ -0,0 +1,29 @@
# Copyright 2026 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
type: object
title: OAuth 2.0 Account Management URL Query Parameters
properties:
action:
type: string
description: |-
The action that the user wishes to take. Must match one of the actions advertised by the
server in [`account_management_actions_supported`](/client-server-api/#account-management-url-discovery).
device_id:
type: string
description: |-
For Matrix-specific actions, the user's device ID. Actions which don't support the device ID
will ignore it.
If the `org.matrix.device_view` or `org.matrix.device_delete` actions are advertised as
supported by the server then the server SHOULD support the `device_id` parameter.