Git Product home page Git Product logo

embesozzi / apisix-authz-openfga Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 12 KB

APISIX plugin for integration with OpenFGA platform for FGA

Home Page: https://embesozzi.medium.com/mastering-access-control-implementing-low-code-authorization-based-on-rebac-and-decoupling-pattern-f6f54f70115e

License: Apache License 2.0

Lua 92.86% Dockerfile 7.14%
apisix apisix-plugin authorization fga openfga access-control oauth2

apisix-authz-openfga's Introduction

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 if the user has the defined relationship with the object invoking the authorization check endpoint that comes with the OpenFGA platform. Based on the result:

  • Authorizes access to the upstream service when the OpenFGA authorization checks evaluate successfully.
  • Responds with 403 Forbidden if the OpenFGA authorization checks fail.
  • Responds with a 500 Internal Server Error in case of an unexpected error.

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

Name Type Required Default Description
host string True OpenFGA Base URL
store_id string False (*) Discovery OpenFGA Store ID
authorization_model_id string False (*) Discovery OpenFGA Authz Model ID
user_type string False user OpenFGA User Authz Tuple
user_jwt_claim string False preferred_username JWT Claim Name
relation string False assignee OpenFGA Rel Authz Tuple
object_type string False role OpenFGA Obj Type Authz Tuple
object string True OpenFGA Obj Authz Tuple
ssl_verify string False False
timeout integer False 3000
keepalive boolean False False
keepalive_pool integer False 5

(*) 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 "Mastering Access Control: Implementing Low-Code Authorization Based on ReBAC and Decoupling Pattern":

Other edition of the Plugin

For more features, check the Enterprise Edition maintained by TwoGenIdentity

apisix-authz-openfga's People

Contributors

embesozzi avatar

Stargazers

Kevin Yang avatar Dominic avatar Raghd Hamzeh avatar Sam Samson avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.