]> git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/docs/api/mg_set_auth_handler.md
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / civetweb / docs / api / mg_set_auth_handler.md
1 # Civetweb API Reference
2
3 ### `mg_set_auth_handler( ctx, uri, handler, cbdata );`
4
5 ### Parameters
6
7 | Parameter | Type | Description |
8 | :--- | :--- | :--- |
9 |**`ctx`**|`struct mg_context *`|The context on which the handler must be set|
10 |**`uri`**|`const char *`|The URI for the authorization handler|
11 |**`handler`**|`mg_authorization_handler`|Callback function doing the actual authorization|
12 |**`cbdata`**|`void *`|Optional user data|
13
14 `int mg_authorization_handler( struct mg_connection *conn, void *cbdata );`
15
16 ### Return Value
17
18 *none*
19
20 ### Description
21
22 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.
23
24 The callback function can return **0** to deny access, and **1** to allow access.
25
26 The `mg_set_auth_handler()` function is very similar in use to [`mg_set_request_handler()`](mg_set_request_handler.md).
27
28 ### See Also
29
30 * [`mg_set_request_handler();`](mg_set_request_handler.md)