Turn off the firewall during early development with Symfony2?

Following this tutorial I am developing a web application using the symfony authentication / authorization architecture.

After designing the whole structure (routes, pages and security levels), I got stuck: how can I design my pages without entering credentials all the time? Is there a way to disable or disable all firewall functionality? Should I use data?

+5
source share
2 answers

In your app/config/security.yml file, in the firewalls config option add or change dev ...

 firewalls: dev: pattern: ^/ security: false 
+6
source

security.firewalls.dev: configuration security.firewalls.dev: used in any Symfony environment (dev, test, prod)!

In Symfony 4 , in order to disable firewalls for all routes in a simple dev environment, you can do something like this:

Installation:

config/packages/security.yaml :

 parameters: # Adds a fallback SECURITY_DEV_PATTERN if the env var is not set. env(SECURITY_DEV_PATTERN): '^/(_(profiler|wdt)|css|images|js)/' security: firewalls: dev: pattern: '%env(SECURITY_DEV_PATTERN)%' security: false 

Override for symfony environment:

create a new config/packages/dev/parameters.yaml file:

 parameters: env(SECURITY_DEV_PATTERN): '^/' 

Now all routes are available without a firewall in Symfony dev

Override using environment variables:

You can also override SECURITY_DEV_PATTERN in the .env file:

SECURITY_DEV_PATTERN=^/

This only works if you have not included .env in your production environment or if you specifically override the SECURITY_DEV_PATTERN environment variable in the same place.

0
source

Source: https://habr.com/ru/post/921424/


All Articles