All Projects → knex → casbin-knex-adapter

knex / casbin-knex-adapter

Licence: Apache-2.0 license
Knex adapter for Casbin

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to casbin-knex-adapter

express-authz
express-authz is an authorization middleware for Express.js based on Casbin
Stars: ✭ 60 (+275%)
Mutual labels:  authorization, casbin
Etcd Watcher
Etcd watcher for Casbin
Stars: ✭ 157 (+881.25%)
Mutual labels:  authorization, casbin
Negroni Authz
negroni-authz is an authorization middleware for Negroni
Stars: ✭ 152 (+850%)
Mutual labels:  authorization, casbin
Casbin Cpp
An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++
Stars: ✭ 113 (+606.25%)
Mutual labels:  authorization, casbin
Mongodb Adapter
MongoDB adapter for Casbin
Stars: ✭ 194 (+1112.5%)
Mutual labels:  authorization, casbin
Node Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser
Stars: ✭ 1,757 (+10881.25%)
Mutual labels:  authorization, casbin
Chi Authz
chi-authz is an authorization middleware for Chi
Stars: ✭ 248 (+1450%)
Mutual labels:  authorization, casbin
Casbin Editor
Web-based model & policy editor for Casbin
Stars: ✭ 45 (+181.25%)
Mutual labels:  authorization, casbin
Protobuf Adapter
Google Protocol Buffers adapter for Casbin
Stars: ✭ 185 (+1056.25%)
Mutual labels:  authorization, casbin
Casbin Server
Casbin as a Service (CaaS)
Stars: ✭ 171 (+968.75%)
Mutual labels:  authorization, casbin
Jcasbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Java
Stars: ✭ 1,335 (+8243.75%)
Mutual labels:  authorization, casbin
Beego Authz
Beego's RBAC & ABAC Authorization middleware based on Casbin
Stars: ✭ 208 (+1200%)
Mutual labels:  authorization, casbin
Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang
Stars: ✭ 10,872 (+67850%)
Mutual labels:  authorization, casbin
Laravel Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.
Stars: ✭ 136 (+750%)
Mutual labels:  authorization, casbin
Egg Authz
egg-authz is an authorization middleware for Egg.js based on Casbin
Stars: ✭ 50 (+212.5%)
Mutual labels:  authorization, casbin
Think Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in ThinkPHP 6.0 .
Stars: ✭ 155 (+868.75%)
Mutual labels:  authorization, casbin
Pycasbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Python
Stars: ✭ 625 (+3806.25%)
Mutual labels:  authorization, casbin
Openstack Policy Editor
A Casbin Policy Editor for OpenStack
Stars: ✭ 28 (+75%)
Mutual labels:  authorization, casbin
Redis Adapter
Redis adapter for Casbin
Stars: ✭ 167 (+943.75%)
Mutual labels:  authorization, casbin
Casbin Authz Plugin
Docker Authorization Plugin based on Casbin
Stars: ✭ 204 (+1175%)
Mutual labels:  authorization, casbin

Knex Adapter

NPM Version Coverage Status

Knex Adapter for Node-Casbin. Use this library for policy storage in Casbin.

For full database support list, go to the Knex documentation.

Installation

npm install casbin-knex-adapter --save

or

yarn add casbin-knex-adapter

Example

const Knex = require('knex')
const casbin = require('casbin');
const KnexAdapter = require('casbin-knex-adapter');

(async function() {
  // Instantiate DB connection
  const knex = Knex(knexOptions)
  // Create adapter
  const adapter = await KnexAdapter.newAdapter({ knex });

  // Create casbin enforcer
  const enforcer = await casbin.newEnforcer('model.conf', adapter);

  // Load policy from DB
  await enforcer.loadPolicy();

  // Check permission
  if (await enforcer.enforce('user', 'resource', 'read')) {
    // Do something if user is authorized
  }

  // Modify policy
  // await enforcer.addPolicy(...)
  // await enforcer.removePolicy(...)
  // await adapter.removePolicyWhere({ 'v0': '00001' }) // needs to be reloaded from enforcer afterwards

  // Rewrite entire policy in DB
  await enforcer.savePolicy();
})();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].