From 173314dfd131087e48f99baa4e69036b60f53431 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Tue, 7 Nov 2023 18:14:28 +0200 Subject: [PATCH] http_stream: enable HTTP Basic Auth We've submitted a PR to Espressif to support enabling HTTP Basic Auth in ESP-ADF's HTTP stream: espressif/esp-adf#1103. Unfortunately we'd also require a change to ESP Audio to support enabling HTTP Basic Auth. As we can't seem to find the ESP Audio source, we'll just enable it unconditionally in ESP-ADF's HTTP stream. ESP Audio uses ESP-ADF's HTTP Stream so this is enough to support HTTP Basic Auth to WIS by using a URL in the form of http://user:pass@wis.local:19001/. ESP-IDF's http_parser component will detect the username and password in the URL, and esp_http_client will set the Authorization header if the auth type is set to basic, and the parser found a username and password in the URL. If the parser didn't find a username and password, esp_http_client will just skip setting the header entirely, so having auth type hardcoded to basic is not a problem even if users configure a URL without username and password. --- components/audio_stream/http_stream.c | 1 + components/esp-adf-libs | 2 +- components/esp-sr | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/audio_stream/http_stream.c b/components/audio_stream/http_stream.c index d38805644..b636e8776 100644 --- a/components/audio_stream/http_stream.c +++ b/components/audio_stream/http_stream.c @@ -575,6 +575,7 @@ static esp_err_t _http_open(audio_element_handle_t self) // if not initialize http client, initial it if (http->client == NULL) { esp_http_client_config_t http_cfg = { + .auth_type = HTTP_AUTH_TYPE_BASIC, .url = uri, .event_handler = _http_event_handle, .user_data = self, diff --git a/components/esp-adf-libs b/components/esp-adf-libs index b4ab944fd..619b3bac9 160000 --- a/components/esp-adf-libs +++ b/components/esp-adf-libs @@ -1 +1 @@ -Subproject commit b4ab944fda9955f4b980c816573d95ac675bb43e +Subproject commit 619b3bac9a34617f288c6e68f3c587618b1c68bb diff --git a/components/esp-sr b/components/esp-sr index 0c1eecaac..a779e5403 160000 --- a/components/esp-sr +++ b/components/esp-sr @@ -1 +1 @@ -Subproject commit 0c1eecaac259af95f76723b61d4e16cef5904fc7 +Subproject commit a779e54037aa93cc74cd1dd27c0cb2f7a2bb10b9