根据凭据限制整个 symfony 管理生成器页面
我有一个网站,有大量的管理生成器来管理各种表格。在经过身份验证的用户领域内,我希望能够拒绝访问,不仅是对单个操作或字段的访问,而且是对整个管理模块的访问。
generator.yml
似乎没有全局凭据参数,并且在模块级别将内容放入 security.yml
中似乎没有任何效果。
我浏览了生成的代码并查看了 cache/front/dev/modules/autoFoo/actions/actions.class.php
,特别是 preExecute(),但我不知道是什么去做。
我想我必须在我自己的 actions.class.php 文件中覆盖 preExecute() ,但我有点不确定需要什么,例如何时调用parent::preExecute() (如果实际上我需要或不)。
I have a website with a large number of admin generators to take care of an assortment of tables. Within the realm of authenticated users, I want to be able to deny access, not just to individual actions or fields, but an entire admin module.
There doesn't appear to be a global credentials parameter for generator.yml
, and putting stuff in security.yml
at the module level doesn't appear to have any effect.
I've browsed the generated code and looked at cache/front/dev/modules/autoFoo/actions/actions.class.php
, and at preExecute() in particular, but I don't know what to do.
I suppose I have to overwrite preExecute() in my own actions.class.php file, but I'm a bit unsure about what needs to be one, e.g., when to call parent::preExecute() (if in fact I need to or not).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信您可以通过设置“all”值来设置模块级别 security.yml 内的凭据。也就是说,在/config/security.yml 中,输入:
I believe you can set the credentials inside of the module level security.yml by setting the "all" value. That is, inside of <module>/config/security.yml, put:
回答我自己的问题,根据一些初步调查的结果,似乎:
……至少可以防止人们通过黑客 URL 来访问管理功能。但我相信
sfContext::getInstance( )
是邪恶的。因此,我仍在寻找正确的方法。Answering my own question, with the results of some preliminary investigations, it would appear that:
...will at least prevent people for hacking URLs to get at the admin function. But I am led to believe that
sfContext::getInstance()
is evil. Hence I'm still looking for the Right Way To Do It.model/config 文件夹中的 security.yml 文件应如下所示:
your security.yml file in your model/config folder should look like this: