Comments on: ESP32/ESP8266 Web Server HTTP Authentication (Username and Password Protected) https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Sat, 12 Apr 2025 10:14:29 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Sara Santos https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1026118 Sat, 12 Apr 2025 10:14:29 +0000 https://randomnerdtutorials.com/?p=96364#comment-1026118 In reply to edwinov.

Hi.
No. Your comment was not deleted.
We don’t delete comments unless they are inappropriate.

It seems that issue is related to the way Firefox handles the logout. It caches the credentials. So, to logo out, what you’re doing is sending a wrong username and password, which works. I think this comment explains pretty well what is happening: https://github.com/arangodb/arangodb/issues/688#issuecomment-37061076

I tried two new different methods, include the one you’re suggesting. I couldn’t find a way to make it work on both chrome and Firefox.
In Firefox, if you logout and close the web browser window, when yo try to access again, it will ask for the credentials again.
So, I guess this is a limitation. Make sure to close the web browser window, after logging out.

Regards,
Sara

]]>
By: edwinov https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1026015 Sat, 12 Apr 2025 00:39:17 +0000 https://randomnerdtutorials.com/?p=96364#comment-1026015 Hi Sara,

Has my previous comment been deleted?

I posted that I am now using the exact versions you refer to:

v3.7.6. of ESP32Async/ESPAsyncWebServer
v3.3.8 of ESP32Async/AsyncTCP

And that I STILL have the same problem.

xhr.open(“GET”, “/logout”, true); -> works on Chrome, fails on Firefox
xhr.open(“GET”, “/logout”, true ,”foo”, “bar”); -> fails on Chrome, works on Firefox

Surely there has to be a way to make it work on both.

Kind regards,

edwinov

]]>
By: edwinov https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1025673 Thu, 10 Apr 2025 21:23:37 +0000 https://randomnerdtutorials.com/?p=96364#comment-1025673 Hi Sara,

Thanks for your reply.

I am now using the exact libraries you link to:

Version 3.7.2 of https://github.com/ESP32Async/ESPAsyncWebServer
Version 3.3.8 of https://github.com/ESP32Async/AsyncTCP

And STILL the same problem.

Chrome works fine. Firefox not. In Firefox even closing the tab does not make a difference, when visiting the page again I do not have to log in and can still access the slider.

Again, using

xhr.open(“GET”, “/logout”, true, “log”, “out”);

instead of

xhr.open(“GET”, “/logout”, true);

reverses everything: Chrome fails and Firefox works.

Please at least install Firefox and see for yourself.

There has to be some solution that works on all browsers.

Kind regards,

edwinov

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1025644 Thu, 10 Apr 2025 19:13:07 +0000 https://randomnerdtutorials.com/?p=96364#comment-1025644 In reply to edwinov.

Hi.
I don’t have Firefox web browser, but it is working fine on Chrome.
Are you using the libraries by ESP32Async?
Regards,
Sara

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1025643 Thu, 10 Apr 2025 19:11:41 +0000 https://randomnerdtutorials.com/?p=96364#comment-1025643 In reply to edwinov.

Hi.
You should use the ESPAsyncWebServer library by ESP32Async as mentioned in the tutorial.
Regards,
Sara

]]>
By: edwinov https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1025406 Thu, 10 Apr 2025 02:59:34 +0000 https://randomnerdtutorials.com/?p=96364#comment-1025406 My post above failed to correctly display some code but I added a SECOND button with onclick = “logoutButtonFF()”.

]]>
By: edwinov https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1025405 Thu, 10 Apr 2025 02:56:41 +0000 https://randomnerdtutorials.com/?p=96364#comment-1025405 Hi Sara,

I have done some testing using the very code of the project above and have reached the following conclusion, for you to verify:

In function logoutButton:

xhr.open(“GET”, “/logout”, true); -> code WORKS in Chromium based browsers, code FAILS in Firefox

if I change it (Dominik’s suggestion above) to:

xhr.open(“GET”, “/logout”, true, “log”, “out”); -> code FAILS in Chromium based browsers, code WORKS in Firefox

I don’t understand the mechanism behind this. The problem is that there seems to be NO way to get it to work in ALL browers (Chromium based AND Firefox).

The temporary solution I have is this change to your code:

Logout Chromium
Logout Firefox

function logoutButton() {
var xhr = new XMLHttpRequest();
xhr.open(“GET”, “/logout”, true);
xhr.send();
setTimeout(function(){ window.open(“/logged-out”,”_self”); }, 1000);
}
function logoutButtonFF() {
var xhr = new XMLHttpRequest();
xhr.open(“GET”, “/logout”, true, “log”, “out”);
xhr.send();
setTimeout(function(){ window.open(“/logged-out”,”_self”); }, 1000);
}

Can you please investigate and confirm this and if possible come up with a solution?

Kind regards,

edwinov

]]>
By: edwinov https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1025390 Thu, 10 Apr 2025 01:10:09 +0000 https://randomnerdtutorials.com/?p=96364#comment-1025390 Hi Sara,

I am using the following:

esp32 core 3.0.7
ESPAsyncWebSrv 1.2.9 by dvarrel

I just tested again and Firefox/LibreWolf works as expected. Chrome/Opera/Edge fail.

When I visit my page I am prompted for username/pwd, I supply these and I get to see the page. On this (configuration) page there are some buttons, clicking them will get my ESP to do something eg light an LED. So far so good.

When I logout of the page (I have a button for that) I get the “Logged out. Return to homepage. Note: close all web browser tabs to complete the logout process.” page. Now if I click the back arrow in my Chrome/Opera/Edge browser I get back to the configuration page and clicking one of the buttons STILL gets the ESP to perform the action!

When I do the same in FireFox/LibreWolf I also still get to see the configuration page but as soon as I click a button I am prompted for username/pwd again (as it should).

If after logging out I click ‘Return to homepage’ then in Chrome/Opera/Edge I immediately get to the page again (as if I never logged out), in Firefox/LibreWolf I need to enter username/pwd again.

I made sure there were no other tabs open. It looks liks every browser based on Chromium has some caching mechanism that does not respect the logout.

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1024359 Mon, 07 Apr 2025 09:28:53 +0000 https://randomnerdtutorials.com/?p=96364#comment-1024359 In reply to edwinov.

Hi.
I just tested the code. I’m using Google Chrome and it is working as expected.
Which web server libraries are you using and which version of the ESP32 core?

Regards,
Sara

]]>
By: edwinov https://randomnerdtutorials.com/esp32-esp8266-web-server-http-authentication/#comment-1024300 Mon, 07 Apr 2025 04:43:51 +0000 https://randomnerdtutorials.com/?p=96364#comment-1024300 In reply to Sara Santos.

Hi Sara, have you found time yet to look at the problem?
Regards,edwinov

]]>