GNU libmicrohttpd 1.0.0
Loading...
Searching...
No Matches
HTTP authentication

Macros

#define MHD_MD5_DIGEST_SIZE   16
 
#define MHD_SHA256_DIGEST_SIZE   32
 
#define MHD_SHA512_256_DIGEST_SIZE   32
 
#define MHD_INVALID_NONCE   -1
 

Functions

_MHD_EXTERN size_t MHD_digest_get_hash_size (enum MHD_DigestAuthAlgo3 algo3)
 
_MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, void *userhash_bin, size_t bin_buf_size)
 
_MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash_hex (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, char *userhash_hex, size_t hex_buf_size)
 
_MHD_EXTERN struct MHD_DigestAuthInfoMHD_digest_auth_get_request_info3 (struct MHD_Connection *connection)
 
_MHD_EXTERN struct MHD_DigestAuthUsernameInfoMHD_digest_auth_get_username3 (struct MHD_Connection *connection)
 
_MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check3 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3)
 
_MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userdigest (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, const char *password, void *userdigest_bin, size_t bin_buf_size)
 
_MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check_digest3 (struct MHD_Connection *connection, const char *realm, const char *username, const void *userdigest, size_t userdigest_size, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3)
 
_MHD_EXTERN enum MHD_Result MHD_queue_auth_required_response3 (struct MHD_Connection *connection, const char *realm, const char *opaque, const char *domain, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 algo, int userhash_support, int prefer_utf8)
 
_MHD_EXTERN charMHD_digest_auth_get_username (struct MHD_Connection *connection)
 
_MHD_EXTERN int MHD_digest_auth_check2 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo)
 
_MHD_EXTERN int MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout)
 
_MHD_EXTERN int MHD_digest_auth_check_digest2 (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t *digest, size_t digest_size, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo)
 
_MHD_EXTERN int MHD_digest_auth_check_digest (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t digest[MHD_MD5_DIGEST_SIZE], unsigned int nonce_timeout)
 
_MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response2 (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthAlgorithm algo)
 
_MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale)
 
_MHD_EXTERN struct MHD_BasicAuthInfoMHD_basic_auth_get_username_password3 (struct MHD_Connection *connection)
 
_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 charMHD_basic_auth_get_username_password (struct MHD_Connection *connection, char **password)
 
_MHD_EXTERN enum MHD_Result MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, const char *realm, struct MHD_Response *response)
 
static enum MHD_DigestAuthResult digest_auth_check_all_inner (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, const uint8_t *userdigest, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3, char **pbuf, struct DigestAlgorithm *da)
 
static enum MHD_DigestAuthResult digest_auth_check_all (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, const uint8_t *userdigest, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3)
 
static enum MHD_Result queue_auth_required_response3_inner (struct MHD_Connection *connection, const char *realm, const char *opaque, const char *domain, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3, int userhash_support, int prefer_utf8, char **buf_ptr, struct DigestAlgorithm *da)
 

Detailed Description

MHD API related to basic and digest HTTP authentication.

Macro Definition Documentation

◆ MHD_INVALID_NONCE

#define MHD_INVALID_NONCE   -1

Constant to indicate that the nonce of the provided authentication code was wrong. Used as return code by MHD_digest_auth_check(), MHD_digest_auth_check2(), MHD_digest_auth_check_digest(), MHD_digest_auth_check_digest2().

Definition at line 5751 of file microhttpd.h.

Referenced by MHD_digest_auth_check2(), and MHD_digest_auth_check_digest2().

◆ MHD_MD5_DIGEST_SIZE

#define MHD_MD5_DIGEST_SIZE   16

Length of the binary output of the MD5 hash function.

See also
MHD_digest_get_hash_size()

Definition at line 4683 of file microhttpd.h.

Referenced by digest_get_hash_size(), and MHD_digest_auth_check_digest().

◆ MHD_SHA256_DIGEST_SIZE

#define MHD_SHA256_DIGEST_SIZE   32

Length of the binary output of the SHA-256 hash function.

See also
MHD_digest_get_hash_size()

Definition at line 4690 of file microhttpd.h.

Referenced by digest_get_hash_size().

◆ MHD_SHA512_256_DIGEST_SIZE

#define MHD_SHA512_256_DIGEST_SIZE   32

Length of the binary output of the SHA-512/256 hash function.

Warning
While this value is the same as the MHD_SHA256_DIGEST_SIZE, the calculated digests for SHA-256 and SHA-512/256 are different.
See also
MHD_digest_get_hash_size()
Note
Available since MHD_VERSION 0x00097701

Definition at line 4700 of file microhttpd.h.

Referenced by digest_get_hash_size().

Function Documentation

◆ digest_auth_check_all()

static enum MHD_DigestAuthResult digest_auth_check_all ( struct MHD_Connection * connection,
const char * realm,
const char * username,
const char * password,
const uint8_t * userdigest,
unsigned int nonce_timeout,
uint32_t max_nc,
enum MHD_DigestAuthMultiQOP mqop,
enum MHD_DigestAuthMultiAlgo3 malgo3 )
static

Authenticates the authorization header sent by the client

If RFC2069 mode is allowed by setting bit MHD_DIGEST_AUTH_QOP_NONE in mqop and the client uses this mode, then server generated nonces are used as one-time nonces because nonce-count is not supported in this old RFC. Communication in this mode is very inefficient, especially if the client requests several resources one-by-one as for every request new nonce must be generated and client repeat all requests twice (the first time to get a new nonce and the second time to perform an authorised request).

Parameters
connectionthe MHD connection structure
realmthe realm for authorization of the client
usernamethe username to be authenticated, must be in clear text even if userhash is used by the client
passwordthe password used in the authentication, must be NULL if userdigest is not NULL
userdigestthe precalculated binary hash of the string "username:realm:password", must be NULL if password is not NULL
nonce_timeoutthe period of seconds since nonce generation, when the nonce is recognised as valid and not stale; if set to zero then daemon's default value is used
max_ncthe maximum allowed nc (Nonce Count) value, if client's nc exceeds the specified value then MHD_DAUTH_NONCE_STALE is returned; if set to zero then daemon's default value is used
mqopthe QOP to use
malgo3digest algorithms allowed to use, fail if algorithm specified by the client is not allowed by this parameter
Returns
MHD_DAUTH_OK if authenticated, error code otherwise.

