Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

casbin-knex-adapter

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casbin-knex-adapter - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

dist/index.d.ts

58

package.json
{
"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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc