Redis adapter for Casbin

Clone this repo:
  1. ac90a57 chore(release): 1.0.4 [skip ci] by semantic-release-bot · 3 years ago master v1.0.4
  2. 15e9f7c fix: fix CI by Yang Luo · 3 years ago
  3. c9b4569 fix: Pass redisOpts argument to constructor (#12) by Tan Khay Ong · 3 years ago
  4. 8542e9b chore(release): 1.0.3 [skip ci] by semantic-release-bot · 3 years, 7 months ago v1.0.3
  5. 76b7c62 Merge pull request #11 from Nawbc/master by Zxilly · 3 years, 7 months ago

casbin-redis-adapter

NPM version NPM download CI Coverage Status Gitter

Redis policy storage, implemented as an adapter for node-casbin.

Installation

npm install --save casbin-redis-adapter
// or
yarn add casbin-redis-adapter

Usage

Require it in a place, where you are instantiating an enforcer (read more about enforcer here):


import {newEnforcer} from 'casbin'; import {NodeRedisAdapter} from './adapter' ; import {join} from 'path'; const model = join(__dirname, 'casbin_conf/model.conf'); const adapter = await NodeRedisAdapter.newAdapter({host: "127.0.0.1", port: 6379}); const enforcer = await newEnforcer(model, adapter);

That is all what required for integrating the adapter into casbin.

Configuration

NodeRedisAdapter.newAdapter() takes the following parameters as an object to establish the connection with redis-server

options: interface IConnectionOptions {
    host: string // IP address of the Redis server
    port: number //	Port of the Redis server
}

redisOpts ? : redis.ClientOpts //https://github.com/NodeRedis/node-redis#options-object-properties

License

Apache-2.0