security:
    password_hashers:
        App\Entity\User: 'auto'

    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
        main:
            lazy: true
            provider: app_user_provider
            entry_point: App\Security\ApiEntryPoint
            json_login:
                check_path: /api/auth/login
                username_path: email
                password_path: password
                success_handler: App\Security\LoginSuccessHandler
                failure_handler: App\Security\LoginFailureHandler
            logout:
                path: /api/auth/logout

    # Le SPA parle uniquement JSON (jamais application/x-www-form-urlencoded
    # ou multipart) : un formulaire HTML forgé sur un autre site ne peut pas
    # reproduire ces requêtes, ce qui neutralise le CSRF classique sans avoir
    # besoin d'un jeton dédié. Le cookie de session reste SameSite=Lax (défaut
    # Symfony), seconde barrière contre les requêtes cross-site.
    access_control:
        - { path: ^/api/auth/(signup|login)$, roles: PUBLIC_ACCESS }
        - { path: ^/api, 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
