Socket
Book a DemoInstallSign in
Socket

shimo-rbac

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shimo-rbac

role base access control

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

usage

  const rbac = new RBAC(roles, options);

  // 访问路由时检查权限
  // allow: result = null
  // deny: result = [deny reason]
  const result = rbac.check({
    roles: 'admin'  // roleId or array of roleId,
    target: 'get /admin', // route
  });

  // 更新数据时检查权限
  // allow: result = null
  // deny: result = [deny reason]
  const result = rbac.check({
    roles: 'admin'  // roleId or array of roleId,
    target: 'team', // model name
    source: {       // data to update
      balance: 999,
    }
  });

roles

  • name {String}
  • merge {Enum: force | merge} 多个 role 如何合并权限, force 独占, merge 合并
  • weight {Number} 合并权限时的权重
  • desc {String}
namemergeweight
adminforce1
bannedforce2
freemerge999999
vipmerge10
alphamerge0

permissions

  • target {String}
  • action {Enum: deny(0) | read(1) | write(2) | readwrite(3)}
roletargetaction
adminteam.balance3
guestget /1
guestget /desktop0
freeget /desktop1
freeget /vip_feature0
vipget /vip_feature1
alphaget /alpha_feature1

列表中的权限默认为禁止 普通用户 free 付费用户 free vip 合并 禁止用户

FAQs

Package last updated on 30 Jun 2016

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.