52 size_t decoded_max_len;
55 params = MHD_get_rq_bauth_params_ (connection);
63 decoded_max_len = MHD_base64_max_dec_size_ (params->
token68.
len);
65 + decoded_max_len + 1);
71 decoded = (
char *) (ret + 1);
73 decoded, decoded_max_len);
80 colon = memchr (decoded,
':', decoded_len);
89 ret->
password = decoded + password_pos;
107 MHD_DLOG (connection->
daemon,
108 _ (
"Error decoding Basic Authorization authentication.\n"));
116 MHD_DLOG (connection->
daemon,
117 _ (
"Failed to allocate memory to process " \
118 "Basic Authorization authentication.\n"));
170 MHD_DLOG (connection->
daemon,
171 _ (
"Failed to allocate memory.\n"));
184 MHD_DLOG (connection->
daemon,
185 _ (
"Failed to allocate memory.\n"));
228 static const char prefix[] =
"Basic realm=\"";
229 static const char suff_charset[] =
"\", charset=\"UTF-8\"";
232 static const size_t suff_charset_len =
239 size_t realm_quoted_len;
242 if (
NULL == response)
245 suffix_len = (0 == prefer_utf8) ? suff_simple_len : suff_charset_len;
246 realm_len = strlen (realm);
247 h_maxlen = prefix_len + realm_len * 2 + suffix_len;
249 h_str = (
char *) malloc (h_maxlen + 1);
253 MHD_DLOG (connection->
daemon,
254 "Failed to allocate memory for Basic Authentication header.\n");
258 memcpy (h_str, prefix, prefix_len);
260 realm_quoted_len = MHD_str_quote (realm, realm_len, h_str + pos,
261 h_maxlen - prefix_len - suffix_len);
262 pos += realm_quoted_len;
264 if (0 == prefer_utf8)
273 mhd_assert (pos + suff_charset_len <= h_maxlen);
274 memcpy (h_str + pos, suff_charset, suff_charset_len + 1);
275 mhd_assert (0 == h_str[pos + suff_charset_len]);
291 MHD_DLOG (connection->
daemon,
292 _ (
"Failed to add Basic Authentication header.\n"));
Declarations for HTTP authorisation general functions.
_MHD_EXTERN enum MHD_Result MHD_queue_basic_auth_fail_response(struct MHD_Connection *connection, const char *realm, struct MHD_Response *response)
_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)
_MHD_EXTERN char * MHD_basic_auth_get_username_password(struct MHD_Connection *connection, char **password)
_MHD_EXTERN struct MHD_BasicAuthInfo * MHD_basic_auth_get_username_password3(struct MHD_Connection *connection)
#define MHD_HTTP_UNAUTHORIZED
_MHD_EXTERN enum MHD_Result MHD_queue_response(struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
_MHD_EXTERN enum MHD_Result MHD_add_response_header(struct MHD_Response *response, const char *header, const char *content)
#define MHD_STATICSTR_LEN_(macro)
MHD internal shared structures.
Header for platform missing functions.
limits values definitions
Header for string manipulating helpers.
struct MHD_Daemon * daemon
struct _MHD_str_w_len token68