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 7, 2023
1 parent a4c7bbe commit 173314d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 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
2 changes: 1 addition & 1 deletion components/esp-adf-libs
2 changes: 1 addition & 1 deletion components/esp-sr
Submodule esp-sr updated 191 files

0 comments on commit 173314d

Please sign in to comment.