|
Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
|
Authorization rules loaded from a parsed JSON object.
Each object member is a rule object with urls, methods and roles arrays. The rule member name is only a label. For example:
Exact paths are checked before prefix rules. A final slash-star selects a prefix; this is not a general wildcard matcher. An empty methods array matches all HTTP methods, and an empty roles array matches all roles. A user with no roles has special super-user access as defined by JUserCont. HTTP HEAD is checked as GET. Unmatched requests are denied.
The user database is borrowed and must outlive this object. Rule updates are not transactional: existing rules are removed before replacement is complete. Serialize configuration changes with requests using this object.
#include <JConstrCont.h>

Public Member Functions | |
| JConstrCont (JUserCont *userCont, AllocatorIntf *alloc=0) | |
| Initialize an empty rule container. More... | |
| ~JConstrCont () | |
| Release the stored rules; does not destroy userCont or its allocator. More... | |
| void | setConstraints (JVal *constraintsVal, JErr *err) |
| Replace rules from a parsed JSON object. More... | |
| void | setCaseInsensitive () |
| Make prefix-rule comparisons case-insensitive. More... | |
Public Member Functions inherited from AuthorizerIntf | |
| AuthorizerIntf (AuthorizerIntf_Authorize authorize) | |
| The constructor. More... | |
| bool | authorize (struct AuthenticatedUser *user, HttpMethod method, const char *path) |
| Returns TRUE if user is authorized. More... | |
| JConstrCont::JConstrCont | ( | JUserCont * | userCont, |
| AllocatorIntf * | alloc = 0 |
||
| ) |
Initialize an empty rule container.
| [in] | userCont | Required borrowed user database used to resolve roles. |
| [in] | alloc | Borrowed allocator, or NULL for the default allocator. Both must remain valid until this container is destroyed. |
| JConstrCont::~JConstrCont | ( | ) |
Release the stored rules; does not destroy userCont or its allocator.
Detach the authorizer and stop its users before destruction.
| void JConstrCont::setCaseInsensitive | ( | ) |
Make prefix-rule comparisons case-insensitive.
Call during setup when the backing filesystem ignores case. Exact-path hash lookups are unaffected by this flag in the current implementation; do not assume this method makes every constraint comparison case-insensitive.
Replace rules from a parsed JSON object.
| [in] | constraintsVal | Required JVal object with rule objects as members. Each rule requires urls (nonempty array of nonempty path strings), methods (array of HTTP method-name strings, or empty), and roles (array of role-name strings, or empty). Strings and role IDs are copied; the JVal tree can be released after this call. |
| [in,out] | err | Required initialized JErr. Reported format and allocation failures are stored here; the old rules are not restored and partial replacement rules can remain. No value is returned. |