Git Product home page Git Product logo

egg-authz's People

Contributors

hsluoyz avatar nodece avatar selflocking avatar snowliy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

egg-authz's Issues

nodejs.Error: unsupported effect at DefaultEffector.mergeEffects

2018-12-26 20:17:45,370 ERROR 6724 [-/127.0.0.1/-/11ms GET /dataset1/resource1] nodejs.Error: unsupported effect
at DefaultEffector.mergeEffects (D:\workspace\egg\casbin-example\node_modules\casbin\lib\effect\defaultEffector.js:52:19)
at Enforcer.enforce (D:\workspace\egg\casbin-example\node_modules\casbin\lib\coreEnforcer.js:355:30)
at BasicAuthorizer.checkPermission (D:\workspace\egg\casbin-example\node_modules\koa-authz\BasicAuthorizer.js:37:21)
at D:\workspace\egg\casbin-example\node_modules\koa-authz\authz.js:31:24

My node version v10.1.0 and use command npm run test-local arises the issue

How to fix it? Thank you for reading!

Invalid enforcer

2019-06-02 09:05:24,948 ERROR 5104 [-/::1/-/1368ms GET /] nodejs.Error: Invalid enforcer
    at D:\1file\tlgtc\tlgc-api-server\node_modules\koa-authz\authz.js:25:15

pid: 5104
hostname: DESKTOP-QKBMCV7

I see the koa-authz\authz.js
image

then I console it in egg, it is true
image

Confused in test cases

For example:

 it('test: p, bob, /dataset2/resource1, * - DELETE', async () => {
    app.mockCsrf()
    const response = await app.httpRequest()
      .delete('/dataset2/resource')
      .set('Authorization', 'bob')
    assert(response.status === 403)
  })

test /dataset2/resource1, however request /dataset2/resource

Enforcer.newEnforcer is not a function

'use strict';
const { Enforcer } = require('casbin')
const {SequelizeAdapter} = require('casbin-sequelize-adapter')

module.exports = appInfo => {
  const config = exports = {};
  // add your config here
  config.middleware = ['authz', 'errorHandler', 'notfoundHandler']

  // casbin 权限管理配置
  config.authz = {
    enable: true,
    newEnforcer: async () => {
      // 配置权限数据库适配器
      console.log(Enforcer)
      const connect = await SequelizeAdapter.newAdapter(`mysql://${process.env.DB_USER || 'root'}:${process.env.DB_PASSWORD || 'root'}@${process.env.DB_HOST || 'localhost'}:${process.env.DB_PORT || '3306'}/`)
      const enforcer = await Enforcer.newEnforcer('zzes_model.conf', connect)
      return enforcer
    }
  }
}

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.