Basic Auth: send correct response codes and headers acc. to rfc7235
as reported by @natedogith1
This commit is contained in:
1 parent
8db511b9bf
commit
bd04ed00d8
2 files changed
+45
-26
No files matched your search
+31
-23
@@ -1563,29 +1563,37 @@ void handle_connection (int fd)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (config.basicauth_list != NULL) {
|
||||
ssize_t len;
|
||||
char *authstring;
|
||||
int failure = 1;
|
||||
len = hashmap_entry_by_key (hashofheaders, "proxy-authorization",
|
||||
(void **) &authstring);
|
||||
if (len > 0 &&
|
||||
/* currently only "basic" auth supported */
|
||||
(strncmp(authstring, "Basic ", 6) == 0 ||
|
||||
strncmp(authstring, "basic ", 6) == 0) &&
|
||||
basicauth_check (config.basicauth_list, authstring + 6) == 1)
|
||||
failure = 0;
|
||||
if(failure) {
|
||||
update_stats (STAT_DENIED);
|
||||
indicate_http_error (connptr, 403, "Access denied",
|
||||
"detail",
|
||||
"The administrator of this proxy has not configured "
|
||||
"it to service requests from you.",
|
||||
NULL);
|
||||
goto fail;
|
||||
}
|
||||
hashmap_remove (hashofheaders, "proxy-authorization");
|
||||
}
|
||||
if (config.basicauth_list != NULL) {
|
||||
ssize_t len;
|
||||
char *authstring;
|
||||
int failure = 1;
|
||||
len = hashmap_entry_by_key (hashofheaders, "proxy-authorization",
|
||||
(void **) &authstring);
|
||||
|
||||
if (len == 0) {
|
||||
update_stats (STAT_DENIED);
|
||||
indicate_http_error (connptr, 407, "Proxy Authentication Required",
|
||||
"detail",
|
||||
"This proxy requires authentication.",
|
||||
NULL);
|
||||
goto fail;
|
||||
}
|
||||
if ( /* currently only "basic" auth supported */
|
||||
(strncmp(authstring, "Basic ", 6) == 0 ||
|
||||
strncmp(authstring, "basic ", 6) == 0) &&
|
||||
basicauth_check (config.basicauth_list, authstring + 6) == 1)
|
||||
failure = 0;
|
||||
if(failure) {
|
||||
update_stats (STAT_DENIED);
|
||||
indicate_http_error (connptr, 401, "Unauthorized",
|
||||
"detail",
|
||||
"The administrator of this proxy has not configured "
|
||||
"it to service requests from you.",
|
||||
NULL);
|
||||
goto fail;
|
||||
}
|
||||
hashmap_remove (hashofheaders, "proxy-authorization");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add any user-specified headers (AddHeader directive) to the
|
||||
|
||||
Reference in new issue
Block a user