Definition at line 3081 of file digestauth.c.

References MHD_Connection::daemon, digest_auth_check_all_inner(), digest_deinit, digest_setup_zero, MHD_HTTP_OK, and NULL.

Referenced by MHD_digest_auth_check3(), and MHD_digest_auth_check_digest3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ digest_auth_check_all_inner()

static enum MHD_DigestAuthResult digest_auth_check_all_inner ( struct MHD_Connection * connection,
const char * realm,
const char * username,
const char * password,
const uint8_t * userdigest,
unsigned int nonce_timeout,
uint32_t max_nc,
enum MHD_DigestAuthMultiQOP mqop,
enum MHD_DigestAuthMultiAlgo3 malgo3,
char ** pbuf,
struct DigestAlgorithm * da )
static

Authenticates the authorization header sent by the client

If RFC2069 mode is allowed by setting bit MHD_DIGEST_AUTH_QOP_NONE in mqop and the client uses this mode, then server generated nonces are used as one-time nonces because nonce-count is not supported in this old RFC. Communication in this mode is very inefficient, especially if the client requests several resources one-by-one as for every request new nonce must be generated and client repeat all requests twice (the first time to get a new nonce and the second time to perform an authorised request).

Parameters
connectionthe MHD connection structure
realmthe realm for authorization of the client
usernamethe username to be authenticated, must be in clear text even if userhash is used by the client
passwordthe password used in the authentication, must be NULL if userdigest is not NULL
userdigestthe precalculated binary hash of the string "username:realm:password", must be NULL if password is not NULL
nonce_timeoutthe period of seconds since nonce generation, when the nonce is recognised as valid and not stale; unlike digest_auth_check_all() zero is used literally
max_ncthe maximum allowed nc (Nonce Count) value, if client's nc exceeds the specified value then MHD_DAUTH_NONCE_STALE is returned; unlike digest_auth_check_all() zero is treated as "no limit"
mqopthe QOP to use
malgo3digest algorithms allowed to use, fail if algorithm specified by the client is not allowed by this parameter
[out]pbufthe pointer to pointer to internally malloc'ed buffer, to be freed if not NULL upon return
Returns
MHD_DAUTH_OK if authenticated, error code otherwise.

< Client's algorithm

< Client's QOP

Temporal buffer in stack for unquoting and other needs

< Temporal malloc'ed buffer for unquoting

< The size of tmp2 buffer

Definition at line 2534 of file digestauth.c.

References _, _MHD_AUTH_DIGEST_MAX_PARAM_SIZE, _MHD_STATIC_UNQ_BUFFER_SIZE, _MHD_UNQ_OK, MHD_Connection::addr, MHD_Connection::addr_len, calc_userdigest(), calc_userhash(), calculate_nonce(), check_nonce_nc(), check_uri_match(), MHD_Connection::daemon, digest_calc_hash(), digest_ext_error, digest_get_size(), digest_init_one_time(), digest_reset(), digest_update(), digest_update_str(), digest_update_with_colon(), get_base_digest_algo(), get_buffer_for_size(), get_nonce_timestamp(), get_rq_extended_uname_copy_z(), get_unquoted_param(), get_unquoted_param_copy(), MHD_Request::headers_received, MHD_Request::http_mthd, is_param_equal(), is_param_equal_caseless(), MHD_Request::method, mhd_assert, MHD_bin_to_hex(), MHD_CHECK_NONCENC_OK, MHD_CHECK_NONCENC_STALE, MHD_CHECK_NONCENC_WRONG, MHD_DAUTH_BIND_NONCE_NONE, MHD_DAUTH_ERROR, MHD_DAUTH_EXT_PARAM_MIN_LEN, MHD_DAUTH_NONCE_OTHER_COND, MHD_DAUTH_NONCE_STALE, MHD_DAUTH_NONCE_WRONG, MHD_DAUTH_OK, MHD_DAUTH_RESPONSE_WRONG, MHD_DAUTH_TOO_LARGE, MHD_DAUTH_WRONG_ALGO, MHD_DAUTH_WRONG_HEADER, MHD_DAUTH_WRONG_QOP, MHD_DAUTH_WRONG_REALM, MHD_DAUTH_WRONG_URI, MHD_DAUTH_WRONG_USERNAME, MHD_DIGEST_AUTH_ALGO3_SESSION, MHD_DIGEST_AUTH_QOP_AUTH_INT, MHD_DIGEST_AUTH_QOP_NONE, MHD_DIGEST_BASE_ALGO_MD5, MHD_DIGEST_BASE_ALGO_SHA256, MHD_DIGEST_BASE_ALGO_SHA512_256, MHD_get_master(), MHD_hex_to_bin(), MHD_HTTP_OK, MHD_monotonic_msec_counter(), MHD_PANIC, MHD_strx_to_uint64_n_(), NONCE_STD_LEN, NULL, MHD_Connection::rq, TRIM_TO_TIMESTAMP, MHD_Request::url, and MHD_Request::url_len.

Referenced by digest_auth_check_all().

Here is the caller graph for this function:

◆ MHD_basic_auth_get_username_password()

_MHD_EXTERN char * MHD_basic_auth_get_username_password ( struct MHD_Connection * connection,
char ** password )

Get the username and password from the basic authorization header sent by the client

Parameters
connectionThe MHD connection structure
[out]passworda pointer for the password, free using MHD_free().
Returns
NULL if no username could be found, a pointer to the username if found, free using MHD_free().

Get the username and password from the basic authorization header sent by the client

Parameters
connectionThe MHD connection structure
[out]passworda pointer for the password, free using MHD_free().
Returns
NULL if no username could be found, a pointer to the username if found, free using MHD_free().

Definition at line 137 of file basicauth.c.

References _, MHD_Connection::daemon, mhd_assert, MHD_basic_auth_get_username_password3(), MHD_HTTP_OK, NULL, MHD_BasicAuthInfo::password, and MHD_BasicAuthInfo::username.

Here is the call graph for this function:

◆ MHD_basic_auth_get_username_password3()

_MHD_EXTERN struct MHD_BasicAuthInfo * MHD_basic_auth_get_username_password3 ( struct MHD_Connection * connection)

Get the username and password from the Basic Authorisation header sent by the client

Parameters
connectionthe MHD connection structure
Returns
NULL if no valid Basic Authentication header is present in current request, or pointer to structure with username and password, which must be freed by MHD_free().
Note
Available since MHD_VERSION 0x00097701

Definition at line 49 of file basicauth.c.

References _, MHD_Connection::daemon, mhd_assert, MHD_HTTP_OK, NULL, MHD_BasicAuthInfo::password_len, and MHD_BasicAuthInfo::username_len.

Referenced by MHD_basic_auth_get_username_password().

Here is the caller graph for this function:

◆ MHD_digest_auth_calc_userdigest()

_MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userdigest ( enum MHD_DigestAuthAlgo3 algo3,
const char * username,
const char * realm,
const char * password,
void * userdigest_bin,
size_t bin_buf_size )

Calculate userdigest, return it as a binary data.

The "userdigest" is the hash of the "username:realm:password" string.

The "userdigest" can be used to avoid storing the password in clear text in database/files

This function is designed to improve security of stored credentials, the "userdigest" does not improve security of the authentication process.

The results can be used to store username & userdigest pairs instead of username & password pairs. To further improve security, application may store username & userhash & userdigest triplets.

Parameters
algo3the digest algorithm
usernamethe username
realmthe realm
passwordthe password
[out]userdigest_binthe output buffer for userdigest; if this function succeeds, then this buffer has #MHD_digest_get_hash_size(algo3) bytes of userdigest upon return
bin_buf_sizethe size of the userdigest_bin buffer, must be at least #MHD_digest_get_hash_size(algo3) bytes long
Returns
MHD_YES on success, MHD_NO if userdigest_bin is too small or if algo3 algorithm is not supported (or external error has occurred, see MHD_FEATURE_EXTERN_HASH).
See also
MHD_digest_auth_check_digest3()
Note
Available since MHD_VERSION 0x00097701

Definition at line 1937 of file digestauth.c.

References calc_userdigest(), digest_deinit, digest_ext_error, digest_get_size(), digest_init_one_time(), get_base_digest_algo(), MHD_HTTP_OK, MHD_NO, and MHD_YES.

Here is the call graph for this function:

◆ MHD_digest_auth_calc_userhash()

_MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash ( enum MHD_DigestAuthAlgo3 algo3,
const char * username,
const char * realm,
void * userhash_bin,
size_t bin_buf_size )

Calculate "userhash", return it as binary data.

The "userhash" is the hash of the string "username:realm".

The "userhash" could be used to avoid sending username in cleartext in Digest Authorization client's header.

Userhash is not designed to hide the username in local database or files, as username in cleartext is required for MHD_digest_auth_check3() function to check the response, but it can be used to hide username in HTTP headers.

This function could be used when the new username is added to the username database to save the "userhash" alongside with the username (preferably) or when loading list of the usernames to generate the userhash for every loaded username (this will cause delays at the start with the long lists).

Once "userhash" is generated it could be used to identify users by clients with "userhash" support. Avoid repetitive usage of this function for the same username/realm combination as it will cause excessive CPU load; save and re-use the result instead.

Parameters
algo3the algorithm for userhash calculations
usernamethe username
realmthe realm
[out]userhash_binthe output buffer for userhash as binary data; if this function succeeds, then this buffer has #MHD_digest_get_hash_size(algo3) bytes of userhash upon return
bin_buf_sizethe size of the userhash_bin buffer, must be at least #MHD_digest_get_hash_size(algo3) bytes long
Returns
MHD_YES on success, MHD_NO if bin_buf_size is too small or if algo3 algorithm is not supported (or external error has occurred, see MHD_FEATURE_EXTERN_HASH)
See also
MHD_digest_auth_calc_userhash_hex()
Note
Available since MHD_VERSION 0x00097701

Definition at line 2042 of file digestauth.c.

References calc_userhash(), digest_deinit, digest_ext_error, digest_get_size(), digest_init_one_time(), get_base_digest_algo(), MHD_HTTP_OK, MHD_NO, and MHD_YES.

Referenced by MHD_digest_auth_calc_userhash_hex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_digest_auth_calc_userhash_hex()

_MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash_hex ( enum MHD_DigestAuthAlgo3 algo3,
const char * username,
const char * realm,
char * userhash_hex,
size_t hex_buf_size )

Calculate "userhash", return it as hexadecimal string.

The "userhash" is the hash of the string "username:realm".

The "userhash" could be used to avoid sending username in cleartext in Digest Authorization client's header.

Userhash is not designed to hide the username in local database or files, as username in cleartext is required for MHD_digest_auth_check3() function to check the response, but it can be used to hide username in HTTP headers.

This function could be used when the new username is added to the username database to save the "userhash" alongside with the username (preferably) or when loading list of the usernames to generate the userhash for every loaded username (this will cause delays at the start with the long lists).

Once "userhash" is generated it could be used to identify users by clients with "userhash" support. Avoid repetitive usage of this function for the same username/realm combination as it will cause excessive CPU load; save and re-use the result instead.

Parameters
algo3the algorithm for userhash calculations
usernamethe username
realmthe realm
[out]userhash_hexthe output buffer for userhash as hex string; if this function succeeds, then this buffer has #MHD_digest_get_hash_size(algo3)*2 chars long userhash zero-terminated string
bin_buf_sizethe size of the userhash_bin buffer, must be at least #MHD_digest_get_hash_size(algo3)*2+1 chars long
Returns
MHD_YES on success, MHD_NO if bin_buf_size is too small or if algo3 algorithm is not supported (or external error has occurred, see MHD_FEATURE_EXTERN_HASH).
See also
MHD_digest_auth_calc_userhash()
Note
Available since MHD_VERSION 0x00097701

Definition at line 2117 of file digestauth.c.

References digest_get_hash_size(), MHD_bin_to_hex_z(), MHD_digest_auth_calc_userhash(), MHD_HTTP_OK, MHD_NO, and MHD_YES.

Here is the call graph for this function:

◆ MHD_digest_auth_check()

_MHD_EXTERN int MHD_digest_auth_check ( struct MHD_Connection * connection,
const char * realm,
const char * username,
const char * password,
unsigned int nonce_timeout )

Authenticates the authorization header sent by the client. Uses MHD_DIGEST_ALG_MD5 (for now, for backwards-compatibility). Note that this MAY change to MHD_DIGEST_ALG_AUTO in the future. If you want to be sure you get MD5, use MHD_digest_auth_check2() and specify MD5 explicitly.

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
usernameThe username needs to be authenticated
passwordThe password used in the authentication
nonce_timeoutThe amount of time for a nonce to be invalid in seconds
Returns
MHD_YES if authenticated, MHD_NO if not, MHD_INVALID_NONCE if nonce is invalid or stale

Authenticates the authorization header sent by the client. Uses MHD_DIGEST_ALG_MD5 (for now, for backwards-compatibility). Note that this MAY change to MHD_DIGEST_ALG_AUTO in the future. If you want to be sure you get MD5, use MHD_digest_auth_check2() and specify MD5 explicitly.

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
usernameThe username needs to be authenticated
passwordThe password used in the authentication
nonce_timeoutThe amount of time for a nonce to be invalid in seconds
Returns
MHD_YES if authenticated, MHD_NO if not, MHD_INVALID_NONCE if nonce is invalid or stale

Definition at line 3133 of file digestauth.c.

References MHD_DIGEST_ALG_MD5, MHD_digest_auth_check2(), and MHD_HTTP_OK.

Here is the call graph for this function:

◆ MHD_digest_auth_check2()

_MHD_EXTERN int MHD_digest_auth_check2 ( struct MHD_Connection * connection,
const char * realm,
const char * username,
const char * password,
unsigned int nonce_timeout,
enum MHD_DigestAuthAlgorithm algo )

Authenticates the authorization header sent by the client.

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
usernameThe username needs to be authenticated
passwordThe password used in the authentication
nonce_timeoutThe amount of time for a nonce to be invalid in seconds
algodigest algorithms allowed for verification
Returns
MHD_YES if authenticated, MHD_NO if not, MHD_INVALID_NONCE if nonce is invalid or stale
Note
Available since MHD_VERSION 0x00096200

Authenticates the authorization header sent by the client.

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
usernameThe username needs to be authenticated
passwordThe password used in the authentication
nonce_timeoutThe amount of time for a nonce to be invalid in seconds
algodigest algorithms allowed for verification
Returns
MHD_YES if authenticated, MHD_NO if not, MHD_INVALID_NONCE if nonce is invalid or stale
Note
Available since MHD_VERSION 0x00096200

Definition at line 3330 of file digestauth.c.

References _, MHD_DAUTH_NONCE_OTHER_COND, MHD_DAUTH_NONCE_STALE, MHD_DAUTH_NONCE_WRONG, MHD_DAUTH_OK, MHD_DIGEST_ALG_AUTO, MHD_DIGEST_ALG_MD5, MHD_DIGEST_ALG_SHA256, MHD_digest_auth_check3(), MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION, MHD_DIGEST_AUTH_MULT_ALGO3_MD5, MHD_DIGEST_AUTH_MULT_ALGO3_SHA256, MHD_DIGEST_AUTH_MULT_QOP_AUTH, MHD_HTTP_OK, MHD_INVALID_NONCE, MHD_NO, MHD_PANIC, and MHD_YES.

Referenced by MHD_digest_auth_check().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_digest_auth_check3()

_MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check3 ( struct MHD_Connection * connection,
const char * realm,
const char * username,
const char * password,
unsigned int nonce_timeout,
uint32_t max_nc,
enum MHD_DigestAuthMultiQOP mqop,
enum MHD_DigestAuthMultiAlgo3 malgo3 )

Authenticates the authorization header sent by the client.

If RFC2069 mode is allowed by setting bit MHD_DIGEST_AUTH_QOP_NONE in mqop and the client uses this mode, then server generated nonces are used as one-time nonces because nonce-count is not supported in this old RFC. Communication in this mode is very inefficient, especially if the client requests several resources one-by-one as for every request a new nonce must be generated and client repeats all requests twice (first time to get a new nonce and second time to perform an authorised request).

Parameters
connectionthe MHD connection structure
realmthe realm for authorization of the client
usernamethe username to be authenticated, must be in clear text even if userhash is used by the client
passwordthe password matching the username (and the realm)
nonce_timeoutthe period of seconds since nonce generation, when the nonce is recognised as valid and not stale; if zero is specified then daemon default value is used.
max_ncthe maximum allowed nc (Nonce Count) value, if client's nc exceeds the specified value then MHD_DAUTH_NONCE_STALE is returned; if zero is specified then daemon default value is used.
mqopthe QOP to use
malgo3digest algorithms allowed to use, fail if algorithm used by the client is not allowed by this parameter
Returns
MHD_DAUTH_OK if authenticated, the error code otherwise
Note
Available since MHD_VERSION 0x00097708

Definition at line 3180 of file digestauth.c.

References digest_auth_check_all(), mhd_assert, MHD_HTTP_OK, and NULL.

Referenced by MHD_digest_auth_check2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_digest_auth_check_digest()

_MHD_EXTERN int MHD_digest_auth_check_digest ( struct MHD_Connection * connection,
const char * realm,
const char * username,
const uint8_t digest[MHD_MD5_DIGEST_SIZE],
unsigned int nonce_timeout )

Authenticates the authorization header sent by the client Uses MHD_DIGEST_ALG_MD5 (required, as digest is of fixed size).

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
usernameThe username needs to be authenticated
digestAn ‘unsigned char *’ pointer to the binary hash for the precalculated hash value "username:realm:password"; length must be MHD_MD5_DIGEST_SIZE bytes
nonce_timeoutThe amount of time for a nonce to be invalid in seconds
Returns
MHD_YES if authenticated, MHD_NO if not, MHD_INVALID_NONCE if nonce is invalid or stale
Note
Available since MHD_VERSION 0x00096000

Authenticates the authorization header sent by the client Uses MHD_DIGEST_ALG_MD5 (required, as digest is of fixed size).

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
usernameThe username needs to be authenticated
digestAn ‘unsigned char *’ pointer to the binary hash for the precalculated hash value "username:realm:password"; length must be MHD_MD5_DIGEST_SIZE bytes
nonce_timeoutThe amount of time for a nonce to be invalid in seconds
Returns
MHD_YES if authenticated, MHD_NO if not, MHD_INVALID_NONCE if nonce is invalid or stale
Note
Available since MHD_VERSION 0x00096000

Definition at line 3443 of file digestauth.c.

References MHD_DIGEST_ALG_MD5, MHD_digest_auth_check_digest2(), MHD_HTTP_OK, and MHD_MD5_DIGEST_SIZE.

Here is the call graph for this function:

◆ MHD_digest_auth_check_digest2()

_MHD_EXTERN int MHD_digest_auth_check_digest2 ( struct MHD_Connection * connection,
const char * realm,
const char * username,
const uint8_t * digest,
size_t digest_size,
unsigned int nonce_timeout,
enum MHD_DigestAuthAlgorithm algo )

Authenticates the authorization header sent by the client.

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
usernameThe username needs to be authenticated
digestAn ‘unsigned char *’ pointer to the binary MD5 sum for the precalculated hash value "username:realm:password" of digest_size bytes
digest_sizenumber of bytes in digest (size must match algo!)
nonce_timeoutThe amount of time for a nonce to be invalid in seconds
algodigest algorithms allowed for verification
Returns
MHD_YES if authenticated, MHD_NO if not, MHD_INVALID_NONCE if nonce is invalid or stale
Note
Available since MHD_VERSION 0x00096200

Authenticates the authorization header sent by the client.

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
usernameThe username needs to be authenticated
digestAn ‘unsigned char *’ pointer to the binary MD5 sum for the precalculated hash value "username:realm:password" of digest_size bytes
digest_sizenumber of bytes in digest (size must match algo!)
nonce_timeoutThe amount of time for a nonce to be invalid in seconds
algodigest algorithms allowed for verification
Returns
MHD_YES if authenticated, MHD_NO if not, MHD_INVALID_NONCE if nonce is invalid or stale
Note
Available since MHD_VERSION 0x00096200

Definition at line 3386 of file digestauth.c.

References _, MHD_DAUTH_NONCE_OTHER_COND, MHD_DAUTH_NONCE_STALE, MHD_DAUTH_NONCE_WRONG, MHD_DAUTH_OK, MHD_DIGEST_ALG_AUTO, MHD_DIGEST_ALG_MD5, MHD_DIGEST_ALG_SHA256, MHD_digest_auth_check_digest3(), MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION, MHD_DIGEST_AUTH_MULT_ALGO3_MD5, MHD_DIGEST_AUTH_MULT_ALGO3_SHA256, MHD_DIGEST_AUTH_MULT_QOP_AUTH, MHD_HTTP_OK, MHD_INVALID_NONCE, MHD_NO, MHD_PANIC, and MHD_YES.

Referenced by MHD_digest_auth_check_digest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_digest_auth_check_digest3()

_MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check_digest3 ( struct MHD_Connection * connection,
const char * realm,
const char * username,
const void * userdigest,
size_t userdigest_size,
unsigned int nonce_timeout,
uint32_t max_nc,
enum MHD_DigestAuthMultiQOP mqop,
enum MHD_DigestAuthMultiAlgo3 malgo3 )

Authenticates the authorization header sent by the client by using hash of "username:realm:password".

If RFC2069 mode is allowed by setting bit MHD_DIGEST_AUTH_QOP_NONE in mqop and the client uses this mode, then server generated nonces are used as one-time nonces because nonce-count is not supported in this old RFC. Communication in this mode is very inefficient, especially if the client requests several resources one-by-one as for every request a new nonce must be generated and client repeats all requests twice (first time to get a new nonce and second time to perform an authorised request).

Parameters
connectionthe MHD connection structure
realmthe realm for authorization of the client
usernamethe username to be authenticated, must be in clear text even if userhash is used by the client
userdigestthe precalculated binary hash of the string "username:realm:password", see MHD_digest_auth_calc_userdigest()
userdigest_sizethe size of the userdigest in bytes, must match the hashing algorithm (see MHD_MD5_DIGEST_SIZE, MHD_SHA256_DIGEST_SIZE, MHD_SHA512_256_DIGEST_SIZE, MHD_digest_get_hash_size())
nonce_timeoutthe period of seconds since nonce generation, when the nonce is recognised as valid and not stale; if zero is specified then daemon default value is used.
max_ncthe maximum allowed nc (Nonce Count) value, if client's nc exceeds the specified value then MHD_DAUTH_NONCE_STALE is returned; if zero is specified then daemon default value is used.
mqopthe QOP to use
malgo3digest algorithms allowed to use, fail if algorithm used by the client is not allowed by this parameter; more than one base algorithms (MD5, SHA-256, SHA-512/256) cannot be used at the same time for this function as userdigest must match specified algorithm
Returns
MHD_DAUTH_OK if authenticated, the error code otherwise
See also
MHD_digest_auth_calc_userdigest()
Note
Available since MHD_VERSION 0x00097701

Authenticates the authorization header sent by the client by using hash of "username:realm:password".

If RFC2069 mode is allowed by setting bit MHD_DIGEST_AUTH_QOP_NONE in mqop and the client uses this mode, then server generated nonces are used as one-time nonces because nonce-count is not supported in this old RFC. Communication in this mode is very inefficient, especially if the client requests several resources one-by-one as for every request a new nonce must be generated and client repeats all requests twice (first time to get a new nonce and second time to perform an authorised request).

