accesscontrol icon indicating copy to clipboard operation
accesscontrol copied to clipboard

wilcard for user and resource

Open joneldiablo opened this issue 7 years ago • 4 comments

I want to do this:

let grantsObject = {
        '*': {
          '*': {
            'create:any': ['!*'],
            'read:any': ['!*'],
            'update:any': ['!*'],
            'delete:any': ['!*']
          }
        }
      };
//......... add more reading database
const ac = new AccessControl(grantsObject);

but I having this error: Unhandled rejection AccessControlError: Cannot use reserved name "*" for a resource.

so, is there any way to add a default permission for all users and all resources?

joneldiablo avatar Oct 25 '18 15:10 joneldiablo

In our case, we would like to grant anyone permission to read:own any resources. Seems not possible at the moment.

gregwym avatar Dec 11 '18 12:12 gregwym

To expand on this, I'd love an api like this:

ac.grant('user').resource('resource_one').action('create', 'any')
ac.grant('user').resource('resource_two').action('edit', 'own')

allowing

ac.grant('user').resource('resource_one').action('*', 'any')

or

ac.grant('admin').resource('*').action('*', 'any')

or some other combination that you could imagine!

gausie avatar Feb 06 '19 18:02 gausie

There's an (intermediate) solution to your problems https://github.com/anodynos/accesscontrol-re :-)

anodynos avatar Feb 25 '19 01:02 anodynos

I want to do this:

let grantsObject = {
        '*': {
          '*': {
            'create:any': ['!*'],
            'read:any': ['!*'],
            'update:any': ['!*'],
            'delete:any': ['!*']
          }
        }
      };
//......... add more reading database
const ac = new AccessControl(grantsObject);

but I having this error: Unhandled rejection AccessControlError: Cannot use reserved name "*" for a resource.

so, is there any way to add default permission for all users and all resources?

I think instead of granting all permissions to all roles using *. Have a default role that is granted to everyone and then use that role to grant all permissions.

hamxabaig avatar Nov 11 '21 07:11 hamxabaig