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$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With