# security:
#     encoders:
#         App\Entity\User:
#             algorithm: argon2i
#             cost: 12

#     # 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: username
#     firewalls:
#         dev:
#             pattern: ^/(_(profiler|wdt)|css|images|js)/
#             security: false
#         main:
#             anonymous: true

#             # activate different ways to authenticate

#             # http_basic: true
#             # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate

#             form_login:
#                 check_path: login
#             guard:
#                 authenticators:
#                     - App\Security\LoginFormAuthenticator
#             # https://symfony.com/doc/current/security/form_login_setup.html
#             remember_me:
#                 secret:   '%kernel.secret%'
#                 lifetime: 604800 # 1 week in seconds
#                 path:     /
#             logout:
#                 path: /logout
#                 target: /

#     # Easy way to control access for large sections of your site
#     # Note: Only the *first* access control that matches will be used
#     # access_control:
#     #     #- { path: ^/admin, roles: ROLE_ADMIN }
#     #     # - { path: ^/profile, roles: ROLE_USER }
#     access_control:
#         - { path: ^/api/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }
#         - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
#         - { path: ^/api/register, roles: IS_AUTHENTICATED_ANONYMOUSLY }
#         - { path: ^/api/v1,       roles: IS_AUTHENTICATED_FULLY }
#         - { path: ^/admin,        roles: ROLE_ADMIN }
security:
    # encoders:
    #     App\Entity\User:
    #         algorithm: argon2i
    #         cost: 12
    role_hierarchy:
        # ROLE_CONTROLLEUR:  [ROLE_COMPTABLE,ROLE_PARTICULIER]
        ROLE_LIVREUR: [ROLE_LIVREUR]
        ROLE_STOCK: [ROLE_STOCK]
        ROLE_ADMIN: [ROLE_CALL,ROLE_SAV,ROLE_LIVREUR,ROLE_STOCK]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
    encoders:
        App\Entity\User:
            algorithm: argon2i
            cost: 12

    providers:
        api_user_provider:
            entity:
                class: App\Entity\User
                property: username

    firewalls:
        login:
            pattern:  ^/api/login
            stateless: true
            anonymous: true
            form_login:
                check_path:               /api/login_check
                success_handler:          lexik_jwt_authentication.handler.authentication_success
                failure_handler:          lexik_jwt_authentication.handler.authentication_failure
                require_previous_session: false

        api:
            pattern:   ^/api/v1
            stateless: true
            anonymous: false
            provider: api_user_provider
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator
        main:
            anonymous: true

            # activate different ways to authenticate

            # http_basic: true
            # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate

            form_login:
                check_path: login
            guard:
                authenticators:
                    - App\Security\LoginFormAuthenticator
            # https://symfony.com/doc/current/security/form_login_setup.html
            remember_me:
                secret:   '%kernel.secret%'
                lifetime: 604800 # 1 week in seconds
                path:     /
            logout:
                path: /logout
                target: /
            # access_denied_handler: App\Security\AccessDeniedHandler
    access_control:
        - { path: ^/api/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        # - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        # - { path: ^/api/register, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        # - { path: ^/api/v1,       roles: IS_AUTHENTICATED_FULLY }
        - { path: ^/admin,        roles: ROLE_ADMIN }