I've only started using in Sentry Laravel 4 and I'm not sure where I should be writing my Group permissions. I've gone through the Sentry docs but the explanation seems a bit vague. Are there any Sentry users who can point me in the right direction?
3 Answers
I'm still figuring out Sentry permissions myself, but hopefully this reply helps get you on the right track. I'm also hoping that I'm on the right track! :)
The following is an (apparently) unstated fact that had me confused the longest. Once I realized this, the rest started to make sense:
Sentry does not maintain, or even require, a pre-defined list of permissions.
The permissions field in the groups and users tables will take whatever permissions keys you give it. Sentry doesn't check to ensure these keys are legitimate when they're saved. It's just a text field.
If you want/need a definitive list of manageable permissions, one option would be to create your own permissions table in the database.
Managing this permissions table would likely also require creating your own models and admin views as this would still be separate from Sentry. As for applying permissions to groups and users, you could then use this table to populate a selectable permissions list on your "create/edit user" and "create/edit groups" pages.
As i have seen the Sentry config file i found some ideas as how to use permissions. You need to define the permissions in the sentry/config/sentry.php file. Here is simple demonstration.
'rules' => array(
/**
* config samples.
*
* 'application::admin@dashboard',
* 'user::admin@create',
* 'user::admin@read',
* 'blog::admin@delete',
* 'my_custom_rule',
* 'is_admin',
*/
'is_admin',
'superuser',
'can_edit',
'can_delete'
)
I added can_edit and can_delete permission and it is now working.
There is a decent Laravel starter with Sentry2 , it helped me explain how it works by checking out how it was implemented. Check l4 with sentry here.
It seems plenty of people struggle with the permission part of sentry, including myself. Also, check out this SO thread, it looks like it is a duplicate of this question, there is more info on that one as well.