Skip to content

Commit 4efa2e5

Browse files
committed
Fix casbin version
1 parent 283e846 commit 4efa2e5

File tree

6 files changed

+4643
-15
lines changed

6 files changed

+4643
-15
lines changed

.gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,4 @@ typings/
6161
.next
6262

6363
.idea/
64-
*.iml
65-
66-
package-lock.json
67-
yarn.lock
64+
*.iml

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Koa-Authz is an authorization middleware for [Koa](https://github.com/koajs/koa)
1717
## Installation
1818

1919
```shell
20-
npm install --save koa-authz
20+
npm install casbin koa-authz --save
2121
```
2222

2323
## Simple Example
2424

2525
```js
26-
const { Enforcer } = require('casbin')
26+
const casbin = require('casbin')
2727
const Koa = require('koa')
2828
const app = new Koa()
2929
const authz = require('koa-authz')
@@ -39,7 +39,7 @@ app.use(async (ctx, next) => {
3939
app.use(authz({
4040
newEnforcer: async() => {
4141
// load the casbin model and policy from files, database is also supported.
42-
const enforcer = await Enforcer.newEnforcer('authz_model.conf', 'authz_policy.csv')
42+
const enforcer = await casbin.newEnforcer('authz_model.conf', 'authz_policy.csv')
4343
return enforcer
4444
}
4545
}))
@@ -74,7 +74,7 @@ class MyAuthorizer extends BasicAuthorizer {
7474
app.use(authz({
7575
newEnforcer: async () => {
7676
// load the casbin model and policy from files, database is also supported.
77-
const enforcer = await Enforcer.newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv')
77+
const enforcer = await casbin.newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv')
7878
return enforcer
7979
},
8080
authorizer: (ctx, option) => new MyAuthorizer(ctx, option)

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333
"url": "https://github.com/node-casbin/koa-authz/issues"
3434
},
3535
"homepage": "https://github.com/node-casbin/koa-authz#readme",
36-
"dependencies": {
37-
"casbin": "^1.0.7"
38-
},
36+
"dependencies": {},
3937
"devDependencies": {
38+
"casbin": "^2.0.3",
4039
"eslint": "^5.4.0",
4140
"eslint-config-standard": "^11.0.0",
4241
"eslint-plugin-import": "^2.14.0",
@@ -47,5 +46,8 @@
4746
"jest": "^23.5.0",
4847
"koa": "^2.5.2",
4948
"supertest": "^3.1.0"
49+
},
50+
"peerDependencies": {
51+
"casbin": "^2.0.3"
5052
}
5153
}

test/customizeServer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
const Koa = require('koa')
16-
const { Enforcer } = require('casbin')
16+
const casbin = require('casbin')
1717
const authz = require('../authz')
1818
const app = new Koa()
1919
const BasicAuthorizer = require('../BasicAuthorizer')
@@ -48,7 +48,7 @@ class CustomizeAuthorizer extends BasicAuthorizer {
4848
app.use(authz({
4949
newEnforcer: async () => {
5050
// load the casbin model and policy from files, database is also supported.
51-
const enforcer = await Enforcer.newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv')
51+
const enforcer = await casbin.newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv')
5252
return enforcer
5353
},
5454
authorizer: (ctx, option) => new CustomizeAuthorizer(ctx, option)

test/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
const Koa = require('koa')
16-
const { Enforcer } = require('casbin')
16+
const casbin = require('casbin')
1717
const authz = require('../authz')
1818

1919
const app = new Koa()
@@ -33,7 +33,7 @@ app.use(async (ctx, next) => {
3333
app.use(authz({
3434
newEnforcer: async () => {
3535
// load the casbin model and policy from files, database is also supported.
36-
const enforcer = await Enforcer.newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv')
36+
const enforcer = await casbin.newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv')
3737
return enforcer
3838
}
3939
}))

0 commit comments

Comments
 (0)