How to use acl - 10 common examples

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 taobataoma / meanTorrent / modules / albums / server / policies / albums.server.policy.js View on Github external
'use strict';

/**
 * Module dependencies
 */
var acl = require('acl');

// Using the memory backend
acl = new acl(new acl.memoryBackend());

/**
 * Invoke Torrents Permissions
 */
exports.invokeRolesPolicies = function () {
  acl.allow(
    [
      {
        roles: ['admin', 'oper'],
        allows: [
          {resources: '/api/albums', permissions: '*'},
          {resources: '/api/albums/torrent/:torrentId', permissions: '*'},
          {resources: '/api/albums/:albumId', permissions: '*'},
          {resources: '/api/albums/:albumId/insert/:torrentId', permissions: '*'},
          {resources: '/api/albums/:albumId/remove/:torrentId', permissions: '*'},
          {resources: '/api/albums/:albumId/set/recommendlevel/:rlevel', permissions: '*'},
github taobataoma / meanTorrent / modules / backup / server / policies / backup.server.policy.js View on Github external
'use strict';

/**
 * Module dependencies
 */
var acl = require('acl');

// Using the memory backend
acl = new acl(new acl.memoryBackend());

/**
 * Invoke Torrents Permissions
 */
exports.invokeRolesPolicies = function () {
  acl.allow(
    [
      {
        roles: ['admin'],
        allows: [
          {resources: '/api/backup', permissions: '*'},
          {resources: '/api/backup/:filename', permissions: '*'}
        ]
      }
    ]
  );
github taobataoma / meanTorrent / modules / requests / server / policies / requests.server.policy.js View on Github external
'use strict';

/**
 * Module dependencies
 */
var acl = require('acl');

// Using the memory backend
acl = new acl(new acl.memoryBackend());

/**
 * Invoke Articles Permissions
 */
exports.invokeRolesPolicies = function () {
  acl.allow([{
    roles: ['oper', 'admin'],
    allows: [
      {resources: '/api/requests', permissions: '*'},
      {resources: '/api/requests/:requestId', permissions: '*'},
      {resources: '/api/requests/:requestId/accept/:torrentId', permissions: '*'},

      {resources: '/api/reqComments/:requestId', permissions: '*'},
      {resources: '/api/reqComments/:requestId/:commentId', permissions: '*'},
      {resources: '/api/reqComments/:requestId/:commentId/:subCommentId', permissions: '*'}
    ]
github taobataoma / meanTorrent / modules / about / server / policies / about.server.policy.js View on Github external
'use strict';

/**
 * Module dependencies
 */
var acl = require('acl');

// Using the memory backend
acl = new acl(new acl.memoryBackend());

/**
 * Invoke Articles Permissions
 */
exports.invokeRolesPolicies = function () {
  acl.allow([{
    roles: ['oper', 'admin'],
    allows: [
      {resources: '/api/makers', permissions: '*'},
      {resources: '/api/makers/create/:userId', permissions: '*'},
      {resources: '/api/makers/:makerId', permissions: '*'},
      {resources: '/api/makers/:makerId/rating', permissions: '*'},
      {resources: '/api/makers/:makerId/addMember/:username', permissions: '*'},
      {resources: '/api/makers/:makerId/removeMember/:username', permissions: '*'}
    ]
  }, {
github taobataoma / meanTorrent / modules / messages / server / policies / messages.server.policy.js View on Github external
'use strict';

/**
 * Module dependencies
 */
var acl = require('acl');

// Using the memory backend
acl = new acl(new acl.memoryBackend());

/**
 * Invoke Invitations Permissions
 */
exports.invokeRolesPolicies = function () {
  acl.allow(
    [
      {
        roles: ['admin', 'oper', 'user'],
        allows: [
          {resources: '/api/messages', permissions: '*'},
          {resources: '/api/messages/:messageId', permissions: '*'},
          {resources: '/api/messages/countUnread', permissions: '*'}
        ]
      },
      {
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);
        }        
      });
github dominiklessel / node-restify-boilerplate / plugins / customACLPlugin.js View on Github external
getACLInstance = function(aclBackend) {

  if (acl) {
    return acl;
  }

  aclBackend = aclBackend || { type: 'memory' };

  aclBackend = aclBackend.type === 'memory' ? new ACL.memoryBackend()
    : aclBackend.type === 'redis' ? aclBackend = new ACL.redisBackend(aclBackend.options.client, aclBackend.options.prefix)
    : aclBackend.type === 'mongodb' ? aclBackend = new ACL.mongodbBackend(aclBackend.options.client, aclBackend.options.prefix)
    : new ACL.memoryBackend();

  acl = new ACL(aclBackend);

  var rules = nconf.get('Security:ACL:Rules');
  var users = nconf.get('Security:Users');

  acl.allow(rules);

  users.forEach(function(user) {
    acl.addUserRoles(user.name, user.role);
  });

  return acl;

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