You can use the role-based-access-control
policy (RBAC policy) to control access to a resource by specifying the required roles to access it.
The policy can be configured to either:
-
allow only incoming requests with roles exactly matching the configured roles (strict mode)
-
allow incoming requests with at least one role matching the configured roles
The roles are checked against request attribute gravitee.attribute.user.roles
.
Property | Required | Description | Type | Default |
---|---|---|---|---|
roles |
X |
The list of required roles |
Array of strings |
|
strict |
X |
Validation mode — strict or not (must or should) |
boolean |
true |
{
"rbac": {
"roles": ["read", "write", "admin"],
"strict": true
}
}
Code | Message |
---|---|
|
Applies if: * The roles associated with the request are not valid |
|
Applies if: * No roles are associated with the current request * Role(s) associated with the request do not match required role(s) |
You can use the response template feature to override the default responses provided by the policy. These templates must be defined at the API level (see the API Console Response Templates option in the API Proxy menu).