DeadAlready / easy-rbac

RBAC implementation for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support wildcard operations

jeremygiberson opened this issue · comments

Hi @DeadAlready, first thanks for contributing this library to the OSC!

I was wondering what your disposition is to adding support to wildcard '*' in role initialization.

Some cases worth considering:

Admin
The admin role can do anything -- maybe this is the super user, maybe this is a system operation. But rather than configuring by hand every single operation -- wildcard resource and wildcard action would be a great catch all.

{
 admin: {
    can: ['*:*']
  }
}

Resource Manager
A role that has total responsibility over some resource - maybe articles for the news page, or comments from blog, etc.

{
 editor: {
    can: ['article:*']
  }
}

Moderator
A role that has specific responsibilities over multiple resources - like flagging posts or comments as inappropriate.

{
 moderator: {
    can: ['*:flag']
  }
}

Using wildcard for resources and actions we can provide catchall's that can be reasonably expected to keep working with the addition of new resources or actions on resources without having to update all existing role configurations with new permission.

Sounds like it would be a decent addition to the library.

I'll see if I can find time this week to code it up.

v3.1 released which supports the * wildcard.