New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

egg-role

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-role

role control of eggjs

latest
Source
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

egg-role

role control plugin for eggjs.

Build Status codecov

Feature:

  • All access controls are based on configuration.
  • According to the application's own ctx.getRoles function to get the current user's role, the plugin itself does not provide the role management function.
  • Can control access to router, service, etc.
  • Custom access error information based on egg-i18n.

Configuration:

exports.role = {
  get: 'getRoles', // this is default value, we will fetch user roles by 'ctx.getRoles';
  policy: {
    'user_admin': [ // role is 'user_admin'
      'router:updateUser', // the role can access router which name is 'updateUser'
      'service:user.listUsers' // the role can access service which name is 'user.listUsers' ignoring what the router is.
    ],
    'comment_inspector': [
      'router:denyComment',
      'router:stickComment',
      'service:comment.listComments'
    ]
  }
};

JSON format policy Example

exports.role = {
  policy: path.join(__dirname, 'policy.json');
};

yaml format policy Example

exports.role = {
  policy: path.join(__dirname, 'policy.yaml');
};

Default Configuration

Before commit your code:

cp pre-commit .git/hooks/

Keywords

role

FAQs

Package last updated on 05 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts