Anniversary Sale · up to 80% off all librariesEnds Nov 9Shop now
SOFTTDocs

Authentication

Protect the NetWizard captive portal with HTTP basic authentication.

By default, anyone who joins the device's access point can open the captive portal. setAuthentication() protects the portal with HTTP basic authentication: the browser prompts for a user name and password before it shows the portal.

Method

setAuthentication()

void setAuthentication(const char* username, const char* password);
void setAuthentication(String& username, String& password);

Prop

Type

Authentication is enabled only when both username and password are non-empty; otherwise the call has no effect. Call it before autoConnect().

void setup() {
  // ...
  NW.setAuthentication("admin", "change-me");
  NW.autoConnect("NetWizard Demo", "setup-password");
  // ...
}

Authentication applies to the portal page and to every portal API route (/netwizard/*).

Notes

  • Authentication protects the portal page, not the access point. To restrict who can join the access point, pass a password as the second argument of autoConnect().
  • HTTP basic authentication sends credentials without encryption over the access point connection. Use it to prevent casual access, not as a substitute for a secured access point.

On this page