Skip to content

Latest commit

 

History

History
83 lines (53 loc) · 4.01 KB

role-based-access-control-rbac.md

File metadata and controls

83 lines (53 loc) · 4.01 KB
description
This page provides the technical details of the RBAC policy

Role-based Access Control (RBAC)

{% hint style="warning" %} This feature requires Gravitee's Enterprise Edition. {% endhint %}

Overview

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 roles are checked against request attribute gravitee.attribute.user.roles. 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

Functional and implementation information for the role-based-access-control policy is organized into the following sections:

Examples

{% hint style="warning" %} This policy can be applied to v2 APIs and v4 HTTP proxy APIs. It cannot be applied to v4 message APIs or v4 TCP proxy APIs. {% endhint %}

{% tabs %} {% tab title="HTTP proxy API example" %} Sample policy configuration:

{
  "rbac": {
    "roles": ["read", "write", "admin"],
    "strict": true
  }
}

{% endtab %} {% endtabs %}

Configuration

Phases

The phases checked below are supported by the role-based-access-control policy:

v2 PhasesCompatible?v4 PhasesCompatible?
onRequesttrueonRequesttrue
onResponsefalseonResponsefalse
onRequestContentfalseonMessageRequestfalse
onResponseContentfalseonMessageResponsefalse

Options

The role-based-access-control policy can be configured with the following options:

PropertyRequiredDescriptionTypeDefault
rolestrueThe list of required rolesArray of strings
stricttrueValidation mode — strict or not (must or should)booleantrue

Compatibility matrix

The following is the compatibility matrix for APIM and the role-based-access-control policy:

Plugin version Supported APIM versions
1.x All

Errors

HTTP status codeMessage
400* The roles associated with the request are not valid
403

* 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).

The error keys sent by this policy are as follows:

KeyParameters
RBAC_NO_USER_ROLE (403)-
RBAC_INVALID_USER_ROLES (400)-
RBAC_FORBIDDEN (403)-

Changelogs

{% @github-files/github-code-block url="https://github.com/gravitee-io/gravitee-policy-role-based-access-control/blob/master/CHANGELOG.md" %}