security:
    encoders:
        App\Entity\AdminUser:
            algorithm: auto
        #App\Entity\VendeurUser:
            #algorithm: auto

    # 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)
        admin_users:
            entity:
                class: App\Entity\AdminUser
                property: email
        vendeur_users:
            entity:
                class: App\Entity\VendeurUser
                property: codePin
        all_users:
            chain:
                providers: [ 'admin_users', 'vendeur_users' ]

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        admin_secured_domain:
            pattern: ^/admin
            provider: admin_users
            anonymous: true
            guard:
                authenticators:
                    - App\Security\AdminLoginAuthenticator
            #user_checker: App\Security\UserChecker
            form_login:
                check_path: security_login_admin
                login_path: security_login_admin
                # csrf token options
                csrf_parameter: _csrf_token
                csrf_token_id: authenticate
                csrf_token_generator: security.csrf.token_manager
            #remember_me:
                #secret:   '%kernel.secret%'
                #lifetime: 604800 # 1 week in seconds
                #path:     /
        vendeur_secured_domain:
            pattern: ^/vendeur
            provider: vendeur_users
            anonymous: true
            guard:
                authenticators:
                    - App\Security\VendeurLoginAuthenticator
            #user_checker: App\Security\UserChecker
            form_login:
                check_path: security_login_vendeur
                login_path: security_login_vendeur
                # csrf token options
                csrf_parameter: _csrf_token
                csrf_token_id: authenticate
                csrf_token_generator: security.csrf.token_manager
            #remember_me:
                #secret:   '%kernel.secret%'
                #lifetime: 604800 # 1 week in seconds
                #path:     /

            # activate different ways to authenticate
            # https://symfony.com/doc/current/security.html#firewalls-authentication

            # https://symfony.com/doc/current/security/impersonating_user.html
            #switch_user: true
        main:
            pattern: ^/
            anonymous: ~
            logout:
                path:   security_logout
                target: /
                invalidate_session: true

    role_hierarchy:
        ROLE_VENDEUR:
            - ROLE_VENDEUR
        ROLE_ADMIN:
            - ROLE_ADMIN
        ROLE_SUPER_ADMIN:
            - ROLE_ADMIN

    # 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: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        - { path: ^/vendeur/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        - { path: ^/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        - { path: ^/vendeur, roles: ROLE_VENDEUR, requires_channel: https }
        - { path: ^/admin, roles: ROLE_ADMIN, requires_channel: https }
