security:
    access_decision_manager:
        strategy: unanimous
        allow_if_all_abstain: true

    # 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:
        sulu:
            id: sulu_security.user_provider

    firewalls:
        dev:
            # Ensure dev tools and static assets are always allowed
            pattern: ^/(_profiler|_wdt|assets|build)/
            security: false
        admin:
            pattern: ^/admin(\/|$)
            lazy: true
            provider: sulu
            entry_point: sulu_security.authentication_entry_point
            json_login:
                check_path: sulu_admin.login_check
                success_handler: sulu_security.authentication_handler
                failure_handler: sulu_security.authentication_handler
            logout:
                path: sulu_admin.logout
            two_factor:
                prepare_on_login: true
                prepare_on_access_denied: true
                check_path: 2fa_login_check_admin
                authentication_required_handler: sulu_security.two_factor_authentication_required_handler
                success_handler: sulu_security.two_factor_authentication_success_handler
                failure_handler: sulu_security.two_factor_authentication_failure_handler

       #website:
       #    pattern: ^/
       #    lazy: true
       #    provider: sulu
       #    # The login and logout routes need to be created.
       #    # For an advanced user management with registration and opt-in emails have a look at the:
       #    # https://github.com/sulu/SuluCommunityBundle
       #    # Also have a look at the user context based caching when you output user role specific data
       #    # https://docs.sulu.io/en/2.6/cookbook/user-context-caching.html
       #    form_login:
       #        login_path: login
       #        check_path: login
       #    logout:
       #        path: logout
       #        target: /
       #    remember_me:
       #        secret:   "%kernel.secret%"
       #        lifetime: 604800 # 1 week in seconds
       #        path:     /
       #
       #    # Activate different ways to authenticate:
       #    # https://symfony.com/doc/current/security.html#the-firewall
       #
       #    # https://symfony.com/doc/current/security/impersonating_user.html
       #    # switch_user: true

    # Note: Only the *first* matching rule is applied
    access_control:
        - { path: ^/admin/reset, roles: PUBLIC_ACCESS }
        - { path: ^/admin/security/reset, roles: PUBLIC_ACCESS }
        - { path: ^/admin/login$, roles: PUBLIC_ACCESS }
        - { path: ^/admin/2fa, roles: PUBLIC_ACCESS }
        - { path: ^/admin/_wdt, roles: PUBLIC_ACCESS }
        - { path: ^/admin/_profiler, roles: PUBLIC_ACCESS }
        - { path: ^/admin/translations, roles: PUBLIC_ACCESS }
        - { path: ^/admin$, roles: PUBLIC_ACCESS }
        - { path: ^/admin/$, roles: PUBLIC_ACCESS }
        - { path: ^/admin/p/, roles: PUBLIC_ACCESS }
        - { path: ^/admin, roles: ROLE_USER }

when@test:
    security:
        password_hashers:
            # Password hashers are resource-intensive by design to ensure security.
            # In tests, it's safe to reduce their cost to improve performance.
            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

        access_decision_manager:
            strategy: affirmative

        providers:
            sulu:
                id: test_user_provider

        firewalls:
            admin:
                http_basic:
                    provider: sulu
