chore(release): 1.0.0 [skip ci]

# 1.0.0 (2023-08-16)

### Bug Fixes

* readme typos and grammar. ([7d2153e](https://github.com/node-casbin/basic-adapter/commit/7d2153e8ed69cb3e490ebfec1fed1d6941763b94))
* Update dependencies to resolve knex security vulnerabilities. ([#27](https://github.com/node-casbin/basic-adapter/issues/27)) ([5cc15ec](https://github.com/node-casbin/basic-adapter/commit/5cc15ec40efc2d21a4c6e076aa57efd51e0490c7))

### Features

* support mssql ([#12](https://github.com/node-casbin/basic-adapter/issues/12)) ([c36b535](https://github.com/node-casbin/basic-adapter/commit/c36b535c8189741569179da26c1f67000330a51b))
* support oracledb ([#13](https://github.com/node-casbin/basic-adapter/issues/13)) ([9a4443b](https://github.com/node-casbin/basic-adapter/commit/9a4443b61562a7cd1c264c4e55cf4dc86ecbc8d5))

### Reverts

* Revert "add oracledb tests (#14)" (#17) ([c5690af](https://github.com/node-casbin/basic-adapter/commit/c5690afa9060af7edbe4c52067f98ad994110cc1)), closes [#14](https://github.com/node-casbin/basic-adapter/issues/14) [#17](https://github.com/node-casbin/basic-adapter/issues/17)
* Revert "feat: support oracledb (#13)" (#16) ([300f56e](https://github.com/node-casbin/basic-adapter/commit/300f56e113bf4ccdd1c5acd387600d84b57acd42)), closes [#13](https://github.com/node-casbin/basic-adapter/issues/13) [#16](https://github.com/node-casbin/basic-adapter/issues/16)
1 file changed
tree: 75ed63d076ed7e2972cb7bb5b6393f4a46531483
  1. .github/
  2. examples/
  3. src/
  4. test/
  5. .eslintrc
  6. .gitattributes
  7. .gitignore
  8. .prettierrc
  9. .releaserc
  10. LICENSE
  11. package-lock.json
  12. package.json
  13. README.md
  14. tsconfig.json
README.md

Basic Adapter

ci NPM version NPM download

Basic Adapter is a basic driver adapter for Node-Casbin which supports pg, sqlite3, mysql, mysql2, and mssql. With this library, Node-Casbin can load policy from or save policy to supported persistence systems.

Drives

We currently support the following SQL systems:

  • [x] pg
  • [x] mysql
  • [x] mysql2
  • [x] sqlite3
  • [ ] oracledb
  • [x] mssql

Installation

npm i casbin-basic-adapter

Simple Example

import { newEnforcer } from 'casbin';
import { Client } from 'pg';
import { BasicAdapter } from 'casbin-basic-adapter';

async function myFunction() {
  // Initialize a Basic adapter and use it in a Node-Casbin enforcer:
  // The adapter can not automatically create database.
  // But the adapter will automatically and use the table named "casbin_rule".
  const a = await BasicAdapter.newAdapter('pg',
    new Client({
      user: 'postgres',
      database: 'postgres',
      password: 'postgres',
    }));

  const e = await newEnforcer('examples/rbac_model.conf', a);

  // Check the permission.
  e.enforce('alice', 'data1', 'read');

  // Modify the policy.
  // await e.addPolicy(...);
  // await e.removePolicy(...);

  // Save the policy back to DB.
  await e.savePolicy();

Getting Help

License

This project is under Apache 2.0 License. See the LICENSE file for the full license text.