Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a route from the firewall? (or avoid session cookie)

I have this firewall which includes anything that begins with /user or /admin.

firewalls:
    main:
        pattern: ^/(user|admin)

But now I need to exclude /user/profile/{user_id}. Can this be done with a regex? For now, it's fine if it excludes anything that begins with /user/profile, if that's easier.

Is there any other mechanism provided by Symfony2 to exclude routes?

EDIT

I need to totally exclude said route to avoid sending the session cookie; allowing anonymous access with access_control is not enough. If you know a way to stop that cookie, it can be a solution too.

like image 415
ChocoDeveloper Avatar asked Dec 02 '12 10:12

ChocoDeveloper


1 Answers

I didn't test this code, but this regex should work:

firewalls:
    main:
        pattern: ^/(user|admin)(?!/profile)
like image 180
Wouter J Avatar answered Sep 27 '22 18:09

Wouter J