Symfony:对某些类型的用户取消后端模块的安全。如何?
开门见山——我有一个 Symfony 1.3 / Propel 1.4 项目。我有一个通过其自己的 security.yml 中的 is_secure: true 来保护的模块。我希望这个模块不仅可供超级管理员访问——我正在使用 sfGuardPlugin symfony 插件。该模块位于后端
应用程序中。
我想让具有任意 type
属性值的用户可以访问该模块。该网站的普通用户在那里有 NULL
,其余所有都有某种值。当我将安全指令更改为 is_secure: false
(只是为了测试它)时,我会转到 /admin
并使用具有某种 类型的用户登录
,我被正确重定向到 /admin/purchases
(唯一不安全的后端
模块),但出现安全错误消息 - “您没有访问权限显示此页面”或类似的内容。
由于我不太熟悉 sfGuardPlugin
(以及 Symfony 的总体安全性),因此我需要一些关于如何执行此操作的帮助。
Straight to the point -- I have a Symfony 1.3 / Propel 1.4 project. I have a module which is secured via is_secure: true
in its own security.yml
. I want this module to be accessible not only for super admins -- I am using the sfGuardPlugin
symfony plugin. The module is located in the backend
app.
I would like to make the module accessible to users who have any value of their type
property. Regular users of the site have NULL
in there, all of the rest have a value of some kind. When I change the security directive to is_secure: false
(just to test it), I then go to /admin
and do login with a user who has some type
, I get properly redirected to /admin/purchases
(the only non-secured backend
module) but with security error message -- "You do not have access to show this page" or something along the lines.
Since I am not quite so familiar with sfGuardPlugin
(and Symfony's security in general), I would like some help as to how do I do this, please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅文档了解行动安全。
使用 sfGuardPlugin 中的组权限自动为您选择的用户提供广告凭据(请参阅额外文档 sfGuardPlugin 以了解插件如何将用户组和权限转换为凭据)
See documentation about action security.
Use group permissions from sfGuardPlugin to automatically ad credentials for users of your choice (see extra documentation for sfGuardPlugin in order to understand how the plugin converts user groups and permissions into credentials)
如果您不想中继 security.yml 凭据,您还可以在操作中处理此问题:
如果这适用于模块的更多操作,则您可以在 DRY 的情况下使用 preExecute() 方法(不要重复自己) ……)
If you don't want to relay on the security.yml credentials, you could also handle this inside an action:
If this works for more actions of your module, yould could use the preExecute() methode in case of DRY (dont repeat yourself…)
只要您拥有每个用户的正确凭据。在您的后端模块中
security.yml 文件中,您可以执行以下操作:
或者您可以执行单独的操作:
As long as you've got the right credentials for each user. In your backend modules
security.yml file you can do this:
Or you can do individual actions: