With this configuration:
firewalls:
login:
pattern: ^/login$
anonymous: ~
security: false
foo:
pattern: ^/foo$
anonymous: ~
security: false
secured_area:
pattern: ^/
form_login:
login_path: /login
check_path: /login_check
logout:
path: /logout
target: /
access_control:
- { path: ^/, roles: ROLE_ADMIN }
- { path: ^/foo, roles: IS_AUTHENTICATED_ANONYMOUSLY }
I want to be able to make /foo
anonymously accessible. However, when I try to go there even after clearing the cache it won't allow me to and redirects to login screen.
How do I make one route to be anonymously accessible while retaining the rest of the system to be secured?
Replace
- { path: ^/foo, roles: IS_ANONYMOUS }
with
- { path: ^/foo, roles: IS_AUTHENTICATED_ANONYMOUSLY }
UPDATE
Also, I believe, you will have to add
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
for authentication to work properly.
For more info check out Avoid Common Pitfalls section here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.