Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Secured area with locale

How can I secure actions with locale - this was pretty easy in symfony1.4. I use now symfony2.3:

My security.yml:

firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    login:
        pattern:  frontend_account_login
        security: false


    secured_area:
        pattern:    ^/
        anonymous: ~
        http_basic:
            realm: "Secured Demo Area"
        form_login:
            check_path: frontend_account_security_check
            login_path: frontend_account_login
            use_referer:        true
            default_target_path: frontend_account_hello
        logout:
            path:   /logout
            target: frontend_account_login            #anonymous: ~
        #http_basic:
        #    realm: "Secured Demo Area"

access_control:
    #This works:
    - { path: ^/de/account/secured/, roles: ROLE_ADMIN }
    - { path: ^/en/account/secured/, roles: ROLE_ADMIN } 
    #I want it kind of that way
    - { path: ^/{_locale}/account/secured/, roles: ROLE_ADMIN }

I read a post with regex: ^/[a-z]+/account/secured/. But it doesn't work. Any idea how I can secure areas with locale. I found some posts here but they all don't work.

Thanks!!!

like image 601
user2906347 Avatar asked Oct 03 '22 15:10

user2906347


1 Answers

If you have only two locales:

- { path: ^/(en|de)/account/secured/, roles: ROLE_ADMIN }
like image 141
A.L Avatar answered Oct 13 '22 09:10

A.L