From 13b4598c83e7cbb65480dbe74f431c207407ebe3 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 16 May 2022 08:14:48 +0200 Subject: [PATCH] feat: Authenticate media downloads This is not strictly required by the spec, but it improves security to require auth for media downloads on your homeserver. I enabled that on my servers now and plan to MSC that soon. This is required for people on my servers to see images and other content now. --- lib/src/generated/api.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/generated/api.dart b/lib/src/generated/api.dart index 66df959e..72d386f9 100644 --- a/lib/src/generated/api.dart +++ b/lib/src/generated/api.dart @@ -4256,6 +4256,7 @@ class Api { if (allowRemote != null) 'allow_remote': allowRemote.toString(), }); final request = Request('GET', baseUri!.resolveUri(requestUri)); + request.headers['authorization'] = 'Bearer ${bearerToken!}'; final response = await httpClient.send(request); final responseBody = await response.stream.toBytes(); if (response.statusCode != 200) unexpectedResponse(response, responseBody); @@ -4289,6 +4290,7 @@ class Api { if (allowRemote != null) 'allow_remote': allowRemote.toString(), }); final request = Request('GET', baseUri!.resolveUri(requestUri)); + request.headers['authorization'] = 'Bearer ${bearerToken!}'; final response = await httpClient.send(request); final responseBody = await response.stream.toBytes(); if (response.statusCode != 200) unexpectedResponse(response, responseBody); @@ -4360,6 +4362,7 @@ class Api { if (allowRemote != null) 'allow_remote': allowRemote.toString(), }); final request = Request('GET', baseUri!.resolveUri(requestUri)); + request.headers['authorization'] = 'Bearer ${bearerToken!}'; final response = await httpClient.send(request); final responseBody = await response.stream.toBytes(); if (response.statusCode != 200) unexpectedResponse(response, responseBody);