繁体   English   中英

Symfony2 FOSUserBundle身份验证

[英]Symfony2 FOSUserBundle authentication

我刚刚配置了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

默认情况下,在symfony中,所有_profiler URL都在dev防火墙中以^/(_(profiler|wdt|error)|css|images|js)/ ,您可以在app/config/security.yml文件中看到。 如您所见,它们没有关联的安全性。 这是正常现象,因为在生产中将无法访问它们。

但是,如果仍然需要检查这些URL,请记住向该防火墙添加一些安全配置,这也会影响其他匹配的URL,例如_errorcss因此您可能只想为_profiler路由创建一个新的特定防火墙。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM