Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude public pages from access control list

Tags:

php

symfony

acl

I have application in Symfony2 with 2 roles: ROLE_ADMIN and ROLE_PARTNER. Also I have some public pages. All public pages starts with URL "/public/". I want to protect all application excluded these public items.

My current config:

access_control:
    - { path: /.*, role: ROLE_PARTNER|ROLE_ADMIN }
    - { path: /public/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

But it works wrong (looping redirection).

like image 661
Alex Pliutau Avatar asked Sep 03 '12 14:09

Alex Pliutau


1 Answers

Change the order:

access_control:
    - { path: ^/public/, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/, role: ROLE_PARTNER|ROLE_ADMIN }

The second option is to turn off security for the public section completely:

firewalls:
    public:
        pattern: ^/public/
        security: false
like image 89
Elnur Abdurrakhimov Avatar answered Oct 18 '22 23:10

Elnur Abdurrakhimov