Skip to content

Authentication fails when using DIGEST_AUTH from iOS devices #3642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Hieromon opened this issue Jan 17, 2020 · 1 comment
Closed

Authentication fails when using DIGEST_AUTH from iOS devices #3642

Hieromon opened this issue Jan 17, 2020 · 1 comment

Comments

@Hieromon
Copy link

Hardware:

Board: Heltec WiFi Kit 32
Core Installation version: 1.0.4
IDE name: Arduino IDE 1.8.10
Flash Frequency: 80MHz
PSRAM enabled: No
Upload Speed: 115200
Computer OS: iOS 13 on iPhone

Description:

HTTP authentication fails when using DIGEST_AUTH with WebServer::authenticate from iOS devices. It occurs in any of Safari, Firefox, and Chrome.
This could be an iOS13 issue, but the ESP8266 arduino core has dealt with a similar issue.
esp8266/Arduino#4717

How does the esp32 arduino-core will deal with this problem?

Sketch:

The below sketch as a quote from the HttpAdvancedAuth.ino.

#include <WiFi.h>
#include <ESPmDNS.h>
#include <ArduinoOTA.h>
#include <WebServer.h>

const char* ssid = "........";
const char* password = "........";

WebServer server(80);

const char* www_username = "admin";
const char* www_password = "esp32";
const char* www_realm = "Custom Auth Realm";
String authFailResponse = "Authentication Failed";

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  if (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("WiFi Connect Failed! Rebooting...");
    delay(1000);
    ESP.restart();
  }
  ArduinoOTA.begin();

  server.on("/", []() {
    if (!server.authenticate(www_username, www_password))
    {
      return server.requestAuthentication(DIGEST_AUTH, www_realm, authFailResponse);
    }
    server.send(200, "text/plain", "Login OK");
  });
  server.begin();

  Serial.print("Open http://");
  Serial.print(WiFi.localIP());
  Serial.println("/ in your browser to see it working");
}

void loop() {
  ArduinoOTA.handle();
  server.handleClient();
}
@Hieromon
Copy link
Author

Sorry, The issue has fixed. #3329
Closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant