Skip to content

Commit 08b75f9

Browse files
authored
Test authBasic function
This should require you to enter a username & password to go into the WiFi pages on the esp. Use the following user & pass for testing admin s3cr3t
1 parent c59b276 commit 08b75f9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

esp-link/main.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ HttpdBuiltInUrl builtInUrls[] = {
8181
{ "/console/text", ajaxConsole, NULL },
8282
{ "/console/send", ajaxConsoleSend, NULL },
8383
//Enable the line below to protect the WiFi configuration with an username/password combo.
84-
// {"/wifi/*", authBasic, myPassFn},
84+
{"/wifi/*", authBasic, myPassFn},
8585
{ "/wifi", cgiRedirect, "/wifi/wifi.html" },
8686
{ "/wifi/", cgiRedirect, "/wifi/wifi.html" },
8787
{ "/wifi/info", cgiWifiInfo, NULL },
@@ -217,3 +217,21 @@ user_init(void) {
217217
system_show_malloc();
218218
#endif
219219
}
220+
221+
//Function that tells the authentication system what users/passwords live on the system.
222+
//This is disabled in the default build; if you want to try it, enable the authBasic line in
223+
//the builtInUrls below.
224+
int myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pass, int passLen) {
225+
if (no==0) {
226+
os_strcpy(user, "admin");
227+
os_strcpy(pass, "s3cr3t");
228+
return 1;
229+
//Add more users this way. Check against incrementing no for each user added.
230+
// } else if (no==1) {
231+
// os_strcpy(user, "user1");
232+
// os_strcpy(pass, "something");
233+
// return 1;
234+
}
235+
return 0;
236+
}
237+

0 commit comments

Comments
 (0)