diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1804ab6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v3 + + - name: Install Dependency + run: yarn install + + - name: Run Lint + run: yarn run lint + + 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/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/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", 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 []; + } }