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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With