Bläddra i källkod

Document HTTP digest auth API functions (see #426)

bel2125 7 år sedan
förälder
incheckning
e9bccfb81b

+ 3 - 1
docs/APIReference.md

@@ -69,7 +69,10 @@ The content of both structures is not defined in the interface - they are only u
 * [`mg_get_context( conn );`](api/mg_get_context.md)
 
 * [`mg_send_http_error( conn, status_code, fmt, ... );`](api/mg_send_http_error.md)
+
 * [`mg_send_digest_access_authentication_request( conn, realm );`](api/mg_send_digest_access_authentication_request.md)
+* [`mg_check_digest_access_authentication( conn, realm, filename );`](api/mg_check_digest_access_authentication.md)
+* [`mg_modify_passwords_file( passwords_file_name, realm, user, password );`](api/mg_modify_passwords_file.md)
 
 
 ## Client API Functions
@@ -98,7 +101,6 @@ The content of both structures is not defined in the interface - they are only u
 * [`mg_handle_form_request( conn, fdh );`](api/mg_handle_form_request.md)
 * [`mg_lock_connection( conn );`](api/mg_lock_connection.md)
 * [`mg_md5( buf, ... );`](api/mg_md5.md)
-* [`mg_modify_passwords_file( passwords_file_name, domain, user, password );`](api/mg_modify_passwords_file.md)
 * [`mg_printf( conn, fmt, ... );`](api/mg_printf.md)
 * [`mg_read( conn, buf, len );`](api/mg_read.md)
 * [`mg_send_chunk( conn, buf, len );`](api/mg_send_chunk.md)

+ 33 - 0
docs/api/mg_check_digest_access_authentication.md

@@ -0,0 +1,33 @@
+# Civetweb API Reference
+
+### `mg_check_digest_access_authentication( conn, realm, filename );`
+
+### Parameters
+
+| Parameter | Type | Description |
+| :--- | :--- | :--- |
+|**`conn`**|`struct mg_connection *`| A pointer to the connection to be used to send data |
+|**`realm`**|`const char *`| The requested authentication realm or NULL |
+|**`filename`**|`const char *`| The path to the passwords file |
+
+### Return Value
+
+| Type | Description |
+| :--- | :--- |
+|`int`| An integer indicating success or failure |
+
+### Description
+
+This function can be used to check if a request header contains HTTP digest authentication
+information, matching user and password encoded within the password file.
+If the authentication realm (also called authentication domain) is NULL, the parameter
+`authentication_domain` as specified in the server configuration (`mg_start()`) is used.
+
+The function returns a negative number on errors.
+
+### See Also
+
+* [`mg_send_digest_access_authentication_request();`](mg_send_digest_access_authentication_request.md)
+* [`mg_modify_passwords_file();`](mg_modify_passwords_file.md)
+* [`mg_start();`](mg_start.md)
+

+ 5 - 0
docs/api/mg_modify_passwords_file.md

@@ -26,3 +26,8 @@ If the password parameter is not `NULL` an entry is added to the password file.
 The function returns 1 when successful and 0 if an error occurs.
 
 ### See Also
+
+* [`mg_check_digest_access_authentication();`](mg_check_digest_access_authentication.md)
+* [`mg_send_digest_access_authentication_request();`](mg_send_digest_access_authentication_request.md)
+
+

+ 4 - 0
docs/api/mg_send_digest_access_authentication_request.md

@@ -21,10 +21,14 @@ This function can be used to send a HTTP Digest Authentication request to the cl
 Browsers will react with repeating the request with user authentication data.
 If they do not yet know the user authentication for the requested realm, they will show
 a dialog to query username and password.
+In case the authentication realm (also called domain) is NULL, the parameter
+`authentication_domain` from the server configuration is used.
 The function returns a negative number on errors.
 
 ### See Also
 
+* [`mg_check_digest_access_authentication();`](mg_check_digest_access_authentication.md)
+* [`mg_modify_passwords_file();`](mg_modify_passwords_file.md)
 * [`mg_send_http_error();`](mg_send_http_error.md)
 * [`mg_write();`](mg_write.md)
 * [`mg_printf();`](mg_print.md)

+ 1 - 0
src/civetweb.c

@@ -7639,6 +7639,7 @@ authorize(struct mg_connection *conn, struct mg_file *filep, const char *realm)
 }
 
 
+/* Public function to check http digest authentication header */
 int
 mg_check_digest_access_authentication(struct mg_connection *conn,
                                       const char *realm,