Every serious application needs to be able to control access to the logical processes within its framework. Using Phalcon, we can easily create a security system to control access to resources based upon group membership. In this recipe, we will define resources as controller-action pairs, but the primitives of the permission system are general enough that, with a little work, the resources could be broadened to be anything.
In our case, the idea of restricting resources (controller actions) is simple—if a user's group does not have permission to access an action then we will display the message Unauthorized access
. Later this could be extended to forward the user to a sign-in page or to an alternative page for that resource.