按照本教程,我正在使用 symfony 身份验证/授权架构开发一个 Web 应用程序。
在设计整个结构(路由、页面和安全级别)后,我陷入了困境:如何在不一直输入凭据的情况下开发我的页面?有什么方法可以禁用或关闭整个防火墙功能吗?我应该使用数据装置吗?
Following this tutorial i'm developing a web application using symfony authentication/authorization architecture.
After designing the whole structure (routes, pages and security levels) i'm stuck: how can i develop my pages without enter credentials all the time? Is there any way to disable or turn off the entire firewall functionality? Should i use data fixtures?
发布评论
评论(2)
在您的
app/config/security.yml
文件中,在firewalls
配置选项下添加或修改dev
...In your
app/config/security.yml
file, under thefirewalls
config option add or modify thedev
...security.firewalls.dev:配置用于每个Symfony环境(dev,test,prod)!
在Symfony 4中,实现禁用在开发环境中为所有路由设置防火墙,您可以执行以下操作:
设置:
config/packages/security.yaml
:覆盖每个 Symfony 环境:
创建一个新文件
config/packages/dev/parameters.yaml
:现在,在 Symfony dev environ 中,所有路由都可以在没有防火墙的情况下访问
使用环境变量覆盖:
您也可以覆盖
.env
文件中的 >SECURITY_DEV_PATTERN:SECURITY_DEV_PATTERN=^/
仅当您不包含生产环境中的
.env
,或者您也专门覆盖了SECURITY_DEV_PATTERN
环境变量。The
security.firewalls.dev:
configuration is used in every Symfony environment (dev,test,prod)!In Symfony 4, to achieve disabling firewalls for all routes in just dev environment, you could do something like this:
Setup:
config/packages/security.yaml
:Override per Symfony environment:
create a new file
config/packages/dev/parameters.yaml
:Now all routes are reachable without firewall in Symfony dev environ
Override using environment variables:
You could also override
SECURITY_DEV_PATTERN
in the.env
file:SECURITY_DEV_PATTERN=^/
This only works if you don't include the
.env
in your production environment, or if you specifically override theSECURITY_DEV_PATTERN
environment variable there as well.