Skip to content

Commit

Permalink
http_stream: enable HTTP Basic Auth
Browse files Browse the repository at this point in the history
We've submitted a PR to Espressif to support enabling HTTP Basic Auth in
ESP-ADF's HTTP stream: espressif#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:[email protected]: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.
  • Loading branch information
stintel committed Nov 8, 2023
1 parent a4c7bbe commit ecf7a96
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions components/audio_stream/http_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ecf7a96

Please sign in to comment.