php - Symfony - permissions (rights) instead of roles -


i implemented user registration/login schema in symfony 3.x project. based implementation on http://symfony.com/doc/current/cookbook/doctrine/registration_form.html (among others).

well, works, it's based on roles, , want change permissions, like: "can_edit", "can_post", "can_delete" etc.

it doesn't work roles, there no such thing "role hierarchy", besides logic behind controlling user access bit more complicated editing security.yml -> access_control.

so how can accomplish this?

btw, did is:

reading this: http://symfony.com/doc/current/cookbook/security/voters.html :)

creating tables "permission" , "user_permission". "permission" table has id , "symbol" (text) column (e.g. value == "can_post"). user_permission has "user_id" , "permission_id" fields.

i created "permission" entity (i use orm), , modified user entity, joined "permission":

/**  *  * @orm\manytomany(targetentity="appbundle\entity\permission", cascade = {"persist"})  */ private $userpermissions; 

but have no idea if i'm way go? , next? i'm new symfony.

btw, don't think want use acl, because of comment in symfony's docs:

using acl's isn't trivial, , simpler use cases, may overkill. if permission logic described writing code (e.g. check if blog owned current user), consider using voters.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -