security:
    # 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_user_provider:
            entity:
                class: App\Entity\User
                property: email

    firewalls:
        dev:
            # Ensure dev tools and static assets are always allowed
            pattern: ^/(_profiler|_wdt|assets|build)/
            security: false
        main:
            lazy: true
            provider: app_user_provider
            custom_authenticator: App\Security\SecurityControllerAuthenticator
            logout:
                path: app_logout
                target: app_login

            remember_me:
                secret: '%kernel.secret%'
                lifetime: 604800
                path: /
                # by default, the feature is enabled by checking a checkbox in the
                # login form, uncomment the following line to always enable it.
                #always_remember_me: true

            # 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: { role: ROLE_ADMIN }

    role_hierarchy:
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    # Note: Only the *first* matching rule is applied
    access_control:
        - { path: ^/$, roles: PUBLIC_ACCESS }
        - { path: ^/login, roles: PUBLIC_ACCESS }
        - { path: ^/inscription, roles: PUBLIC_ACCESS }
        - { path: ^/reset-password, roles: PUBLIC_ACCESS }
        - { path: ^/invitation, roles: PUBLIC_ACCESS }
        - { path: ^/cron/, roles: PUBLIC_ACCESS }
        - { path: ^/api/push/vapid-public-key, roles: PUBLIC_ACCESS }
        # API JSON : remember_me + entry point JSON sur /api/ (SecurityControllerAuthenticator::start).
        - { path: ^/api/buteurs/recherche, roles: IS_AUTHENTICATED }
        - { path: ^/api/matchs/live-feed, roles: IS_AUTHENTICATED }
        - { path: ^/api/notifications, roles: IS_AUTHENTICATED }
        - { path: ^/api/badges, roles: IS_AUTHENTICATED }
        - { path: ^/api/forum, roles: IS_AUTHENTICATED }
        - { path: ^/quizz-hymnes, roles: ROLE_ADMIN }
        - { path: ^/api/anthem-quiz, roles: ROLE_ADMIN }
        - { path: ^/admin/sync, roles: ROLE_ADMIN }
        - { path: ^/admin, roles: ROLE_ADMIN }
        # Front : IS_AUTHENTICATED inclut « remember me » (admins = joueurs + lien menu EasyAdmin).
        - { path: ^/, roles: IS_AUTHENTICATED }

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
