@@ -24,17 +24,20 @@ int ICACHE_FLASH_ATTR authBasic(HttpdConnData *connData) {
24
24
char userpass [AUTH_MAX_USER_LEN + AUTH_MAX_PASS_LEN + 2 ];
25
25
char user [AUTH_MAX_USER_LEN ];
26
26
char pass [AUTH_MAX_PASS_LEN ];
27
+
28
+ // os_printf("authBasic()\n");
27
29
if (connData -> conn == NULL ) {
28
30
//Connection aborted. Clean up.
29
31
return HTTPD_CGI_DONE ;
30
32
}
31
33
32
34
r = httpdGetHeader (connData , "Authorization" , hdr , sizeof (hdr ));
35
+ // os_printf("httpdGetHeader -> %d {%s}\n", r, hdr);
33
36
if (r && strncmp (hdr , "Basic" , 5 )== 0 ) {
34
- r = base64_decode (strlen (hdr )- 6 , hdr + 6 , sizeof (userpass ), (unsigned char * )userpass );
37
+ r = my_base64_decode (strlen (hdr )- 6 , hdr + 6 , sizeof (userpass ), (unsigned char * )userpass );
35
38
if (r < 0 ) r = 0 ; //just clean out string on decode error
36
39
userpass [r ]= 0 ; //zero-terminate user:pass string
37
- // os_printf("Auth: %s\n", userpass);
40
+ // os_printf("Auth: %s\n", userpass);
38
41
while (((AuthGetUserPw )(connData -> cgiArg ))(connData , no ,
39
42
user , AUTH_MAX_USER_LEN , pass , AUTH_MAX_PASS_LEN )) {
40
43
//Check user/pass against auth header
@@ -43,6 +46,7 @@ int ICACHE_FLASH_ATTR authBasic(HttpdConnData *connData) {
43
46
userpass [strlen (user )]== ':' &&
44
47
os_strcmp (userpass + strlen (user )+ 1 , pass )== 0 ) {
45
48
//Authenticated. Yay!
49
+ os_printf ("Authenticated as '%s', Yay !\n" , user );
46
50
return HTTPD_CGI_AUTHENTICATED ;
47
51
}
48
52
no ++ ; //Not authenticated with this user/pass. Check next user/pass combo.
@@ -56,6 +60,7 @@ int ICACHE_FLASH_ATTR authBasic(HttpdConnData *connData) {
56
60
httpdEndHeaders (connData );
57
61
httpdSend (connData , forbidden , -1 );
58
62
//Okay, all done.
63
+ os_printf ("Not authenticated !\n" );
59
64
return HTTPD_CGI_DONE ;
60
65
}
61
66
0 commit comments