Skip to content

Commit 6dc7b95

Browse files
authored
Use auth header instead of query param for hs->as comms (#1200)
* Use auth header instead of query param for hs->as comms MSC: matrix-org/matrix-spec-proposals#2832 * Fix for OpenAPI 2
1 parent ef384f1 commit 6dc7b95

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace homeserver authorization approach with an `Authorization` header instead of `access_token` when talking to the application service, as per [MSC2832](https://github.com/matrix-org/matrix-spec-proposals/pull/2832).

content/application-service-api.md

+21-5
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,27 @@ this.
127127

128128
#### Authorization
129129

130-
Homeservers MUST include a query parameter named `access_token`
131-
containing the `hs_token` from the application service's registration
132-
when making requests to the application service. Application services
133-
MUST verify the provided `access_token` matches their known `hs_token`,
134-
failing the request with an `M_FORBIDDEN` error if it does not match.
130+
{{% changed-in v="1.4" %}}
131+
132+
Homeservers MUST include an `Authorization` header, containing the `hs_token`
133+
from the application service's registration, when making requests to the
134+
application service. Application services MUST verify that the provided
135+
`Bearer` token matches their known `hs_token`, failing the request with
136+
an `M_FORBIDDEN` error if it does not match.
137+
138+
The format of the `Authorization` header is similar to the [Client-Server API](/client-server-api/#client-authentication):
139+
`Bearer TheHSTokenGoesHere`.
140+
141+
{{% boxes/note %}}
142+
In previous versions of this specification, an `access_token` query
143+
parameter was used instead. Servers should only send this query parameter
144+
if supporting legacy versions of the specification.
145+
146+
If sending the `query_string`, it is encouraged to send it alongside
147+
the `Authorization` header for maximum compatibility.
148+
149+
Application services should ensure both match if both are provided.
150+
{{% /boxes/note %}}
135151

136152
#### Legacy routes
137153

data/api/application-service/definitions/security.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2018 New Vector Ltd
2+
# Copyright 2022 The Matrix.org Foundation C.I.C.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
45
# you may not use this file except in compliance with the License.
@@ -13,6 +14,6 @@
1314
# limitations under the License.
1415
homeserverAccessToken:
1516
type: apiKey
16-
description: The `hs_token` provided by the application service's registration.
17-
name: access_token
18-
in: query
17+
name: Authorization
18+
in: header
19+
description: The `Bearer` `hs_token` provided by the application service's registration.

0 commit comments

Comments
 (0)