diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/civetweb/docs/api/mg_set_auth_handler.md | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/civetweb/docs/api/mg_set_auth_handler.md')
-rw-r--r-- | src/civetweb/docs/api/mg_set_auth_handler.md | 30 |
1 files changed, 30 insertions, 0 deletions
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) |