How to use the acl.allow function in acl

To help you get started, we’ve selected a few acl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cheneyweb / x-koa / src / auth / xauth_router.js View on Github external
// 路由相关
const Router = require('koa-router')
// 日志相关
const log = require('tracer').colorConsole({ level: require('config').get('log').level })
// 初始化路由
const router = new Router()
// 认证相关
const passport = require(__dirname + '/passport_config.js')

// 角色权限
let acl = require('acl')
acl = new acl(new acl.memoryBackend())
acl.allow('admin', 'xbatis', 'remove')

/**
 * 认证登录
 */
router.post('/xauth/login', function (ctx, next) {
    return passport.authenticate('local', function (err, user, info, status) {
        if (user) {
            ctx.body = 'Y'
            acl.addUserRoles(user.id, 'admin')// 添加用户与其角色,这里模拟使用admin
            return ctx.login(user)
        } else {
            ctx.body = info
        }
    })(ctx, next)
})
github ratneshsinghparihar / Node-Data / core / initialize / initialize.ts View on Github external
resource.acl.forEach(access => {
                var aclString: Array = this.aclStringFromMask(access["accessmask"]);
                acl.allow(access["role"], resource["name"], aclString, function (err, res) {
                    if (res) {
                        console.log("User joed is allowed to view blogs")
                    }
                    if (err) {
                        //console.log("error in acl " + err);
                    }
                })
            });
github IBM-Cloud / collaboration / server / authorization.js View on Github external
acl.addUserRoles(req.user['id'], ['admin', documentEditorRole], function(err) {       
                if (err) {        
                  res.write('Error: User ' + req.user['id'] + ' not added as admin');
                  res.end(); 
                }
                else {
                  acl.allow(['admin', documentEditorRole], newDocumentId, 'update');
                  res.write('Success: User ' + req.user['id'] + ' added as admin');
                  res.end();  
                }
              });              
            }
github IBM-Cloud / collaboration / server / authorization.js View on Github external
mongodbUtils.getDatabase(function(err, database) {
        if (database) {
          acl = new acl(new acl.mongodbBackend(database, "acl"));

          acl.allow(['admin','user'], 'persons', 'view');

          callback(null, acl);
        }
        else {
          callback('Error: Cannot access ACL database', null);
        }        
      });

acl

An Access Control List module, based on Redis with Express middleware support

Unknown
Latest version published 7 years ago

Package Health Score

41 / 100
Full package analysis

Popular acl functions