Symfony Basic Security Authentication

From symfony's book http://symfony.com/doc/current/book/security.html#security-authorization I am trying to configure basic HTTP authentication.

The security.yml file is as follows:

 security: providers: in_memory: memory: ~ firewalls: dev: pattern: ^/(_(profiler|wdt|error)|css|images|js)/ security: false default: anonymous: ~ http_basic: ~ access_control: - { path: ^/login, roles: ROLE_USER } 

But as soon as I add

  access_control: - { path: ^/login, roles: ROLE_USER } 

I get a symfony error message:

 InvalidConfigurationException in ArrayNode.php line 309: Unrecognized option "0" under "security.firewalls.access_control" 

What am I doing wrong? What to do to fix it?

+6
source share
2 answers

Your indentation is not very good.

Key

access_control cannot stay under firewalls node

You should change your security.yml as follows

 security: providers: in_memory: memory: ~ firewalls: dev: pattern: ^/(_(profiler|wdt|error)|css|images|js)/ security: false default: anonymous: ~ http_basic: ~ access_control: - { path: ^/login, roles: ROLE_USER } 
+22
source

Remember that if you require ROLE_USER for your /login path, then an unauthorized user will not be able to log into your application.

+1
source

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


All Articles