如何结合 Zend_Ath、Zend_Acl 和partialview 进行身份验证和资源控制
根据随机性会让你无处不在。 瑞安的博客 不需要 Zend Framework 的操作堆栈组件,并且可以将部分视图与 Zend_Acl 和 Zend_Auth 结合起来以验证和控制资源。
我在谷歌上找不到任何合适的例子来说明它是如何完成的。我会很高兴有人会好心地向我展示如何实现这一点。谢谢
According to Randomness will get you everywhere.
Ryan’s Blog
the action stack component of Zend Framework is un-needed and that a partial view can be combined with Zend_Acl and Zend_Auth for the purpose of authenticating and controlling resources.
I have not been able to find any suitable example on google about how its done. Will be glad is someone will be kind to show me how to implement this. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这里:
您可以结合使用 Zend_Auth 和 Zend_Acl。为了扩展其他答案,我给出了一个简短的示例,说明如何使用 zend 框架管理身份验证:
首先,您需要设置一个插件来预调度所有请求,并检查是否允许客户端访问某些数据。该插件可能如下所示:
因此,每种用户类型都具有您在 acl 库中定义的某些权限。对于每个请求,您都会检查是否允许用户访问资源。如果没有,您将重定向到登录页面,否则 preDispatch 将用户传递到资源。
在 Zend_Acl 中,您定义角色、资源和权限,允许或拒绝访问,例如:
然后您必须在引导程序文件中设置 acl 和身份验证:
最后在身份验证控制器中,您必须使用自定义身份验证适配器并设置登录和注销操作:
在您的登录操作您需要将登录数据传递给执行身份验证的身份验证适配器。
仅此而已。我向您推荐 youtube 上关于 zend auth 和 zend acl 的如何。
Here you go:
You could use the combination of Zend_Auth and Zend_Acl. To extend the other answers I give a short example of how you can manage authentication using zend framework:
First you need to setup a plugin to predispatch all requests and check if the client is allowed to access certain data. This plugin might look like this one:
So every user type has certain permissions that you define in your acl library. On every request you check if the user is allowed to access a resource. If not you redirect to login page, else the preDispatch passes the user to the resource.
In Zend_Acl you define roles, resources and permission, that allow or deny access, e.g.:
Then you have to setup acl and auth in your bootstrap file:
Finally in your authentication controller you have to use a custom auth adapter and setup actions for login and logout:
In your login action you need to pass login data to the auth adapter which performs the authentication.
And that's all. I recommend you this HOW TO on youtube on zend auth and zend acl.
您可能会发现以下有关 Action Helpers 的文章很有用,如果您不熟悉,我建议您浏览这些网站,因为它们也有关于实现 Zend_Auth 的文章:
You may find the following articles on Action Helpers useful, I recommend browsing the sites if any are new to you as they also have articles on implementing Zend_Auth: