Authorization via security.yaml

# config/packages/security.yaml
security:

access_control:
# public access only for /
- { path: ^/$, roles: PUBLIC_ACCESS }
# public access to login page /login
- { path: ^/login, roles: PUBLIC_ACCESS }
# or require ROLE_ADMIN or ROLE_USER_ADMIN for /admin/users*
- { path: '^/admin/users', roles: [ROLE_USER_ADMIN, ROLE_ADMIN] }
# require ROLE_ADMIN for /admin*
- { path: ^/admin, roles: ROLE_ADMIN }
# authenticated users only to the rest /*
- { path: ^/, roles: IS_AUTHENTICATED_FULLY
No limit on amount of URL patterns. Each is a regular expression. First match will be used.

Prepend the path with ^ to ensure only URLs beginning with the pattern are matched.
Comments