5

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!!!

4

2 に答える 2

1

YoannChさんの回答も正解です。

{_locale}を a%_locale%またはに置き換えるべきではありませんか%locale%

于 2013-10-22T12:47:11.503 に答える