From a1bf3bbdc364215dd10670e409674c09352a3ae6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:04:48 +0000 Subject: [PATCH 1/5] Initial plan From e9b588f65f0d107ce7fa77eb1fc57f061debf131 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:07:20 +0000 Subject: [PATCH 2/5] Re-write CI scripts and update README with all badges Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com> --- .github/workflows/ci.yml | 41 +++++++++++++++++++++++++++++++++++ .github/workflows/default.yml | 17 --------------- README.md | 20 ++++++++--------- package.json | 4 +++- 4 files changed, 53 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/default.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..45740e3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2.1.5 + + - name: Install Dependency + run: yarn install + + - name: Run Lint + run: yarn run lint + + - name: Run Fix + run: yarn run fix + + test: + needs: [lint] + runs-on: ubuntu-latest + strategy: + matrix: + node: [^18, ^20] + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + + - name: Install Dependency + run: yarn install + + - name: Run Unit test + run: yarn run test diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml deleted file mode 100644 index 66f3e6a..0000000 --- a/.github/workflows/default.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Default - -on: - push: - branches: - - master - pull_request: - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install Dependencies - run: yarn install - - name: Run test - run: yarn test diff --git a/README.md b/README.md index 6644b74..debbb24 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,24 @@ -# session-role-manager +# Session Role Manager +[![CI](https://github.com/node-casbin/session-role-manager/actions/workflows/ci.yml/badge.svg)](https://github.com/node-casbin/session-role-manager/actions/workflows/ci.yml) [![NPM version][npm-image]][npm-url] [![NPM download][download-image]][download-url] -[![Release](https://img.shields.io/github/release/node-casbin/session-role-manager.svg)](https://github.com/node-casbin/session-role-manager/releases) +[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN) [npm-image]: https://img.shields.io/npm/v/session-role-manager.svg?style=flat-square -[npm-url]: https://npmjs.org/package/session-role-manager +[npm-url]: https://npmjs.com/package/session-role-manager [download-image]: https://img.shields.io/npm/dm/session-role-manager.svg?style=flat-square -[download-url]: https://npmjs.org/package/session-role-manager +[download-url]: https://npmjs.com/package/session-role-manager -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. +Session Role Manager is the Session-based role manager for [Node-Casbin](https://github.com/casbin/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 -```shell script -# Yarn -yarn add session-role-manager -# NPM -npm install session-role-manager --save +``` +npm install session-role-manager ``` -## Example +## Simple Example ```typescript import { newEnforcer } from 'casbin'; diff --git a/package.json b/package.json index 240fcd8..296194d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "prepack": "yarn test && yarn build", "postpack": "rimraf lib", "build": "rimraf lib && tsc", - "test": "jest" + "test": "jest", + "lint": "prettier --check .", + "fix": "prettier --write ." }, "files": [ "examples", From f9d9c6dede2f25877b06b8eb5750f5eafa50eaae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:08:18 +0000 Subject: [PATCH 3/5] Fix CI workflow issues based on code review feedback Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com> --- .github/workflows/ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45740e3..a0543d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v2 - name: Set up Node.js - uses: actions/setup-node@v2.1.5 + uses: actions/setup-node@v3 - name: Install Dependency run: yarn install @@ -17,15 +17,12 @@ jobs: - name: Run Lint run: yarn run lint - - name: Run Fix - run: yarn run fix - test: needs: [lint] runs-on: ubuntu-latest strategy: matrix: - node: [^18, ^20] + node: ['18', '20'] steps: - uses: actions/checkout@v2 From c98fe95657405137c941976efeffc1291398b949 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:10:06 +0000 Subject: [PATCH 4/5] Add workflow permissions to fix security issue Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com> --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0543d1..1804ab6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,9 @@ name: CI on: [push, pull_request] +permissions: + contents: read + jobs: lint: runs-on: ubuntu-latest From ab6b0b20839cb69324cadc28ca81416b22341a0f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:32:50 +0000 Subject: [PATCH 5/5] Fix test failures: add missing RoleManager methods and fix Jest module resolution Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com> --- jest.config.js | 3 +++ src/roleManager.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/jest.config.js b/jest.config.js index 095740e..9e77df5 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,4 +4,7 @@ module.exports = { '^.+\\.(ts|tsx)$': 'ts-jest', }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'], + moduleNameMapper: { + '^csv-parse/sync$': '/node_modules/csv-parse/dist/cjs/sync.cjs', + }, }; diff --git a/src/roleManager.ts b/src/roleManager.ts index feb7209..18953a6 100644 --- a/src/roleManager.ts +++ b/src/roleManager.ts @@ -125,4 +125,16 @@ export class SessionRoleManager implements RoleManager { logPrint(item.toString()); } } + + // getDomains gets domains that a user has. + public async getDomains(name: string): Promise { + // This role manager does not support domains. + return []; + } + + // getAllDomains gets all domains. + public async getAllDomains(): Promise { + // This role manager does not support domains. + return []; + } }