flash-oss / node_acl

Access control lists for node applications
MIT License
63 stars 9 forks source link

Get resources and permissions grouped by role #3

Closed sujeet-agrahari closed 3 years ago

sujeet-agrahari commented 3 years ago

I have gone through the packages and I couldn't find any appropriate method for listing roles, resources and their permissions on it.

/**
  whatResources(role, function(err, {resourceName: [permissions]})

  Returns what resources a given role or roles have permissions over.

  whatResources(role, permissions, function(err, resources) )

  Returns what resources a role has the given permissions over, even I pass roles as an array.

  @param {String|Array} Roles
  @param {String|Array} Permissions
  @param {Function} Callback called wish the result.
*/

It return data like below,

{
  resource: [permissions]
}

But it doesn't return what role has what permissions. I want something like below,

[{
  role: 'super-admin',
  resourcePermissions: [
    {
      resource: 'orders',
      permissions: ['get', 'put']
    },
    {
     resource: 'payments',
     permissions: ['get', 'delete']
  ]
},
....
]
koresar commented 3 years ago

Oh, I believe many would want the same.

Could you please implement it? We love pull requests!