Session based role manager for node-casbin

Clone this repo:
  1. c4aa4ff chore(release): 0.1.0 [skip ci] by semantic-release-bot · 3 months ago master v0.1.0
  2. 2464c1a feat: add CI semantic-release for npm and GitHub (#6) by Yang Luo · 3 months ago
  3. 3a63d70 feat: modernize CI workflow and README, fix the code by Yang Luo · 3 months ago
  4. 37a9d72 Merge branch 'master' of https://github.com/node-casbin/session-role-manager by DivyPatel9881 · 6 years ago
  5. 3d995de fix: Changed string to Date for SessionRole time. by DivyPatel9881 · 6 years ago

Session Role Manager

CI NPM version NPM download Discord

Session Role Manager is the Session-based role manager for Node-Casbin. With this library, Node-Casbin can load session-based role hierarchy (user-role mapping) from Casbin policy or save role hierarchy to it. The session is only active in the specified time range.

Installation

npm install session-role-manager

Simple Example

import { newEnforcer } from 'casbin';
import { SessionRoleManager } from 'session-role-manager';

async function app() {
  const e = await newEnforcer('examples/rbac_model_with_sessions.conf', 'examples/rbac_policy_with_sessions.csv');

  // Use our role manager.
  const rm = new SessionRoleManager(10);
  e.setRoleManager(rm);
  await e.buildRoleLinks();
}

app();