Skip to content

Commit 866c05f

Browse files
authored
Reorganize client authentication section to separate the legacy API and the new OAuth 2.0 API (#2141)
Since account locking and suspension are authentication API agnostic, this is a pre-requisite to adding the new OAuth 2.0-based API. This also splits the endpoints that where all included in the registration OpenAPI data, to separate them cleanly in the spec, and avoid having deactivation show before registration. Signed-off-by: Kévin Commaille <[email protected]>
1 parent 7470c72 commit 866c05f

File tree

5 files changed

+424
-335
lines changed

5 files changed

+424
-335
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add the OAuth 2.0 based authentication API, as per [MSC3861](https://github.com/matrix-org/matrix-spec-proposals/pull/3861) and its sub-proposals.

content/client-server-api/_index.md

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ endpoints it supports.
439439
Most API endpoints require the user to identify themselves by presenting
440440
previously obtained credentials in the form of an access token.
441441
An access token is typically obtained via the [Login](#login) or
442-
[Registration](#account-registration-and-management) processes. Access tokens
442+
[Registration](#account-registration) processes. Access tokens
443443
can expire; a new access token can be generated by using a refresh token.
444444

445445
{{% boxes/note %}}
@@ -494,7 +494,7 @@ used to generate a new access token and refresh token, the new access
494494
and refresh tokens are now bound to the device associated with the
495495
initial refresh token.
496496

497-
By default, the [Login](#login) and [Registration](#account-registration-and-management)
497+
By default, the [Login](#login) and [Registration](#account-registration)
498498
processes auto-generate a new `device_id`. A client is also free to
499499
generate its own `device_id` or, provided the user remains the same,
500500
reuse a device: in either case the client should pass the `device_id` in
@@ -560,9 +560,11 @@ specifying the device ID it is already using to the login API.
560560
with an `M_USER_LOCKED` error code, cannot obtain a new access token until
561561
the account has been [unlocked](#account-locking).
562562

563-
### User-Interactive Authentication API
563+
### Legacy API
564564

565-
#### Overview
565+
#### User-Interactive Authentication API
566+
567+
##### Overview
566568

567569
Some API endpoints require authentication that interacts with the user.
568570
The homeserver may provide many different ways of authenticating, such
@@ -586,7 +588,7 @@ the flows in order must result in an HTTP 401 response, as defined
586588
below. When all stages in a flow are complete, authentication is
587589
complete and the API call succeeds.
588590

589-
#### User-interactive API in the REST API
591+
##### User-interactive API in the REST API
590592

591593
In the REST API described in this specification, authentication works by
592594
the client and server exchanging JSON dictionaries. The server indicates
@@ -764,7 +766,7 @@ auth by offering a stage with only the `m.login.dummy` auth type, but they
764766
must still give a 401 response to requests with no auth data.
765767
{{% /boxes/note %}}
766768

767-
#### Example
769+
**Example**
768770

769771
At a high level, the requests made for an API call completing an auth
770772
flow with three stages will resemble the following diagram:
@@ -806,7 +808,7 @@ flow with three stages will resemble the following diagram:
806808
|_______________________|
807809
```
808810

809-
#### Authentication types
811+
##### Authentication types
810812

811813
This specification defines the following auth types:
812814
- `m.login.password`
@@ -817,7 +819,7 @@ This specification defines the following auth types:
817819
- `m.login.dummy`
818820
- `m.login.registration_token`
819821

820-
##### Password-based
822+
###### Password-based
821823

822824

823825
| Type | Description |
@@ -876,7 +878,7 @@ explicitly as follows:
876878
In the case that the homeserver does not know about the supplied 3PID,
877879
the homeserver must respond with 403 Forbidden.
878880

879-
##### Google ReCaptcha
881+
###### Google ReCaptcha
880882

881883
| Type | Description |
882884
|---------------------|------------------------------------------------------|
@@ -893,7 +895,7 @@ follows:
893895
}
894896
```
895897

896-
##### Single Sign-On
898+
###### Single Sign-On
897899

898900
| Type | Description |
899901
|---------------|--------------------------------------------------------------------------------------|
@@ -903,7 +905,7 @@ A client wanting to complete authentication using SSO should use the
903905
[Fallback](#fallback) mechanism. See [SSO during User-Interactive
904906
Authentication](#sso-during-user-interactive-authentication) for more information.
905907

906-
##### Email-based (identity / homeserver)
908+
###### Email-based (identity / homeserver)
907909

908910
| Type | Description |
909911
|--------------------------|------------------------------------------------------------------------------------------------------------------|
@@ -932,7 +934,7 @@ follows:
932934
Note that `id_server` (and therefore `id_access_token`) is optional if
933935
the [`/requestToken`](#post_matrixclientv3registeremailrequesttoken) request did not include them.
934936

935-
##### Phone number/MSISDN-based (identity / homeserver)
937+
###### Phone number/MSISDN-based (identity / homeserver)
936938

937939
| Type | Description |
938940
|------------------|----------------------------------------------------------------------------------------------------------------|
@@ -961,7 +963,7 @@ follows:
961963
Note that `id_server` (and therefore `id_access_token`) is optional if
962964
the [`/requestToken`](#post_matrixclientv3registermsisdnrequesttoken) request did not include them.
963965

964-
##### Dummy Auth
966+
###### Dummy Auth
965967

966968
| Type | Description |
967969
|------------------|------------------------------------------------------------------------|
@@ -987,7 +989,7 @@ just the type and session, if provided:
987989
}
988990
```
989991

990-
##### Token-authenticated registration
992+
###### Token-authenticated registration
991993

992994
{{% added-in v="1.2" %}}
993995

@@ -1031,7 +1033,7 @@ in the registration process that their token has expired.
10311033

10321034
{{% http-api spec="client-server" api="registration_tokens" %}}
10331035

1034-
##### Terms of service at registration
1036+
###### Terms of service at registration
10351037

10361038
{{% added-in v="1.11" %}}
10371039

@@ -1154,7 +1156,7 @@ user during registration, if applicable.
11541156

11551157
{{% definition path="api/client-server/definitions/m.login.terms_params" %}}
11561158

1157-
#### Fallback
1159+
##### Fallback
11581160

11591161
Clients cannot be expected to be able to know how to process every
11601162
single login type. If a client does not know how to handle a given login
@@ -1195,7 +1197,7 @@ with just the session ID:
11951197
}
11961198
```
11971199

1198-
##### Example
1200+
**Example**
11991201

12001202
A client webapp might use the following JavaScript to open a popup
12011203
window which will handle unknown login types:
@@ -1251,7 +1253,7 @@ function unknownLoginType(homeserverUrl, apiEndpoint, loginType, sessionID, onCo
12511253
}
12521254
```
12531255

1254-
#### Identifier types
1256+
##### Identifier types
12551257

12561258
Some authentication mechanisms use a user identifier object to identify
12571259
a user. The user identifier object has a `type` field to indicate the
@@ -1264,7 +1266,7 @@ This specification defines the following identifier types:
12641266
- `m.id.thirdparty`
12651267
- `m.id.phone`
12661268

1267-
##### Matrix User ID
1269+
###### Matrix User ID
12681270

12691271
| Type | Description |
12701272
|-------------|--------------------------------------------|
@@ -1281,7 +1283,7 @@ ID.
12811283
}
12821284
```
12831285

1284-
##### Third-party ID
1286+
###### Third-party ID
12851287

12861288
| Type | Description |
12871289
|-------------------|---------------------------------------------------------------------------|
@@ -1301,7 +1303,7 @@ ID media.
13011303
}
13021304
```
13031305

1304-
##### Phone number
1306+
###### Phone number
13051307

13061308
| Type | Description |
13071309
|--------------|-------------------------------------------|
@@ -1327,7 +1329,7 @@ The `country` is the two-letter uppercase ISO-3166-1 alpha-2 country
13271329
code that the number in `phone` should be parsed as if it were dialled
13281330
from.
13291331

1330-
### Login
1332+
#### Login
13311333

13321334
A client can obtain access tokens using the [`/login`](#post_matrixclientv3login) API.
13331335

@@ -1399,7 +1401,7 @@ a token for their user ID if supported by the homeserver using
13991401

14001402
{{% http-api spec="client-server" api="logout" %}}
14011403

1402-
#### Appservice Login
1404+
##### Appservice Login
14031405

14041406
{{% added-in v="1.2" %}}
14051407

@@ -1436,7 +1438,7 @@ If the access token does correspond to an appservice, but the user id does
14361438
not lie within its namespace then the homeserver will respond with an
14371439
errcode of `M_EXCLUSIVE`.
14381440

1439-
#### Login Fallback
1441+
##### Login Fallback
14401442

14411443
If a client does not recognize any or all login flows it can use the
14421444
fallback login API:
@@ -1456,11 +1458,13 @@ forwarded to the login endpoint during the login process. For example:
14561458

14571459
GET /_matrix/static/client/login/?device_id=GHTYAJCE
14581460

1459-
### Account registration and management
1461+
#### Account registration
14601462

14611463
{{% http-api spec="client-server" api="registration" %}}
14621464

1463-
#### Notes on password management
1465+
#### Account management
1466+
1467+
##### Password management
14641468

14651469
{{% boxes/warning %}}
14661470
Clients SHOULD enforce that the password provided is suitably complex.
@@ -1469,6 +1473,16 @@ number and a symbol and be at a minimum 8 characters in length. Servers
14691473
MAY reject weak passwords with an error code `M_WEAK_PASSWORD`.
14701474
{{% /boxes/warning %}}
14711475

1476+
{{% http-api spec="client-server" api="password_management" %}}
1477+
1478+
##### Account deactivation
1479+
1480+
{{% http-api spec="client-server" api="account_deactivation" %}}
1481+
1482+
### OAuth 2.0 API
1483+
1484+
### Account moderation
1485+
14721486
#### Account locking
14731487

14741488
{{% added-in v="1.12" %}}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Copyright 2016 OpenMarket Ltd
2+
# Copyright 2022 The Matrix.org Foundation C.I.C.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
openapi: 3.1.0
16+
info:
17+
title: Matrix Client-Server Account Deactivation API
18+
version: 1.0.0
19+
paths:
20+
/account/deactivate:
21+
post:
22+
summary: Deactivate a user's account.
23+
description: |-
24+
Deactivate the user's account, removing all ability for the user to
25+
login again.
26+
27+
This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api).
28+
29+
An access token should be submitted to this endpoint if the client has
30+
an active session.
31+
32+
The homeserver may change the flows available depending on whether a
33+
valid access token is provided.
34+
35+
Unlike other endpoints, this endpoint does not take an `id_access_token`
36+
parameter because the homeserver is expected to sign the request to the
37+
identity server instead.
38+
security:
39+
- {}
40+
- accessTokenQuery: []
41+
- accessTokenBearer: []
42+
operationId: deactivateAccount
43+
requestBody:
44+
content:
45+
application/json:
46+
schema:
47+
type: object
48+
properties:
49+
auth:
50+
description: Additional authentication information for the user-interactive
51+
authentication API.
52+
allOf:
53+
- $ref: definitions/auth_data.yaml
54+
id_server:
55+
type: string
56+
description: |-
57+
The identity server to unbind all of the user's 3PIDs from.
58+
If not provided, the homeserver MUST use the `id_server`
59+
that was originally use to bind each identifier. If the
60+
homeserver does not know which `id_server` that was,
61+
it must return an `id_server_unbind_result` of
62+
`no-support`.
63+
example: example.org
64+
erase:
65+
x-addedInMatrixVersion: "1.10"
66+
type: boolean
67+
description: |-
68+
Whether the user would like their content to be erased as
69+
much as possible from the server.
70+
71+
Erasure means that any users (or servers) which join the
72+
room after the erasure request are served redacted copies of
73+
the events sent by this account. Users which had visibility
74+
on those events prior to the erasure are still able to see
75+
unredacted copies. No redactions are sent and the erasure
76+
request is not shared over federation, so other servers
77+
might still serve unredacted copies.
78+
79+
The server should additionally erase any non-event data
80+
associated with the user, such as [account data](/client-server-api/#client-config)
81+
and [contact 3PIDs](/client-server-api/#adding-account-administrative-contact-information).
82+
83+
Defaults to `false` if not present.
84+
required: true
85+
responses:
86+
"200":
87+
description: The account has been deactivated.
88+
content:
89+
application/json:
90+
schema:
91+
type: object
92+
properties:
93+
id_server_unbind_result:
94+
type: string
95+
enum:
96+
- success
97+
- no-support
98+
description: |-
99+
An indicator as to whether or not the homeserver was able to unbind
100+
the user's 3PIDs from the identity server(s). `success` indicates
101+
that all identifiers have been unbound from the identity server while
102+
`no-support` indicates that one or more identifiers failed to unbind
103+
due to the identity server refusing the request or the homeserver
104+
being unable to determine an identity server to unbind from. This
105+
must be `success` if the homeserver has no identifiers to unbind
106+
for the user.
107+
example: success
108+
required:
109+
- id_server_unbind_result
110+
"401":
111+
description: The homeserver requires additional authentication information.
112+
content:
113+
application/json:
114+
schema:
115+
$ref: definitions/auth_response.yaml
116+
"429":
117+
description: This request was rate-limited.
118+
content:
119+
application/json:
120+
schema:
121+
$ref: definitions/errors/rate_limited.yaml
122+
tags:
123+
- Account management
124+
servers:
125+
- url: "{protocol}://{hostname}{basePath}"
126+
variables:
127+
protocol:
128+
enum:
129+
- http
130+
- https
131+
default: https
132+
hostname:
133+
default: localhost:8008
134+
basePath:
135+
default: /_matrix/client/v3
136+
components:
137+
securitySchemes:
138+
accessTokenQuery:
139+
$ref: definitions/security.yaml#/accessTokenQuery
140+
accessTokenBearer:
141+
$ref: definitions/security.yaml#/accessTokenBearer

0 commit comments

Comments
 (0)