ZF-Commons / zfc-rbac

Role-based access control module to provide additional features on top of Zend\Permissions\Rbac
BSD 3-Clause "New" or "Revised" License
181 stars 111 forks source link

a guard priority question #375

Closed andrconstruction closed 7 years ago

andrconstruction commented 7 years ago

Hi. Can you advise me what should I do. I need to create an auth service for an api before guards start. What a priority of my listener should be or an event? Or how can I achieve this?

danizord commented 7 years ago

By default, guards are attached to MvcEvent::EVENT_ROUTE with priority -5: https://github.com/ZF-Commons/zfc-rbac/blob/v2.6.3/src/ZfcRbac/Guard/AbstractGuard.php#L36-L44, so if you want your listener to run before it, you just have to attach it with a higher priority.

Also make sure that your use-case can't be covered with a custom provider: https://github.com/ZF-Commons/zfc-rbac/blob/master/docs/03.%20Role%20providers.md