Configuring the security access
Last updated
Was this helpful?
Was this helpful?
bin/console make:usersecurity:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
# used to reload user from session & other features (e.g. switch_user)
app_admin_user_provider:
entity:
class: App\Entity\User
property: emailsecurity:
firewalls:
# ...
admin:
context: admin
pattern: '/admin(?:/.*)?$'
provider: app_admin_user_provider # Reuse the provider key you configured on providers section
form_login:
# These routes are provided by Sylius Admin Ui package
login_path: sylius_admin_ui_login
check_path: sylius_admin_ui_login_check
default_target_path: sylius_admin_ui_dashboard
logout:
# These routes are provided by Sylius Admin Ui package
path: sylius_admin_ui_logout
target: sylius_admin_ui_login
main:
lazy: truesecurity:
access_control:
- { path: ^/admin/login, roles: PUBLIC_ACCESS }
- { path: ^/admin/logout, roles: PUBLIC_ACCESS }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/, roles: PUBLIC_ACCESS }