Skip to content

Commit 97b5702

Browse files
committed
Use auth header instead of query param for hs->as comms
MSC: matrix-org/matrix-spec-proposals#2832
1 parent b36d4ef commit 97b5702

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed
Lines changed: 1 addition & 0 deletions
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

Lines changed: 21 additions & 5 deletions
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

Lines changed: 5 additions & 4 deletions
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.
@@ -12,7 +13,7 @@
1213
# See the License for the specific language governing permissions and
1314
# limitations under the License.
1415
homeserverAccessToken:
15-
type: apiKey
16-
description: The `hs_token` provided by the application service's registration.
17-
name: access_token
18-
in: query
16+
type: http
17+
scheme: Bearer
18+
# Per docs, this is basically a description. https://swagger.io/docs/specification/authentication/bearer-authentication/
19+
bearerFormat: The `hs_token` provided by the application service's registration.

0 commit comments

Comments
 (0)