diff --git a/httpd/auth.c b/httpd/auth.c index df14175a..76fc8475 100644 --- a/httpd/auth.c +++ b/httpd/auth.c @@ -24,17 +24,20 @@ int ICACHE_FLASH_ATTR authBasic(HttpdConnData *connData) { char userpass[AUTH_MAX_USER_LEN+AUTH_MAX_PASS_LEN+2]; char user[AUTH_MAX_USER_LEN]; char pass[AUTH_MAX_PASS_LEN]; + +// os_printf("authBasic()\n"); if (connData->conn==NULL) { //Connection aborted. Clean up. return HTTPD_CGI_DONE; } r=httpdGetHeader(connData, "Authorization", hdr, sizeof(hdr)); +// os_printf("httpdGetHeader -> %d {%s}\n", r, hdr); if (r && strncmp(hdr, "Basic", 5)==0) { - r=base64_decode(strlen(hdr)-6, hdr+6, sizeof(userpass), (unsigned char *)userpass); + r=my_base64_decode(strlen(hdr)-6, hdr+6, sizeof(userpass), (unsigned char *)userpass); if (r<0) r=0; //just clean out string on decode error userpass[r]=0; //zero-terminate user:pass string -// os_printf("Auth: %s\n", userpass); +// os_printf("Auth: %s\n", userpass); while (((AuthGetUserPw)(connData->cgiArg))(connData, no, user, AUTH_MAX_USER_LEN, pass, AUTH_MAX_PASS_LEN)) { //Check user/pass against auth header @@ -43,6 +46,7 @@ int ICACHE_FLASH_ATTR authBasic(HttpdConnData *connData) { userpass[strlen(user)]==':' && os_strcmp(userpass+strlen(user)+1, pass)==0) { //Authenticated. Yay! +os_printf("Authenticated as '%s', Yay !\n", user); return HTTPD_CGI_AUTHENTICATED; } no++; //Not authenticated with this user/pass. Check next user/pass combo. @@ -56,6 +60,7 @@ int ICACHE_FLASH_ATTR authBasic(HttpdConnData *connData) { httpdEndHeaders(connData); httpdSend(connData, forbidden, -1); //Okay, all done. +os_printf("Not authenticated !\n"); return HTTPD_CGI_DONE; } diff --git a/httpd/base64.c b/httpd/base64.c index 9d97a269..e600d2ad 100644 --- a/httpd/base64.c +++ b/httpd/base64.c @@ -39,7 +39,7 @@ static int ICACHE_FLASH_ATTR base64decode(const char in[4], char out[3]) { #endif /* decode a base64 string in one shot */ -int ICACHE_FLASH_ATTR base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out) { +int ICACHE_FLASH_ATTR my_base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out) { unsigned int ii, io; uint32_t v; unsigned int rem; @@ -109,4 +109,4 @@ int base64_encode(size_t in_len, const unsigned char *in, size_t out_len, char * return io; } -#endif \ No newline at end of file +#endif diff --git a/httpd/base64.h b/httpd/base64.h index 4dc86213..25b270d6 100644 --- a/httpd/base64.h +++ b/httpd/base64.h @@ -1,6 +1,6 @@ #ifndef BASE64_H #define BASE64_H -int base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out); +int my_base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out); -#endif \ No newline at end of file +#endif