简体   繁体   中英

Can we use regex in symfony2 access control?

Can we use regex in access control in symfony2 security?

1) /foo/{id} -- [ROLE_ADMIN]
2) /foo/{id}/profile --  [IS_AUTHENTICATED_ANONYMOUSLY]

Another issue:

If I removed the access_control from my security, still it goes to the Security module and try to Authenticate from Security/Authentication/Provider/AuthProvide .

What should be the ideal behavior? I think it should not authenticate the resource if no access_control is in security.yml .

My firewall configuration is:

 firewalls:
    main:
            pattern: ^/
            anonymous: true
            myapp: true

Yes, you can use regex.

But /foo/{id}/profile won't match what you want. As id is probably an integer, you'll have to use instead:

^/foo/[0-9]+/profile$

or

^/foo/[^/]+/profile$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM