w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Symfony - Restrict access to a route for users with a particular role

I think you can easily do that with symfony expression language(new feature in 2.4 I think). Some example:

access_control:
    - { path: ^/_internal/secure, allow_if: "'127.0.0.1' ==
request.getClientIp() or has_role('ROLE_ADMIN')" }

For more details go to: https://github.com/symfony/symfony/pull/8913

For version 2.3.4(the current stable one), you need to manually create another custom role that is the negation of MY_CUSTOM_ROLE.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.