ACList
From Utopia MVC
Access Control List class, secures a page, showing login forms for non-logged Users, giving out forbidden messages for logged users who don't have enough rights to access the resource and lets authorized users see the page.
Basic use is calling
<?php ACList::onlyAllowGroups('group1','group2') ?>
.
This library relies heavily on the default actions in the ErrorController controller to handle the login/deny access functionalities, this allows for a great degree of customization in the user flow.
Contents |
Methods
onlyAllowGroups
Only allows user having a group found in $groups
Straightforward method that basically takes care of everything on its own, just pass one or more group names that are supposed to have access to the page (being inside even just one is enough).
Unauthorized users will be sent to ErrorController::httpError(401) for attempting login, or ErrorController::httpError(403) if they are already logged in and should be denied access.
- group
- unlimited amount of User::groups that can access this resource, any match will grant access.
Returns true in case access was granted.
hasAccesss
Returns true if $user has one of the listed $groups in his access level.
Basic method that does little but running a quick check.
- user
- the User object to be checked for access
- groups
- an array of allowed access levels (strings), any match will grant access.
Returns true in case access should be granted.