1. 简介
Zend_Acl 为权限管理提供轻量并灵活的访问控制列表 (ACL,access control list) 的实现。一般地,应用软件可以利用这样的功能限制某些特定对象来访问特定保护的对象。
2. ACL 主要内容
简单地说就是:roles 请求访问 resources。
resources 的权限(例如:"create", "read", "update", "delete").
3. Resources
接口Zend_Acl_Resource_Interface
new Zend_Acl_Resource('someResource');
4. Roles
Zend_Acl_Role_Interface
new Zend_Acl_Role('editor');
5. Setup privileges
$acl->deny($roles, $resources, $privileges); //可以是数组, null表示所有
$acl->allow($roles, $resources, $privileges);
$acl->RemoveDeny($roles, $resources, $privileges);
$acl->RemoveAllow($roles, $resources, $privileges);
6. ACL 可以被序列化
7. ACL的Assert属性
class CleanIPAssertion implements Zend_Acl_Assert_Interface
{
public function assert(Zend_Acl $acl,
Zend_Acl_Role_Interface $role = null,
Zend_Acl_Resource_Interface $resource = null,
$privilege = null)
{
return $this->_isCleanIP($_SERVER['REMOTE_ADDR']);
}
protected function _isCleanIP($ip)
{
echo $ip."is denied!";
}
}
//$acl->allow($roles, $resources, $privileges, new CleanIPAssertion());
阅读(480) | 评论(0) | 转发(0) |