Skip to content

Commit

Permalink
Add spec for Matrix auth endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Feb 4, 2019
1 parent 8b5c637 commit 360743f
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 1 deletion.
4 changes: 3 additions & 1 deletion maubot/management/api/client_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import Dict, Tuple, NamedTuple, Optional
from json import JSONDecodeError
from http import HTTPStatus
import hmac
import hashlib

Expand Down Expand Up @@ -95,7 +96,8 @@ async def register(request: web.Request) -> web.Response:
return web.json_response({
"errcode": e.errcode,
"error": e.message,
}, status=e.http_status)
"http_status": e.http_status,
}, status=HTTPStatus.INTERNAL_SERVER_ERROR)


@routes.post("/client/auth/{server}/login")
Expand Down
129 changes: 129 additions & 0 deletions maubot/management/api/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,107 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
/client/auth/servers:
get:
operationId: get_client_auth_servers
summary: Get the list of servers you can register or log in on via the maubot server
tags: [Clients]
responses:
200:
description: OK
content:
application/json:
schema:
type: array
items:
type: string
example:
- maunium.net
- example.com
- matrix.org
401:
$ref: '#/components/responses/Unauthorized'
'/client/auth/{server}/register':
parameters:
- name: server
in: path
description: The server name to register the account on.
required: true
schema:
type: string
post:
operationId: client_auth_register
summary: |
Register a new account on the given Matrix server using the shared registration
secret configured into the maubot server.
tags: [Clients]
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/MatrixAuthentication'
responses:
200:
description: Registration successful
content:
application/json:
schema:
type: object
properties:
access_token:
type: string
example: token_here
user_id:
type: string
example: '@putkiteippi:maunium.net'
home_server:
type: string
example: maunium.net
device_id:
type: string
example: device_id_here
401:
$ref: '#/components/responses/Unauthorized'
500:
$ref: '#/components/responses/MatrixServerError'
'/client/auth/{server}/login':
parameters:
- name: server
in: path
description: The server name to log in to.
required: true
schema:
type: string
post:
operationId: client_auth_login
summary: Log in to the given Matrix server via the maubot server
tags: [Clients]
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/MatrixAuthentication'
responses:
200:
description: Login successful
content:
application/json:
schema:
type: object
properties:
user_id:
type: string
example: '@putkiteippi:maunium.net'
access_token:
type: string
example: token_here
device_id:
type: string
example: device_id_here
401:
$ref: '#/components/responses/Unauthorized'
500:
$ref: '#/components/responses/MatrixServerError'

components:
responses:
Expand Down Expand Up @@ -432,6 +533,23 @@ components:
application/json:
schema:
$ref: '#/components/schemas/Error'
MatrixServerError:
description: The Matrix server returned an error
content:
application/json:
schema:
type: object
properties:
errcode:
type: string
description: The `errcode` returned by the server.
error:
type: string
description: The human-readable error returned by the server.
http_status:
type: integer
description: The HTTP status returned by the server.

securitySchemes:
bearer:
type: http
Expand Down Expand Up @@ -516,3 +634,14 @@ components:
readOnly: true
items:
$ref: '#/components/schemas/PluginInstance'
MatrixAuthentication:
type: object
properties:
username:
type: string
example: putkiteippi
description: The user ID localpart to register/log in as.
password:
type: string
example: p455w0rd
description: The password for/of the user.

0 comments on commit 360743f

Please sign in to comment.