security:
    enable_authenticator_manager: true
#    access_decision_manager:
#        strategy: unanimous
#        allow_if_all_abstain: false
    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    # 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:
        users_in_memory: { memory: null }
        database_admin:
            id: AutoAdmin\Bundle\Admin\Security\AdministratorProvider
            # used to reload user from session & other features (e.g. switch_user)
#            user_provider:
#                entity:
#                    class: App\Entity\User
#                    property: email
#
#            encoders:
#                AutoAdmin\Bundle\Admin\Entity\Administrator:
#                    algorithm: auto
#                App\Entity\User:
#                    algorithm: auto

    role_hierarchy:
        ROLE_USER: [ ]
        ROLE_ADMIN: [ ]
        ROLE_SUPER_ADMIN: [ ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH ]
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        main:
            context: global
            switch_user: true
            pattern: ^/admin
#            anonymous: true
            lazy: true
            provider: database_admin
            entry_point: AutoAdmin\Bundle\Admin\Security\AdminCustomAuthenticator
            form_login:
                check_path: aa_admin_login
                login_path: aa_admin_login
                enable_csrf: true
                default_target_path: aa_admin_dashboard_index
            logout:
                path: aa_admin_logout
                target: aa_admin_login
            custom_authenticators:
                - AutoAdmin\Bundle\Admin\Security\AdminCustomAuthenticator

        front:
            context: global
            # this firewall applies to all URLs
            pattern: ^/

            # but the firewall does not require login on every page
            # denying access is done in access_control or in your controllers
#            lazy: true
#            provider: user_provider
#            logout:
#                path: user_logout
                # where to redirect after logout
#                target: app_any_route

    # Easy way to control access for large sections of your site
    # Note: Only the *first* access control that matches will be used
    access_control:
        - { path: '^/admin/([a-z]{2})/login', roles: PUBLIC_ACCESS }
        - { path: '^/admin/([a-z]{2})/password-reset', roles: PUBLIC_ACCESS }
        - { path: '^/admin/([a-z]{2})', roles: ROLE_ADMIN }

when@test:
    security:
        password_hashers:
            # By default, password hashers are resource intensive and take time. This is
            # important to generate secure password hashes. In tests however, secure hashes
            # are not important, waste resources and increase test times. The following
            # reduces the work factor to the lowest possible values.
            Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
                algorithm: auto
                cost: 4 # Lowest possible value for bcrypt
                time_cost: 3 # Lowest possible value for argon
                memory_cost: 10 # Lowest possible value for argon