Parameters
connectionthe MHD connection structure
realmthe realm for authorization of the client
usernamethe username to be authenticated, must be in clear text even if userhash is used by the client
userdigestthe precalculated binary hash of the string "username:realm:password", see MHD_digest_auth_calc_userdigest()
userdigest_sizethe size of the userdigest in bytes, must match the hashing algorithm (see MHD_MD5_DIGEST_SIZE, MHD_SHA256_DIGEST_SIZE, MHD_SHA512_256_DIGEST_SIZE, MHD_digest_get_hash_size())
nonce_timeoutthe period of seconds since nonce generation, when the nonce is recognised as valid and not stale; if zero is specified then daemon default value is used.
max_ncthe maximum allowed nc (Nonce Count) value, if client's nc exceeds the specified value then MHD_DAUTH_NONCE_STALE is returned; if zero is specified then daemon default value is used.
mqopthe QOP to use
malgo3digest algorithms allowed to use, fail if algorithm used by the client is not allowed by this parameter; more than one base algorithms (MD5, SHA-256, SHA-512/256) cannot be used at the same time for this function as userdigest must match specified algorithm
Returns
MHD_DAUTH_OK if authenticated, the error code otherwise
See also
MHD_digest_auth_calc_userdigest()
Note
Available since MHD_VERSION 0x00097708

Definition at line 3246 of file digestauth.c.

References _, MHD_Connection::daemon, digest_auth_check_all(), digest_get_hash_size(), MHD_DAUTH_WRONG_ALGO, MHD_DIGEST_BASE_ALGO_MD5, MHD_DIGEST_BASE_ALGO_SHA256, MHD_DIGEST_BASE_ALGO_SHA512_256, MHD_HTTP_OK, MHD_PANIC, and NULL.

Referenced by MHD_digest_auth_check_digest2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_digest_auth_get_request_info3()

_MHD_EXTERN struct MHD_DigestAuthInfo * MHD_digest_auth_get_request_info3 ( struct MHD_Connection * connection)

Get information about Digest Authorization client's header.

Parameters
connectionThe MHD connection structure
Returns
NULL if no valid Digest Authorization header is used in the request; a pointer to the structure with information if the valid request header found, free using MHD_free().
See also
MHD_digest_auth_get_username3()
Note
Available since MHD_VERSION 0x00097701

Get information about Digest Authorization client's header.

Parameters
connectionThe MHD connection structure
Returns
NULL no valid Digest Authorization header is used in the request; a pointer structure with information if the valid request header found, free using MHD_free().
Note
Available since MHD_VERSION 0x00097701

Definition at line 1268 of file digestauth.c.

References get_rq_nc(), get_rq_param_unquoted_copy_z(), get_rq_uname(), get_rq_uname_type(), get_rq_unames_size(), mhd_assert, MHD_calloc_(), MHD_DIGEST_AUTH_INVALID_NC_VALUE, MHD_DIGEST_AUTH_UNAME_TYPE_INVALID, MHD_DIGEST_AUTH_UNAME_TYPE_MISSING, MHD_GET_RQ_NC_VALID, MHD_HTTP_OK, NULL, and MHD_DigestAuthInfo::uname_type.

Here is the call graph for this function:

◆ MHD_digest_auth_get_username()

_MHD_EXTERN char * MHD_digest_auth_get_username ( struct MHD_Connection * connection)

Get the username from the authorization header sent by the client

This function supports username in standard and extended notations. "userhash" is not supported by this function.

Parameters
connectionThe MHD connection structure
Returns
NULL if no username could be found, username provided as "userhash", extended notation broken or memory allocation error occurs; a pointer to the username if found, free using MHD_free().
Warning
Returned value must be freed by MHD_free().
See also
MHD_digest_auth_get_username3()

Definition at line 1414 of file digestauth.c.

References get_rq_uname(), get_rq_uname_type(), get_rq_unames_size(), mhd_assert, MHD_calloc_(), MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED, MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD, MHD_HTTP_OK, NULL, MHD_DigestAuthUsernameInfo::uname_type, and MHD_DigestAuthUsernameInfo::username.

Here is the call graph for this function:

◆ MHD_digest_auth_get_username3()

_MHD_EXTERN struct MHD_DigestAuthUsernameInfo * MHD_digest_auth_get_username3 ( struct MHD_Connection * connection)

Get the username from Digest Authorization client's header.

Parameters
connectionThe MHD connection structure
Returns
NULL if no valid Digest Authorization header is used in the request, or no username parameter is present in the header, or username is provided incorrectly by client (see description for MHD_DIGEST_AUTH_UNAME_TYPE_INVALID); a pointer structure with information if the valid request header found, free using MHD_free().
See also
MHD_digest_auth_get_request_info3() provides more complete information
Note
Available since MHD_VERSION 0x00097701

Get the username from Digest Authorization client's header.

Parameters
connectionThe MHD connection structure
Returns
NULL if no valid Digest Authorization header is used in the request, or no username parameter is present in the header, or username is provided incorrectly by client (see description for MHD_DIGEST_AUTH_UNAME_TYPE_INVALID); a pointer structure with information if the valid request header found, free using MHD_free().
See also
MHD_digest_auth_get_request_info3() provides more complete information
Note
Available since MHD_VERSION 0x00097701

Definition at line 1356 of file digestauth.c.

References get_rq_uname(), get_rq_uname_type(), get_rq_unames_size(), mhd_assert, MHD_calloc_(), MHD_DIGEST_AUTH_UNAME_TYPE_INVALID, MHD_DIGEST_AUTH_UNAME_TYPE_MISSING, MHD_HTTP_OK, NULL, and MHD_DigestAuthUsernameInfo::uname_type.

Here is the call graph for this function:

◆ MHD_digest_get_hash_size()

_MHD_EXTERN size_t MHD_digest_get_hash_size ( enum MHD_DigestAuthAlgo3 algo3)

Get digest size for specified algorithm.

The size of the digest specifies the size of the userhash, userdigest and other parameters which size depends on used hash algorithm.

Parameters
algo3the algorithm to check
Returns
the size of the digest (either MHD_MD5_DIGEST_SIZE or MHD_SHA256_DIGEST_SIZE/MHD_SHA512_256_DIGEST_SIZE) or zero if the input value is not supported or not valid
See also
MHD_digest_auth_calc_userdigest()
MHD_digest_auth_calc_userhash(), MHD_digest_auth_calc_userhash_hex()
Note
Available since MHD_VERSION 0x00097701

Definition at line 295 of file digestauth.c.

References digest_get_hash_size().

Here is the call graph for this function:

◆ MHD_queue_auth_fail_response()

_MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response ( struct MHD_Connection * connection,
const char * realm,
const char * opaque,
struct MHD_Response * response,
int signal_stale )

Queues a response to request authentication from the client. For now uses MD5 (for backwards-compatibility). Still, if you need to be sure, use MHD_queue_auth_fail_response2().

This function modifies provided response. The response must not be reused and should be destroyed after call of this function.

Parameters
connectionThe MHD connection structure
realmthe realm presented to the client
opaquestring to user for opaque value
responsereply to send; should contain the "access denied" body; note that this function will set the "WWW Authenticate" header and that the caller should not do this; the NULL is tolerated
signal_staleMHD_YES if the nonce is stale to add 'stale=true' to the authentication header
Returns
MHD_YES on success, MHD_NO otherwise

Queues a response to request authentication from the client. For now uses MD5 (for backwards-compatibility). Still, if you need to be sure, use MHD_queue_auth_fail_response2().

Parameters
connectionThe MHD connection structure
realmthe realm presented to the client
opaquestring to user for opaque value
responsereply to send; should contain the "access denied" body; note that this function will set the "WWW Authenticate" header and that the caller should not do this; the NULL is tolerated
signal_staleMHD_YES if the nonce is stale to add 'stale=true' to the authentication header
Returns
MHD_YES on success, MHD_NO otherwise

Definition at line 4063 of file digestauth.c.

References MHD_DIGEST_ALG_MD5, MHD_HTTP_OK, and MHD_queue_auth_fail_response2().

Here is the call graph for this function:

◆ MHD_queue_auth_fail_response2()

_MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response2 ( struct MHD_Connection * connection,
const char * realm,
const char * opaque,
struct MHD_Response * response,
int signal_stale,
enum MHD_DigestAuthAlgorithm algo )

Queues a response to request authentication from the client

This function modifies provided response. The response must not be reused and should be destroyed after call of this function.

Parameters
connectionThe MHD connection structure
realmthe realm presented to the client
opaquestring to user for opaque value
responsereply to send; should contain the "access denied" body; note that this function will set the "WWW Authenticate" header and that the caller should not do this; the NULL is tolerated
signal_staleMHD_YES if the nonce is stale to add 'stale=true' to the authentication header
algodigest algorithm to use
Returns
MHD_YES on success, MHD_NO otherwise
Note
Available since MHD_VERSION 0x00096200

Queues a response to request authentication from the client

Parameters
connectionThe MHD connection structure
realmthe realm presented to the client
opaquestring to user for opaque value
responsereply to send; should contain the "access denied" body; note that this function will set the "WWW Authenticate" header and that the caller should not do this; the NULL is tolerated
signal_staleMHD_YES if the nonce is stale to add 'stale=true' to the authentication header
algodigest algorithm to use
Returns
MHD_YES on success, MHD_NO otherwise
Note
Available since MHD_VERSION 0x00096200

Definition at line 4019 of file digestauth.c.

References _, MHD_DIGEST_ALG_AUTO, MHD_DIGEST_ALG_MD5, MHD_DIGEST_ALG_SHA256, MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION, MHD_DIGEST_AUTH_MULT_ALGO3_MD5, MHD_DIGEST_AUTH_MULT_ALGO3_SHA256, MHD_DIGEST_AUTH_MULT_QOP_AUTH, MHD_HTTP_OK, MHD_PANIC, MHD_queue_auth_required_response3(), and NULL.

Referenced by MHD_queue_auth_fail_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_queue_auth_required_response3()

_MHD_EXTERN enum MHD_Result MHD_queue_auth_required_response3 ( struct MHD_Connection * connection,
const char * realm,
const char * opaque,
const char * domain,
struct MHD_Response * response,
int signal_stale,
enum MHD_DigestAuthMultiQOP mqop,
enum MHD_DigestAuthMultiAlgo3 malgo3,
int userhash_support,
int prefer_utf8 )

Queues a response to request authentication from the client

This function modifies provided response. The response must not be reused and should be destroyed (by MHD_destroy_response()) after call of this function.

If mqop allows both RFC 2069 (MHD_DIGEST_AUTH_QOP_NONE) and QOP with value, then response is formed like if MHD_DIGEST_AUTH_QOP_NONE bit was not set, because such response should be backward-compatible with RFC 2069.

If mqop allows only MHD_DIGEST_AUTH_MULT_QOP_NONE, then the response is formed in strict accordance with RFC 2069 (no 'qop', no 'userhash', no 'charset'). For better compatibility with clients, it is recommended (but not required) to set domain to NULL in this mode.

Parameters
connectionthe MHD connection structure
realmthe realm presented to the client
opaquethe string for opaque value, can be NULL, but NULL is not recommended for better compatibility with clients; the recommended format is hex or Base64 encoded string
domainthe optional space-separated list of URIs for which the same authorisation could be used, URIs can be in form "path-absolute" (the path for the same host with initial slash) or in form "absolute-URI" (the full path with protocol), in any case client may assume that URI is in the same "protection space" if it starts with any of values specified here; could be NULL (clients typically assume that the same credentials could be used for any URI on the same host); this list provides information for the client only and does not actually restrict anything on the server side
responsethe reply to send; should contain the "access denied" body; note: this function sets the "WWW Authenticate" header and the caller should not set this header; the NULL is tolerated
signal_staleif set to MHD_YES then indication of stale nonce used in the client's request is signalled by adding 'stale=true' to the authentication header, this instructs the client to retry immediately with the new nonce and the same credentials, without asking user for the new password
mqopthe QOP to use
malgo3digest algorithm to use; if several algorithms are allowed then MD5 is preferred (currently, may be changed in next versions)
userhash_supportif set to non-zero value (MHD_YES) then support of userhash is indicated, allowing client to provide hash("username:realm") instead of the username in clear text; note that clients are allowed to provide the username in cleartext even if this parameter set to non-zero; when userhash is used, application must be ready to identify users by provided userhash value instead of username; see MHD_digest_auth_calc_userhash() and MHD_digest_auth_calc_userhash_hex()
prefer_utf8if not set to MHD_NO, parameter 'charset=UTF-8' is added, indicating for the client that UTF-8 encoding for the username is preferred
Returns
MHD_YES on success, MHD_NO otherwise
Note
Available since MHD_VERSION 0x00097701

Definition at line 3966 of file digestauth.c.

References digest_deinit, digest_setup_zero, MHD_HTTP_OK, NULL, and queue_auth_required_response3_inner().

Referenced by MHD_queue_auth_fail_response2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_queue_basic_auth_fail_response()

_MHD_EXTERN enum MHD_Result MHD_queue_basic_auth_fail_response ( struct MHD_Connection * connection,
const char * realm,
struct MHD_Response * response )

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.

Parameters
connectionThe MHD connection structure
realmthe realm presented to the client
responseresponse object to modify and queue; the NULL is tolerated
Returns
MHD_YES on success, MHD_NO otherwise

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.

Parameters
connectionThe MHD connection structure
realmthe realm presented to the client
responseresponse object to modify and queue; the NULL is tolerated
Returns
MHD_YES on success, MHD_NO otherwise

Definition at line 313 of file basicauth.c.

References MHD_NO, and MHD_queue_basic_auth_required_response3().

Here is the call graph for this function:

◆ MHD_queue_basic_auth_required_response3()

_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 )

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 7617section-2 for details.

The 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.

Parameters
connectionthe MHD connection structure
realmthe realm presented to the client
prefer_utf8if not set to MHD_NO, parameter'charset="UTF-8"' will be added, indicating for client that UTF-8 encoding is preferred
responsethe response object to modify and queue; the NULL is tolerated
Returns
MHD_YES on success, MHD_NO otherwise
Note
Available since MHD_VERSION 0x00097704

Definition at line 223 of file basicauth.c.

References _, MHD_Connection::daemon, MHD_add_response_header(), mhd_assert, MHD_HTTP_HEADER_WWW_AUTHENTICATE, MHD_HTTP_OK, MHD_HTTP_UNAUTHORIZED, MHD_NO, MHD_queue_response(), MHD_STATICSTR_LEN_, and NULL.

Referenced by MHD_queue_basic_auth_fail_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ queue_auth_required_response3_inner()

static enum MHD_Result queue_auth_required_response3_inner ( struct MHD_Connection * connection,
const char * realm,
const char * opaque,
const char * domain,
struct MHD_Response * response,
int signal_stale,
enum MHD_DigestAuthMultiQOP mqop,
enum MHD_DigestAuthMultiAlgo3 malgo3,
int userhash_support,
int prefer_utf8,
char ** buf_ptr,
struct DigestAlgorithm * da )
static

Internal version of MHD_queue_auth_required_response3() to simplify cleanups.

Parameters
connectionthe MHD connection structure
realmthe realm presented to the client
opaquethe string for opaque value, can be NULL, but NULL is not recommended for better compatibility with clients; the recommended format is hex or Base64 encoded string
domainthe optional space-separated list of URIs for which the same authorisation could be used, URIs can be in form "path-absolute" (the path for the same host with initial slash) or in form "absolute-URI" (the full path with protocol), in any case client may assume that URI is in the same "protection space" if it starts with any of values specified here; could be NULL (clients typically assume that the same credentials could be used for any URI on the same host)
responsethe reply to send; should contain the "access denied" body; note that this function sets the "WWW Authenticate" header and that the caller should not do this; the NULL is tolerated
signal_staleset to MHD_YES if the nonce is stale to add 'stale=true' to the authentication header, this instructs the client to retry immediately with the new nonce and the same credentials, without asking user for the new password
mqopthe QOP to use
malgo3digest algorithm to use, MHD selects; if several algorithms are allowed then MD5 is preferred (currently, may be changed in next versions)
userhash_supportif set to non-zero value (MHD_YES) then support of userhash is indicated, the client may provide hash("username:realm") instead of username in clear text; note that clients are allowed to provide the username in cleartext even if this parameter set to non-zero; when userhash is used, application must be ready to identify users by provided userhash value instead of username; see MHD_digest_auth_calc_userhash() and MHD_digest_auth_calc_userhash_hex()
prefer_utf8if not set to MHD_NO, parameter 'charset=UTF-8' is added, indicating for the client that UTF-8 encoding is preferred
prefer_utf8if not set to MHD_NO, parameter 'charset=UTF-8' is added, indicating for the client that UTF-8 encoding is preferred
Returns
MHD_YES on success, MHD_NO otherwise
Note
Available since MHD_VERSION 0x00097701

< Selected algorithm

Definition at line 3509 of file digestauth.c.

References _, _MHD_AUTH_DIGEST_BASE, _MHD_AUTH_DIGEST_MAX_PARAM_SIZE, _MHD_MD5_TOKEN, _MHD_SHA256_TOKEN, _MHD_SHA512_256_TOKEN, calculate_add_nonce_with_retry(), MHD_Connection::daemon, digest_ext_error, digest_get_size(), digest_init_one_time(), get_base_digest_algo(), MHD_add_response_entry_no_alloc_(), mhd_assert, MHD_DIGEST_AUTH_ALGO3_MD5, MHD_DIGEST_AUTH_ALGO3_NON_SESSION, MHD_DIGEST_AUTH_ALGO3_SHA256, MHD_DIGEST_AUTH_ALGO3_SHA512_256, MHD_DIGEST_AUTH_MULT_QOP_AUTH_INT, MHD_DIGEST_AUTH_MULT_QOP_NONE, MHD_DIGEST_AUTH_QOP_AUTH_INT, MHD_DIGEST_BASE_ALGO_MD5, MHD_DIGEST_BASE_ALGO_SHA256, MHD_DIGEST_BASE_ALGO_SHA512_256, MHD_get_master(), MHD_HEADER_KIND, MHD_HTTP_HEADER_WWW_AUTHENTICATE, MHD_HTTP_OK, MHD_HTTP_UNAUTHORIZED, MHD_NO, MHD_PANIC, MHD_queue_response(), MHD_STATICSTR_LEN_, MHD_TOKEN_AUTH_, NONCE_STD_LEN, and NULL.

Referenced by MHD_queue_auth_required_response3().

Here is the call graph for this function:
Here is the caller graph for this function: