casbin-knex-adapter
Advanced tools
Comparing version 0.2.0 to 0.3.0
{ | ||
"name": "casbin-knex-adapter", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Knex adapter for Casbin", | ||
"main": "lib/adapter.js", | ||
"repository": "git@github.com:sarneeh/casbin-knex-adapter.git", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"repository": "git@github.com:knex/casbin-knex-adapter.git", | ||
"author": "Jakub Sarnowski <sarneeh@gmail.com>", | ||
"licenses": [ | ||
"contributors": [ | ||
{ | ||
"type": "Apache-2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0" | ||
"name": "Igor Savin", | ||
"email": "kibertoad@gmail.com" | ||
} | ||
], | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"build": "tsc", | ||
"db:start": "docker-compose -f scripts/docker-compose.yml up --build -d mysql postgres mssql && docker-compose -f scripts/docker-compose.yml up waitmssql waitmysql waitpostgres", | ||
"db:stop": "docker-compose -f scripts/docker-compose.yml down", | ||
"lint": "eslint --format codeframe \"lib/**/*.ts\" \"test/**/*.ts\"", | ||
"prettier": "prettier --write \"{lib,test}/**/*.{js,ts}\" index.ts", | ||
"test": "jest --runInBand", | ||
"test:coverage": "jest --config=jest.config.json --coverage", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"peerDependencies": { | ||
"knex": ">=0.16.5", | ||
"casbin": ">=2.0.4" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.13.0", | ||
"@typescript-eslint/parser": "^4.13.0", | ||
"@types/node": "^14.14.21", | ||
"@types/jest": "^26.0.20", | ||
"casbin": "^5.2.3", | ||
"eslint": "^7.18.0", | ||
"eslint-config-prettier": "^7.1.0", | ||
"eslint-plugin-prettier": "^3.3.0", | ||
"jest": "^26.6.3", | ||
"knex": "~0.21.15", | ||
"mssql": "^6.3.1", | ||
"mysql": "^2.18.1", | ||
"mysql2": "^2.2.5", | ||
"pg": "^8.5.1", | ||
"prettier": "^2.2.1", | ||
"sqlite3": "^5.0.1", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.3" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"dependencies": { | ||
"casbin": "^2.0.1", | ||
"knex": "^0.16.5" | ||
} | ||
"README.md", | ||
"LICENSE", | ||
"dist/*" | ||
] | ||
} |
# Knex Adapter | ||
[Knex](https://github.com/tgriesser/knex) Adapter for [Node-Casbin](). Use this library for [policy storage](https://casbin.org/docs/en/adapters) in Casbin. | ||
[![NPM Version][npm-image]][npm-url] | ||
![](https://github.com/knex/casbin-knex-adapter/workflows/ci/badge.svg) | ||
[![Coverage Status](https://coveralls.io/repos/knex/casbin-knex-adapter/badge.svg?branch=master)](https://coveralls.io/r/knex/casbin-knex-adapter?branch=master) | ||
[Knex](https://github.com/knex/knex) Adapter for [Node-Casbin](https://github.com/casbin/node-casbin). Use this library for [policy storage](https://casbin.org/docs/en/adapters) in Casbin. | ||
For full database support list, go to the Knex [documentation](https://knexjs.org/#Installation-node). | ||
**WARNING: This adapter has only been tested manually. It lacks automated tests, which will show up when I'll have time. If you want to use it in production - be careful.** | ||
## Installation | ||
@@ -20,2 +22,3 @@ | ||
```js | ||
const Knex = require('knex') | ||
const casbin = require('casbin'); | ||
@@ -25,6 +28,6 @@ const KnexAdapter = require('casbin-knex-adapter'); | ||
(async function() { | ||
// Instantiate DB connection | ||
const knex = Knex(knexOptions) | ||
// Create adapter | ||
const adapter = await KnexAdapter.newAdapter(knexOptions); | ||
// or pass a Knex instance | ||
// const adapter = await KnexAdapter.newAdapter(knexInstance); | ||
const adapter = await KnexAdapter.newAdapter(knex); | ||
@@ -38,4 +41,4 @@ // Create casbin enforcer | ||
// Check permission | ||
if (enforcer.eforce('user', 'resource', 'read')) { | ||
// Do something | ||
if (await enforcer.enforce('user', 'resource', 'read')) { | ||
// Do something if user is authorized | ||
} | ||
@@ -47,5 +50,8 @@ | ||
// Save policy to DB | ||
// Rewrite entire policy in DB | ||
await enforcer.savePolicy(); | ||
})(); | ||
``` | ||
[npm-image]: https://img.shields.io/npm/v/casbin-knex-adapter.svg | ||
[npm-url]: https://npmjs.org/package/casbin-knex-adapter |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
24793
9
148
54
18
2
+ Added@casbin/expression-eval@5.3.0(transitive)
+ Addedawait-lock@2.2.2(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedcasbin@5.36.0(transitive)
+ Addedcolorette@2.0.19(transitive)
+ Addedcommander@10.0.1(transitive)
+ Addedcsv-parse@5.6.0(transitive)
+ Addeddebug@4.3.4(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedesm@3.2.25(transitive)
+ Addedget-package-type@0.1.0(transitive)
+ Addedgetopts@2.3.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinterpret@2.2.0(transitive)
+ Addedknex@3.1.0(transitive)
+ Addedminimatch@7.4.6(transitive)
+ Addedms@2.1.2(transitive)
+ Addedpg-connection-string@2.6.2(transitive)
+ Addedrechoir@0.8.0(transitive)
+ Addedresolve-from@5.0.0(transitive)
+ Addedtarn@3.0.2(transitive)
+ Addedtildify@2.0.0(transitive)
- Removedcasbin@^2.0.1
- Removedknex@^0.16.5
- Removed@babel/polyfill@7.12.1(transitive)
- Removed@types/bluebird@3.5.42(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-each@1.0.1(transitive)
- Removedarray-slice@1.1.0(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedcasbin@2.0.4(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcolorette@1.0.7(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removedcore-js@2.6.12(transitive)
- Removeddebug@2.6.94.1.1(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removeddetect-file@1.0.0(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedexpand-tilde@2.0.2(transitive)
- Removedexpression-eval@1.4.0(transitive)
- Removedextend@3.0.2(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfindup-sync@3.0.0(transitive)
- Removedfined@1.2.0(transitive)
- Removedflagged-respawn@1.0.1(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfor-own@1.0.0(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedget-value@2.0.6(transitive)
- Removedgetopts@2.2.3(transitive)
- Removedglobal-modules@1.0.0(transitive)
- Removedglobal-prefix@1.0.2(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhomedir-polyfill@1.0.3(transitive)
- Removedinherits@2.0.4(transitive)
- Removedini@1.3.8(transitive)
- Removedinterpret@1.4.0(transitive)
- Removedip@1.1.9(transitive)
- Removedis-absolute@1.0.0(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-relative@1.0.0(transitive)
- Removedis-unc-path@1.0.0(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedknex@0.16.5(transitive)
- Removedliftoff@3.1.0(transitive)
- Removedmake-iterator@1.0.1(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.0.02.1.3(transitive)
- Removednanomatch@1.2.13(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.defaults@1.1.0(transitive)
- Removedobject.map@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedparse-filepath@1.0.2(transitive)
- Removedparse-passwd@1.0.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-root@0.1.1(transitive)
- Removedpath-root-regex@0.1.2(transitive)
- Removedpg-connection-string@2.0.0(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedrechoir@0.6.2(transitive)
- Removedregenerator-runtime@0.13.11(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-dir@1.0.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedtarn@1.1.5(transitive)
- Removedtildify@1.2.0(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunc-path-regex@0.1.2(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedv8flags@3.2.0(transitive)
- Removedwhich@1.3.1(transitive)