spalax/zf2-simple-acl
简单的ACL模块。提供限制路由的可能性。根据用户请求的受限资源的路径/模块提供智能重定向。它可以用于通过单个ACL库限制几个模块。
0.0.2
2013-12-11 15:39 UTC
Requires
- php: >=5.3
- doctrine/doctrine-module: >=0.7.2
- doctrine/doctrine-orm-module: >=0.7.0
- zendframework/zendframework: >=2.0.0
- zf-commons/zfc-user: >=0.1.2
This package is auto-updated.
Last update: 2024-09-06 10:18:39 UTC
README
简单的ACL模块。
限制路由
开始时您只需要定义想要限制的路由以及对于未定义路由的您希望使用的策略。策略可能是 'permissive' 或 'strict'。如果值是 'permissive',它将表示“允许所有来自所有”,因此您将不得不限制所有想要被限制的资源。如果值是 'strict',它将表示“拒绝所有来自所有”,因此您将不得不允许所有想要可用的资源。
'restriction_strategy' => 'permissive',
'routes' => array(
'main' => array(true)
)
智能重定向
根据用户请求的受限资源的路径/模块提供智能重定向。它可以用于通过单个ACL库限制几个模块。
'redirect_route' => array('/frontend.*?/'=>'frontend/user/login',
'/backend.*?/'=>'backend/user/login')
如果您在前后端模块上有授权,并且希望将请求后端资源的用户重定向到后端/user/login路由,将请求前端受限资源的用户重定向到前端/user/login,这将非常有用。
识别器
这是一种非常简单的通过某些令牌授权用户的能力。现在只支持通过在COOKIE中定义的令牌进行授权。我添加这个功能只是因为我时不时需要可以访问特定资源的用户角色,但不需要通过登录表单进行真实授权。在我的例子中是一个cron脚本。
wget http://$1/generate/sitemap --no-cookies --header "Cookie: cron=a23b4cdg76fb38a5d48b83e22f0e79df" -o /dev/null -O /tmp/sitemap.generated
您应该指定识别器
'recognizers' => array('cron'),
和角色
'roles' => array(array('name'=>'cron',
'id'=>2,
'data' => array(
'type'=>'cron',
// It is authorization token, value will be compared with
// token inside $_COOKIE['cron'] and will decide that this is
// cron role.
'token'=>'a23b4cdg76fb38a5d48b83e22f0e79df'
)))