feat: modernize CI workflow and README, fix the code
6 files changed
tree: 563837e2c9e036ae476ee5504c1b1190cdd6010b
  1. .github/
  2. examples/
  3. src/
  4. test/
  5. .gitignore
  6. .prettierrc
  7. jest.config.js
  8. LICENSE
  9. package.json
  10. README.md
  11. tsconfig.json
README.md

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();