Skip to content

Commit d7f58e2

Browse files
committed
Keep this function, as the one from the library appears to crash.
1 parent 848c973 commit d7f58e2

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

httpd/auth.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@ int ICACHE_FLASH_ATTR authBasic(HttpdConnData *connData) {
2424
char userpass[AUTH_MAX_USER_LEN+AUTH_MAX_PASS_LEN+2];
2525
char user[AUTH_MAX_USER_LEN];
2626
char pass[AUTH_MAX_PASS_LEN];
27+
28+
// os_printf("authBasic()\n");
2729
if (connData->conn==NULL) {
2830
//Connection aborted. Clean up.
2931
return HTTPD_CGI_DONE;
3032
}
3133

3234
r=httpdGetHeader(connData, "Authorization", hdr, sizeof(hdr));
35+
// os_printf("httpdGetHeader -> %d {%s}\n", r, hdr);
3336
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);
3538
if (r<0) r=0; //just clean out string on decode error
3639
userpass[r]=0; //zero-terminate user:pass string
37-
// os_printf("Auth: %s\n", userpass);
40+
// os_printf("Auth: %s\n", userpass);
3841
while (((AuthGetUserPw)(connData->cgiArg))(connData, no,
3942
user, AUTH_MAX_USER_LEN, pass, AUTH_MAX_PASS_LEN)) {
4043
//Check user/pass against auth header
@@ -43,6 +46,7 @@ int ICACHE_FLASH_ATTR authBasic(HttpdConnData *connData) {
4346
userpass[strlen(user)]==':' &&
4447
os_strcmp(userpass+strlen(user)+1, pass)==0) {
4548
//Authenticated. Yay!
49+
os_printf("Authenticated as '%s', Yay !\n", user);
4650
return HTTPD_CGI_AUTHENTICATED;
4751
}
4852
no++; //Not authenticated with this user/pass. Check next user/pass combo.
@@ -56,6 +60,7 @@ int ICACHE_FLASH_ATTR authBasic(HttpdConnData *connData) {
5660
httpdEndHeaders(connData);
5761
httpdSend(connData, forbidden, -1);
5862
//Okay, all done.
63+
os_printf("Not authenticated !\n");
5964
return HTTPD_CGI_DONE;
6065
}
6166

httpd/base64.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int ICACHE_FLASH_ATTR base64decode(const char in[4], char out[3]) {
3939
#endif
4040

4141
/* decode a base64 string in one shot */
42-
int ICACHE_FLASH_ATTR base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out) {
42+
int ICACHE_FLASH_ATTR my_base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out) {
4343
unsigned int ii, io;
4444
uint32_t v;
4545
unsigned int rem;
@@ -109,4 +109,4 @@ int base64_encode(size_t in_len, const unsigned char *in, size_t out_len, char *
109109
return io;
110110
}
111111

112-
#endif
112+
#endif

httpd/base64.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef BASE64_H
22
#define BASE64_H
33

4-
int base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out);
4+
int my_base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out);
55

6-
#endif
6+
#endif

0 commit comments

Comments
 (0)