Skip to content

Commit e405707

Browse files
turt2liveuhoreg
andauthored
Add registration token UIA type (#3616)
* Add registration token UIA type MSC: #3231 **Note**: This introduces the endpoint as v1 rather than r0 given the global versioning changes landed between the acceptance of the MSC and now. * Fix swagger * Changelogs * Update data/api/client-server/registration_tokens.yaml Co-authored-by: Hubert Chathi <[email protected]> Co-authored-by: Hubert Chathi <[email protected]>
1 parent 20bd445 commit e405707

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add token-authenticated registration support as per [MSC3231](https://github.com/matrix-org/matrix-doc/pull/3231).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `/register/m.login.registration_token/validity` as per [MSC3231](https://github.com/matrix-org/matrix-doc/pull/3231).

content/client-server-api/_index.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ This specification defines the following auth types:
618618
- `m.login.email.identity`
619619
- `m.login.msisdn`
620620
- `m.login.dummy`
621+
- `m.login.registration_token`
621622

622623
##### Password-based
623624

@@ -789,6 +790,49 @@ just the type and session, if provided:
789790
}
790791
```
791792

793+
##### Token-authenticated registration
794+
795+
{{% added-in v="1.2" %}}
796+
797+
| Type | Description |
798+
|-------------------------------|-------------------------------------------------------------------|
799+
| `m.login.registration_token` | Registers an account with a pre-shared token for authentication |
800+
801+
{{% boxes/note %}}
802+
The `m.login.registration_token` authentication type is only valid on the
803+
[`/register`](#post_matrixclientv3register) endpoint.
804+
{{% /boxes/note %}}
805+
806+
This authentication type provides homeservers the ability to allow registrations
807+
to a limited set of people instead of either offering completely open registrations
808+
or completely closed registration (where the homeserver administrators create
809+
and distribute accounts).
810+
811+
The token required for this authentication type is shared out of band from
812+
Matrix and is an opaque string with maximum length of 64 characters in the
813+
range `[A-Za-z0-9._~-]`. The server can keep any number of tokens for any
814+
length of time/validity. Such cases might be a token limited to 100 uses or
815+
for the next 2 hours - after the tokens expire, they can no longer be used
816+
to create accounts.
817+
818+
To use this authentication type, clients should submit an auth dict with just
819+
the type, token, and session:
820+
821+
```json
822+
{
823+
"type": "m.login.registration_token",
824+
"token": "fBVFdqVE",
825+
"session": "<session ID>"
826+
}
827+
```
828+
829+
To determine if a token is valid before attempting to use it, the client can
830+
use the `/validity` API defined below. The API doesn't guarantee that a token
831+
will be valid when used, but does avoid cases where the user finds out late
832+
in the registration process that their token has expired.
833+
834+
{{% http-api spec="client-server" api="registration_tokens" %}}
835+
792836
#### Fallback
793837

794838
Clients cannot be expected to be able to know how to process every
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Copyright 2022 The Matrix.org Foundation C.I.C.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
swagger: '2.0'
15+
info:
16+
title: "Matrix Client-Server Registration Token API"
17+
version: "1.0.0"
18+
host: localhost:8008
19+
schemes:
20+
- https
21+
- http
22+
basePath: /_matrix/client/v1
23+
consumes:
24+
- application/json
25+
produces:
26+
- application/json
27+
paths:
28+
"/register/m.login.registration_token/validity":
29+
get:
30+
x-addedInMatrixVersion: "1.2"
31+
summary: Query if a given registration token is still valid.
32+
description: |-
33+
Queries the server to determine if a given registration token is still
34+
valid at the time of request. This is a point-in-time check where the
35+
token might still expire by the time it is used.
36+
37+
Servers should be sure to rate limit this endpoint to avoid brute force
38+
attacks.
39+
operationId: registrationTokenValidity
40+
parameters:
41+
- in: query
42+
name: token
43+
type: string
44+
x-example: "fBVFdqVE"
45+
required: true
46+
description: The token to check validity of.
47+
responses:
48+
200:
49+
description: The check has a result.
50+
examples:
51+
application/json: {
52+
"valid": true
53+
}
54+
schema:
55+
type: object
56+
properties:
57+
valid:
58+
type: boolean
59+
description: |-
60+
True if the token is still valid, false otherwise. This should
61+
additionally be false if the token is not a recognised token by
62+
the server.
63+
required: ['valid']
64+
403:
65+
description: |-
66+
The homeserver does not permit registration and thus all tokens are
67+
considered invalid.
68+
examples:
69+
application/json: {
70+
"errcode": "M_FORBIDDEN",
71+
"error": "Registration is not enabled on this homeserver."
72+
}
73+
schema:
74+
"$ref": "definitions/errors/error.yaml"
75+
429:
76+
description: This request was rate-limited.
77+
schema:
78+
"$ref": "definitions/errors/rate_limited.yaml"
79+
tags:
80+
- Account management

0 commit comments

Comments
 (0)