akveo / nebular

:boom: Customizable Angular UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/nebular
MIT License
8.06k stars 1.51k forks source link

NbAccessChecker #954

Open KelvinPrimo opened 6 years ago

KelvinPrimo commented 6 years ago

Issue type

I'm submitting a ... (check one with "x")

feature description

*nbIsGranted to use "OR" and "AND" on permissions and resources. for especial permissions givem from an api to especial users. like this: NbSecurityModule.forRoot({ accessControl: { custon: { view: ['header'], }, guest: { parent: 'custon', view: ['header'], Screate: api.specialcreate, },

and in template. <button *nbIsGranted="[{'OR':['post', 'Screate']}, {'AND':['comments', 'specialresource1']}]" >Post Comment</button>

in this example the user must have "post" OR "Screate" permission, and 'comments' and 'specialresource1' resource.

Tibing commented 6 years ago

Hi @KelvinPrimo, could you please explain slightly deeper how this API has to work from your point of view?

KelvinPrimo commented 6 years ago

Hello @Tibing, In my case, the role user do not have permission to create user and simulation. but when user loggin the server return an JWT with following information: { "sub": 2, "exp": 1541530348, "user": { "id": 2, "role": "user", "active": 1, "nome": "Kelvin", "sobrenome": "Primo", "email": "kelvin.primo@gmail.com", "username": "kelvin", "birthdate": "2017-09-16T00:00:00+00:00", "created": "2018-10-24T17:29:00+00:00", "modified": "2018-10-24T17:29:00+00:00", "picture": "/assets/images/eva.png", "tipo": "1", "validade": "2018-10-26T00:00:00+00:00", "specialPermissions": { "create": ['User', 'Simulation'], "delete": ['Simulation'], "view": ['Simulation'], } "sub": 2 } }

only admin's can create simulations. Or, any role with the special permission. and that is the idea behind it. and in my case the "add user button" will be like this: <button *nbIsGranted="[{'OR':['create', 'specialPermissions']}, ['user']]" >Add User</button>

But the mainly idea is just use *nbIsGranted with this workflow. OR workflow AND workflow

I hope you understood. Sorry for my poor english.

nnixaa commented 5 years ago

Hi @KelvinPrimo, have you been able to resolve the issue?