Home

Awesome

Apache APISIX Plugin Authorization OpenFGA for FGA

This directory contains a plugin to integrate OpenFGA with Apache APISIX to perform API authorization based Relationship-Based Access Control (ReBAC).
Refer to the FGA-based Zanzibar Platform for more information on OpenFGA.

This plugin will:

a. Identifies the user based on the access token received, which means that the API is using OAuth 2.0 as one of the authorization protocols.

b. Checks whether the user meets the defined relationship criteria with the object by invoking the authorization check endpoint — if a single authorization check is required — or the authorization batch check — if multiple authorization checks are needed — provided by the OpenFGA platform. Based on the result:

It also supports the discovery of the Store and Authorization model in the OpenFGA Platform if those attributes are not specified in the plugin configuration.

Configuration

Attributes

NameTypeRequiredDefaultDescription
hoststringTrueOpenFGA Base URL
store_idstringFalse(*) DiscoveryOpenFGA Store ID
authorization_model_idstringFalse(*) DiscoveryOpenFGA Authz Model ID
ssl_verifybooleanFalseFalseVerify SSL certificate
timeoutintegerFalse3000Timeout in milliseconds (min: 1, max: 60000)
keepalivebooleanFalseFalseEnable keepalive for connections
keepalive_timeoutintegerFalse60000Keepalive timeout in milliseconds (min: 1000)
keepalive_poolintegerFalse5Keepalive pool size (min: 1)
checkobjectTrueCheck configuration for authorization

check Attributes

NameTypeRequiredDefaultDescription
conditionstringTrueANDCondition type: AND or OR
tuplesarrayTrueList of authorization tuples

tuples Object Attributes

NameTypeRequiredDefaultDescription
user_idstringTrueUser ID (Format claim::{claim-name})
user_typestringFalseuserUser Type
relationstringFalseassigneeRelation of the user to the object
object_typestringTrueroleType of the object, e.g., role
object_idstringTrueID of the object

(*) Discovery: The plugin performs discovery to obtain the store and authorization ID based on the defined OpenFGA Platform.

Installation

git clone https://github.com/embesozzi/apisix-authz-openfga
cd apisix-authz-openfga
cp apisix/plugins/authz-openfga.lua /usr/local/apisix/lua/apisix/plugins

Modify configuration, add plugins

Modify the configuration file /usr/local/apisix/conf/config.yaml and add it authz-openfga to plugins.

   - authz-openfga

And also enable the plugin cache:

nginx_config:
    http_configuration_snippet: |
    ...

    # authz-openfga  plugin
    lua_shared_dict authz_openfga_authorization_model             1m; # cache for discovery metadata documents

Use Cases

The use cases are explaing in the following medium article:

Other edition of the Plugin

For more features, check the Enterprise Edition maintained by TwoGenIdentity