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:
        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
        device_pairing:
            pattern: ^/api/v1/(device-pairings|device-probes)
            security: false
        device:
            pattern: ^/api/v1/device/
            stateless: true
            custom_authenticators:
                - App\Security\DeviceAuthenticator
        parent:
            pattern: ^/api/v1/parent/
            lazy: true
            provider: app_user_provider
            user_checker: App\Security\ParentUserChecker
            custom_authenticators:
                - App\Security\ParentJsonLoginAuthenticator
        main:
            security: false

    # Note: Only the *first* matching rule is applied
    access_control:
        - { path: ^/api/v1/parent/(csrf|login)$, roles: PUBLIC_ACCESS }
        - { path: ^/api/v1/parent/, roles: ROLE_PARENT }
        - { path: ^/api/v1/device/, roles: ROLE_DEVICE }

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
