Symfony sfGuardPlugin:禁用默认路由
我在 symfony 1.4 中使用 sfGuardPlugin,我想知道如何摆脱它的“默认”路由。我的意思是“守卫/用户”、“守卫/权限”和“守卫/组”路线。
事实上,我设计了自己的后端,没有管理生成器,并且我使用自定义网址重新创建了这三个页面。那么如何禁用对默认 sfGuard 页面的访问呢?
I'm using the sfGuardPlugin in symfony 1.4 and I'm wondering how to get rid of its "default" routes. I mean by that the "guard/users", "guard/permissions" and "guard/groups" routes.
Indeed I have designed my own backend without admin generator, and I've recreated these three pages with customs urls. So how can I disable the access to the default sfGuard pages ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
app.yml:
如文档中所述。
app.yml:
as stated in the documentation.
您应该将文件
/config/sfDoctrineGuardPluginConfiguration.class.php
更新到最新版本。
在上次更新之前,尽管有文档,但路由确实已注册。
您似乎正在使用此文件的先前版本。
You should update the file
/config/sfDoctrineGuardPluginConfiguration.class.php
to the lasted version.
Before the lasted update, despite the documentation, the routes did get registed anyway.
It seems you are using the previous version of this file.
要停用这 3 个模块:您只需从后端应用程序的 settings.yml 中删除 sfGuardGroup、sfGuardUser、sfGuardPermission。
为了只保留身份验证模块
但是我不知道默认值是什么。
To desactivate these 3 modules : you just have to remove the sfGuardGroup, sfGuardUser, sfGuardPermission from the settings.yml for backend application.
In order to keep only the authentification module
However I have no idea what default is.
如果您 (i) 仍然想使用插件提供的模块,(ii) 使用您自己的路由,(iii) 阻止人们使用默认的 sfGuard 路由,并且 (iv) 仍然使用默认的 /:module/:action 路由(这是相当有用的),你可以重写 sfGuardRouting 类,它在这里
您只需将此文件复制到您的
目录,然后使用这些方法。例如,我只是评论了该类所有方法的所有代码(因为我在 apps/myApp/config/routing.yml 文件中为 sfGuardPlugin 的模块创建了自己的路由),如下所示
If you (i) still want to use the modules provided by the plugin, (ii) using your own routes, (iii) preventing people from using the default sfGuard routes and (iv) still have the default /:module/:action route (which is rather useful), you can override the sfGuardRouting class, which is here
You can simply copy this file to your
directory and then play with the methods. For instance I just commented all the code of all methods of the class (since I made my own routes in my apps/myApp/config/routing.yml file) for the modules of the sfGuardPlugin), like this