# api/config/packages/security.yaml
security:
    # https://symfony.com/doc/current/security.html#c-hashing-passwords
    password_hashers:
        App\Entity\User: 'auto'

    # https://symfony.com/doc/current/security/authenticator_manager.html
    enable_authenticator_manager: true
    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    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:
            pattern: ^/_(profiler|wdt)
            security: false
        #api:
        #    pattern: ^/api/
        #    stateless: true
        #    entry_point: jwt
        #    provider: app_user_provider
            #jwt: ~
            #refresh_jwt:
                #check_path: /api/token/refresh
        main:
            #json_login:
            #    check_path: /authentication_token
            #    username_path: email
            #    password_path: password
            #    success_handler: lexik_jwt_authentication.handler.authentication_success
            #    failure_handler: lexik_jwt_authentication.handler.authentication_failure
            #user_checker: App\Security\UserEnabledChecker
            #jwt: ~
            provider: app_user_provider
            custom_authenticator: App\Security\AppSebegoAuthenticator
            logout:
                path: app_logout
                # where to redirect after logout
                # target: app_any_route
            two_factor:
                auth_form_path: 2fa_login    # The route name you have used in the routes.yaml
                check_path: 2fa_login_check  # The route name you have used in the routes.yaml

            remember_me:
                secret: '%kernel.secret%'
                lifetime: 604800
                path: /
                always_remember_me: true

    access_control:
        #- { path: ^/docs, roles: PUBLIC_ACCESS } # Allows accessing API documentations and Swagger UI
        #- { path: ^/authentication_token, roles: PUBLIC_ACCESS }
        #- { path: ^/, roles: PUBLIC_ACCESS }
        #- { path: ^/api/(login|token/refresh), roles: PUBLIC_ACCESS }
        - { path: ^/admin, roles: IS_AUTHENTICATED_FULLY }
        - { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS }

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
