mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
Renamed one new basic auth function, improved doxy
This commit is contained in:
@@ -45,10 +45,10 @@ answer_to_connection (void *cls, struct MHD_Connection *connection,
|
|||||||
static const char *page =
|
static const char *page =
|
||||||
"<html><body>Authorization required</body></html>";
|
"<html><body>Authorization required</body></html>";
|
||||||
response = MHD_create_response_from_buffer_static (strlen (page), page);
|
response = MHD_create_response_from_buffer_static (strlen (page), page);
|
||||||
ret = MHD_queue_basic_auth_fail_response3 (connection,
|
ret = MHD_queue_basic_auth_required_response3 (connection,
|
||||||
"admins",
|
"admins",
|
||||||
MHD_YES,
|
MHD_YES,
|
||||||
response);
|
response);
|
||||||
}
|
}
|
||||||
else if ((strlen ("root") != auth_info->username_len) ||
|
else if ((strlen ("root") != auth_info->username_len) ||
|
||||||
(0 != memcmp (auth_info->username, "root",
|
(0 != memcmp (auth_info->username, "root",
|
||||||
@@ -63,10 +63,10 @@ answer_to_connection (void *cls, struct MHD_Connection *connection,
|
|||||||
static const char *page =
|
static const char *page =
|
||||||
"<html><body>Wrong username or password</body></html>";
|
"<html><body>Wrong username or password</body></html>";
|
||||||
response = MHD_create_response_from_buffer_static (strlen (page), page);
|
response = MHD_create_response_from_buffer_static (strlen (page), page);
|
||||||
ret = MHD_queue_basic_auth_fail_response3 (connection,
|
ret = MHD_queue_basic_auth_required_response3 (connection,
|
||||||
"admins",
|
"admins",
|
||||||
MHD_YES,
|
MHD_YES,
|
||||||
response);
|
response);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -89,10 +89,10 @@ ask_for_authentication (struct MHD_Connection *connection, const char *realm)
|
|||||||
if (! response)
|
if (! response)
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
|
|
||||||
ret = MHD_queue_basic_auth_fail_response3 (connection,
|
ret = MHD_queue_basic_auth_required_response3 (connection,
|
||||||
realm,
|
realm,
|
||||||
MHD_YES,
|
MHD_YES,
|
||||||
response);
|
response);
|
||||||
MHD_destroy_response (response);
|
MHD_destroy_response (response);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,10 +87,10 @@ ahc_echo (void *cls,
|
|||||||
response =
|
response =
|
||||||
MHD_create_response_from_buffer_static (strlen (DENIED),
|
MHD_create_response_from_buffer_static (strlen (DENIED),
|
||||||
(const void *) DENIED);
|
(const void *) DENIED);
|
||||||
ret = MHD_queue_basic_auth_fail_response3 (connection,
|
ret = MHD_queue_basic_auth_required_response3 (connection,
|
||||||
"TestRealm",
|
"TestRealm",
|
||||||
MHD_NO,
|
MHD_NO,
|
||||||
response);
|
response);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+40
-37
@@ -96,7 +96,7 @@ extern "C"
|
|||||||
* they are parsed as decimal numbers.
|
* they are parsed as decimal numbers.
|
||||||
* Example: 0x01093001 = 1.9.30-1.
|
* Example: 0x01093001 = 1.9.30-1.
|
||||||
*/
|
*/
|
||||||
#define MHD_VERSION 0x00097703
|
#define MHD_VERSION 0x00097704
|
||||||
|
|
||||||
/* If generic headers don't work on your platform, include headers
|
/* If generic headers don't work on your platform, include headers
|
||||||
which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t',
|
which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t',
|
||||||
@@ -5794,7 +5794,9 @@ MHD_queue_auth_fail_response (struct MHD_Connection *connection,
|
|||||||
struct MHD_BasicAuthInfo
|
struct MHD_BasicAuthInfo
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The username, cannot be NULL
|
* The username, cannot be NULL.
|
||||||
|
* The buffer pointed by the @a username becomes invalid when the pointer
|
||||||
|
* to the structure is freed by #MHD_free().
|
||||||
*/
|
*/
|
||||||
char *username;
|
char *username;
|
||||||
|
|
||||||
@@ -5804,7 +5806,9 @@ struct MHD_BasicAuthInfo
|
|||||||
size_t username_len;
|
size_t username_len;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The password, may be NULL if password is not encoded by the client
|
* The password, may be NULL if password is not encoded by the client.
|
||||||
|
* The buffer pointed by the @a password becomes invalid when the pointer
|
||||||
|
* to the structure is freed by #MHD_free().
|
||||||
*/
|
*/
|
||||||
char *password;
|
char *password;
|
||||||
|
|
||||||
@@ -5830,6 +5834,38 @@ struct MHD_BasicAuthInfo
|
|||||||
_MHD_EXTERN struct MHD_BasicAuthInfo *
|
_MHD_EXTERN struct MHD_BasicAuthInfo *
|
||||||
MHD_basic_auth_get_username_password3 (struct MHD_Connection *connection);
|
MHD_basic_auth_get_username_password3 (struct MHD_Connection *connection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queues a response to request basic authentication from the client.
|
||||||
|
*
|
||||||
|
* The given response object is expected to include the payload for
|
||||||
|
* the response; the "WWW-Authenticate" header will be added and the
|
||||||
|
* response queued with the 'UNAUTHORIZED' status code.
|
||||||
|
*
|
||||||
|
* See RFC 7617#section-2 for details.
|
||||||
|
*
|
||||||
|
* The @a response is modified by this function. The modified response object
|
||||||
|
* can be used to respond subsequent requests by #MHD_queue_response()
|
||||||
|
* function with status code #MHD_HTTP_UNAUTHORIZED and must not be used again
|
||||||
|
* with MHD_queue_basic_auth_required_response3() function. The response could
|
||||||
|
* be destroyed right after call of this function.
|
||||||
|
*
|
||||||
|
* @param connection the MHD connection structure
|
||||||
|
* @param realm the realm presented to the client
|
||||||
|
* @param prefer_utf8 if not set to #MHD_NO, parameter'charset="UTF-8"' will
|
||||||
|
* be added, indicating for client that UTF-8 encoding
|
||||||
|
* is preferred
|
||||||
|
* @param response the response object to modify and queue; the NULL
|
||||||
|
* is tolerated
|
||||||
|
* @return #MHD_YES on success, #MHD_NO otherwise
|
||||||
|
* @note Available since #MHD_VERSION 0x00097704
|
||||||
|
* @ingroup authentication
|
||||||
|
*/
|
||||||
|
_MHD_EXTERN enum MHD_Result
|
||||||
|
MHD_queue_basic_auth_required_response3 (struct MHD_Connection *connection,
|
||||||
|
const char *realm,
|
||||||
|
int prefer_utf8,
|
||||||
|
struct MHD_Response *response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the username and password from the basic authorization header sent by the client
|
* Get the username and password from the basic authorization header sent by the client
|
||||||
*
|
*
|
||||||
@@ -5845,39 +5881,6 @@ MHD_basic_auth_get_username_password (struct MHD_Connection *connection,
|
|||||||
char **password);
|
char **password);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Queues a response to request basic authentication from the client.
|
|
||||||
*
|
|
||||||
* The given response object is expected to include the payload for
|
|
||||||
* the response; the "WWW-Authenticate" header will be added and the
|
|
||||||
* response queued with the 'UNAUTHORIZED' status code.
|
|
||||||
*
|
|
||||||
* See RFC 7617#section-2 for details.
|
|
||||||
*
|
|
||||||
* The @a response is modified by this function. The modified response object
|
|
||||||
* can be used to respond subsequent requests by #MHD_queue_response()
|
|
||||||
* function with status code #MHD_HTTP_UNAUTHORIZED and must not be used again
|
|
||||||
* with MHD_queue_basic_auth_fail_response3() function. The response could
|
|
||||||
* be destroyed right after call of this function.
|
|
||||||
*
|
|
||||||
* @param connection the MHD connection structure
|
|
||||||
* @param realm the realm presented to the client
|
|
||||||
* @param prefer_utf8 if not set to #MHD_NO, parameter'charset="UTF-8"' will
|
|
||||||
* be added, indicating for client that UTF-8 encoding
|
|
||||||
* is preferred
|
|
||||||
* @param response the response object to modify and queue; the NULL
|
|
||||||
* is tolerated
|
|
||||||
* @return #MHD_YES on success, #MHD_NO otherwise
|
|
||||||
* @note Available since #MHD_VERSION 0x00097701
|
|
||||||
* @ingroup authentication
|
|
||||||
*/
|
|
||||||
_MHD_EXTERN enum MHD_Result
|
|
||||||
MHD_queue_basic_auth_fail_response3 (struct MHD_Connection *connection,
|
|
||||||
const char *realm,
|
|
||||||
int prefer_utf8,
|
|
||||||
struct MHD_Response *response);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queues a response to request basic authentication from the client
|
* Queues a response to request basic authentication from the client
|
||||||
* The given response object is expected to include the payload for
|
* The given response object is expected to include the payload for
|
||||||
@@ -5888,7 +5891,7 @@ MHD_queue_basic_auth_fail_response3 (struct MHD_Connection *connection,
|
|||||||
* @param realm the realm presented to the client
|
* @param realm the realm presented to the client
|
||||||
* @param response response object to modify and queue; the NULL is tolerated
|
* @param response response object to modify and queue; the NULL is tolerated
|
||||||
* @return #MHD_YES on success, #MHD_NO otherwise
|
* @return #MHD_YES on success, #MHD_NO otherwise
|
||||||
* @deprecated use MHD_queue_basic_auth_fail_response3()
|
* @deprecated use MHD_queue_basic_auth_required_response3()
|
||||||
* @ingroup authentication
|
* @ingroup authentication
|
||||||
*/
|
*/
|
||||||
_MHD_EXTERN enum MHD_Result
|
_MHD_EXTERN enum MHD_Result
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ MHD_basic_auth_get_username_password (struct MHD_Connection *connection,
|
|||||||
* The @a response is modified by this function. The modified response object
|
* The @a response is modified by this function. The modified response object
|
||||||
* can be used to respond subsequent requests by #MHD_queue_response()
|
* can be used to respond subsequent requests by #MHD_queue_response()
|
||||||
* function with status code #MHD_HTTP_UNAUTHORIZED and must not be used again
|
* function with status code #MHD_HTTP_UNAUTHORIZED and must not be used again
|
||||||
* with MHD_queue_basic_auth_fail_response3() function. The response could
|
* with MHD_queue_basic_auth_required_response3() function. The response could
|
||||||
* be destroyed right after call of this function.
|
* be destroyed right after call of this function.
|
||||||
*
|
*
|
||||||
* @param connection the MHD connection structure
|
* @param connection the MHD connection structure
|
||||||
@@ -216,14 +216,14 @@ MHD_basic_auth_get_username_password (struct MHD_Connection *connection,
|
|||||||
* @param response the response object to modify and queue; the NULL
|
* @param response the response object to modify and queue; the NULL
|
||||||
* is tolerated
|
* is tolerated
|
||||||
* @return #MHD_YES on success, #MHD_NO otherwise
|
* @return #MHD_YES on success, #MHD_NO otherwise
|
||||||
* @note Available since #MHD_VERSION 0x00097701
|
* @note Available since #MHD_VERSION 0x00097704
|
||||||
* @ingroup authentication
|
* @ingroup authentication
|
||||||
*/
|
*/
|
||||||
_MHD_EXTERN enum MHD_Result
|
_MHD_EXTERN enum MHD_Result
|
||||||
MHD_queue_basic_auth_fail_response3 (struct MHD_Connection *connection,
|
MHD_queue_basic_auth_required_response3 (struct MHD_Connection *connection,
|
||||||
const char *realm,
|
const char *realm,
|
||||||
int prefer_utf8,
|
int prefer_utf8,
|
||||||
struct MHD_Response *response)
|
struct MHD_Response *response)
|
||||||
{
|
{
|
||||||
static const char prefix[] = "Basic realm=\"";
|
static const char prefix[] = "Basic realm=\"";
|
||||||
static const char suff_charset[] = "\", charset=\"UTF-8\"";
|
static const char suff_charset[] = "\", charset=\"UTF-8\"";
|
||||||
@@ -306,7 +306,7 @@ MHD_queue_basic_auth_fail_response3 (struct MHD_Connection *connection,
|
|||||||
* @param realm the realm presented to the client
|
* @param realm the realm presented to the client
|
||||||
* @param response response object to modify and queue; the NULL is tolerated
|
* @param response response object to modify and queue; the NULL is tolerated
|
||||||
* @return #MHD_YES on success, #MHD_NO otherwise
|
* @return #MHD_YES on success, #MHD_NO otherwise
|
||||||
* @deprecated use MHD_queue_basic_auth_fail_response3()
|
* @deprecated use MHD_queue_basic_auth_required_response3()
|
||||||
* @ingroup authentication
|
* @ingroup authentication
|
||||||
*/
|
*/
|
||||||
_MHD_EXTERN enum MHD_Result
|
_MHD_EXTERN enum MHD_Result
|
||||||
@@ -314,8 +314,8 @@ MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection,
|
|||||||
const char *realm,
|
const char *realm,
|
||||||
struct MHD_Response *response)
|
struct MHD_Response *response)
|
||||||
{
|
{
|
||||||
return MHD_queue_basic_auth_fail_response3 (connection, realm, MHD_NO,
|
return MHD_queue_basic_auth_required_response3 (connection, realm, MHD_NO,
|
||||||
response);
|
response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -366,10 +366,10 @@ ahc_echo (void *cls,
|
|||||||
(const void *) DENIED);
|
(const void *) DENIED);
|
||||||
if (NULL == response)
|
if (NULL == response)
|
||||||
mhdErrorExitDesc ("Response creation failed");
|
mhdErrorExitDesc ("Response creation failed");
|
||||||
ret = MHD_queue_basic_auth_fail_response3 (connection, REALM, MHD_YES,
|
ret = MHD_queue_basic_auth_required_response3 (connection, REALM, MHD_YES,
|
||||||
response);
|
response);
|
||||||
if (MHD_YES != ret)
|
if (MHD_YES != ret)
|
||||||
mhdErrorExitDesc ("'MHD_queue_basic_auth_fail_response3()' failed");
|
mhdErrorExitDesc ("'MHD_queue_basic_auth_required_response3()' failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user