|
|
@@ -736,41 +736,38 @@ MHDT_server_reply_check_basic_auth (
|
|
|
const char *cred = cls;
|
|
|
union MHD_RequestInfoDynamicData dd;
|
|
|
enum MHD_StatusCode sc;
|
|
|
- struct MHD_BasicAuthInfo *ba;
|
|
|
- struct MHD_Connection *connection; // FIXME - suboptimal API
|
|
|
- union MHD_RequestInfoFixedData rif;
|
|
|
-
|
|
|
-#define FIXME 1
|
|
|
-#if FIXME
|
|
|
- sc = MHD_request_get_info_fixed (request,
|
|
|
- MHD_REQUEST_INFO_FIXED_CONNECTION,
|
|
|
- &rif);
|
|
|
- if (MHD_SC_OK != sc)
|
|
|
- return NULL;
|
|
|
- connection = rif.v_connection;
|
|
|
-#endif
|
|
|
+ const struct MHD_BasicAuthInfo *ba;
|
|
|
+
|
|
|
/* should not be needed, except to make gcc happy */
|
|
|
memset (&dd,
|
|
|
0,
|
|
|
sizeof (dd));
|
|
|
sc = MHD_request_get_info_dynamic (request,
|
|
|
- MHD_REQUEST_INFO_DYNAMIC_BAUTH_REQ_INFO,
|
|
|
+ MHD_REQUEST_INFO_DYNAMIC_AUTH_BASIC_CREDS,
|
|
|
&dd);
|
|
|
if (MHD_SC_OK != sc)
|
|
|
- return MHD_action_basic_auth_required_response (
|
|
|
- connection, // FIXME: I'd like to see 'request' here.
|
|
|
+ {
|
|
|
+ fprintf (stderr,
|
|
|
+ "No credentials?\n");
|
|
|
+ return MHD_action_basic_auth_challenge_p (
|
|
|
+ request,
|
|
|
"test-realm",
|
|
|
MHD_YES,
|
|
|
MHD_response_from_empty (
|
|
|
- MHD_HTTP_STATUS_FORBIDDEN));
|
|
|
- ba = dd.v_bauth_info;
|
|
|
+ MHD_HTTP_STATUS_UNAUTHORIZED));
|
|
|
+ }
|
|
|
+ ba = dd.v_auth_basic_creds;
|
|
|
if (NULL == ba)
|
|
|
- return MHD_action_basic_auth_required_response (
|
|
|
- connection, // FIXME: I'd like to see 'request' here.
|
|
|
+ {
|
|
|
+ fprintf (stderr,
|
|
|
+ "No credentials??\n");
|
|
|
+ return MHD_action_basic_auth_challenge_p (
|
|
|
+ request,
|
|
|
"test-realm",
|
|
|
MHD_YES,
|
|
|
MHD_response_from_empty (
|
|
|
- MHD_HTTP_STATUS_FORBIDDEN));
|
|
|
+ MHD_HTTP_STATUS_UNAUTHORIZED));
|
|
|
+ }
|
|
|
if ( (0 != strncmp (ba->username.cstr,
|
|
|
cred,
|
|
|
ba->username.len)) ||
|
|
|
@@ -778,12 +775,19 @@ MHDT_server_reply_check_basic_auth (
|
|
|
(NULL == ba->password.cstr) ||
|
|
|
(0 != strcmp (ba->password.cstr,
|
|
|
&cred[ba->username.len + 1])) )
|
|
|
- return MHD_action_basic_auth_required_response (
|
|
|
- connection, // FIXME: I'd like to see 'request' here.
|
|
|
+ {
|
|
|
+ fprintf (stderr,
|
|
|
+ "Wrong credentials (Got: %s/%s Want: %s)!\n",
|
|
|
+ ba->username.cstr,
|
|
|
+ ba->password.cstr,
|
|
|
+ cred);
|
|
|
+ return MHD_action_basic_auth_challenge_p (
|
|
|
+ request,
|
|
|
"test-realm",
|
|
|
MHD_YES,
|
|
|
MHD_response_from_empty (
|
|
|
- MHD_HTTP_STATUS_FORBIDDEN));
|
|
|
+ MHD_HTTP_STATUS_UNAUTHORIZED));
|
|
|
+ }
|
|
|
return MHD_action_from_response (
|
|
|
request,
|
|
|
MHD_response_from_empty (
|