Symfony2 FOSUserBundle身份验证

时间:2015-08-02 16:11:12

标签: symfony

我刚配置了Symfony2的FOSUserBundle捆绑包,我有一个问题要问。

下面的一些URL允许每个人访问配置页面。我怎样才能将此限制为仅限管理员?

例如,没有管理员登录的访问者/成员不应该看到下面的页面。

http://localhost/fosuser/web/app_dev.php/_profiler/search_bar

我使用终端运行以下命令:php app/console router:debug

_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_purge ANY ANY ANY /_profiler/purge
_profiler_info ANY ANY ANY /_profiler/info/{about}
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
_configurator_home ANY ANY ANY /_configurator/
_configurator_step ANY ANY ANY /_configurator/step/{index}
_configurator_final ANY ANY ANY /_configurator/final
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
user ANY ANY ANY /user/
user_show ANY ANY ANY /user/{id}/show
user_new ANY ANY ANY /user/new
user_create POST ANY ANY /user/create
user_edit ANY ANY ANY /user/{id}/edit
user_update POST|PUT ANY ANY /user/{id}/update
user_delete POST|DELETE ANY ANY /user/{id}/delete
custom_user_homepage ANY ANY ANY /hello/{name}
homepage ANY ANY ANY /app/example

1 个答案:

答案 0 :(得分:1)

默认情况下,在symfony中,所有_profiler个网址都在dev防火墙中使用模式^/(_(profiler|wdt|error)|css|images|js)/进行管理,您可以在app/config/security.yml文件中看到。正如您将看到的,它们没有相关的安全性。这是正常现象,因为它们无法在生产中使用。

但是,如果您仍然需要检查这些网址,请随意向该防火墙添加一些安全配置,同时考虑到它还会影响其他匹配的网址,例如_errorcss,因此您可能需要为_profiler路由创建一个新的特定防火墙。