From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/civetweb/docs/api/mg_set_auth_handler.md | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/civetweb/docs/api/mg_set_auth_handler.md (limited to 'src/civetweb/docs/api/mg_set_auth_handler.md') diff --git a/src/civetweb/docs/api/mg_set_auth_handler.md b/src/civetweb/docs/api/mg_set_auth_handler.md new file mode 100644 index 00000000..302324ad --- /dev/null +++ b/src/civetweb/docs/api/mg_set_auth_handler.md @@ -0,0 +1,30 @@ +# Civetweb API Reference + +### `mg_set_auth_handler( ctx, uri, handler, cbdata );` + +### Parameters + +| Parameter | Type | Description | +| :--- | :--- | :--- | +|**`ctx`**|`struct mg_context *`|The context on which the handler must be set| +|**`uri`**|`const char *`|The URI for the authorization handler| +|**`handler`**|`mg_authorization_handler`|Callback function doing the actual authorization| +|**`cbdata`**|`void *`|Optional user data| + +`int mg_authorization_handler( struct mg_connection *conn, void *cbdata );` + +### Return Value + +*none* + +### Description + +The function `mg_set_auth_handler()` hooks an authorization function to an URI to check if a user is authorized to visit that URI. The check is performed by a callback function of type `mg_authorization_handler`. The callback function is passed two parameters: the current connection and a pointer to optional user defined data which was passed to `mg_set_auth_handler()` when the callback was hooked to the URI. + +The callback function can return **0** to deny access, and **1** to allow access. + +The `mg_set_auth_handler()` function is very similar in use to [`mg_set_request_handler()`](mg_set_request_handler.md). + +### See Also + +* [`mg_set_request_handler();`](mg_set_request_handler.md) -- cgit v1.2.3