security:
    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        #in_memory: { memory: ~ }
        from_admin_database:
            entity:
                class: App\Entity\Admin\Admin
                manager_name: admin
                #property: username
        from_company:
            entity:
                #class: App\Entity\Main\User
                class: App\Entity\Main\Company
                #property: email

        from_collaborator:
            entity:
                class: App\Entity\Main\User

        from_default_database:
            chain:
                providers: [from_company, from_collaborator]

        #from_all:
            #chain:
                #providers: [from_admin_database, from_default_database]

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        admin_secured_area:
            pattern:   ^/admin
            user_checker: App\Security\AdminChecker
            anonymous: true
            provider: from_admin_database

            form_login:
                login_path: /admin/login
                check_path: /admin/login
                default_target_path: /admin/actives-companies
                always_use_default_target_path: true

            logout:
                path: /logout
                target: /admin

            #guard:
                #authenticators:
                    #- 'App\Security\LoginFormAuthenticator'

        main:
            pattern:   ^/
            #user_checker: App\Security\UserChecker
            anonymous: true
            provider: from_default_database
            switch_user: ~

            # activate different ways to authenticate

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

            #form_login: true

            form_login:
                login_path: login
                check_path: login
                default_target_path: /usagers

            # https://symfony.com/doc/current/security/form_login_setup.html

            logout:
                path: /logout
                target: /

            guard:
                authenticators:
                    - App\Security\LoginFormAuthenticator


    role_hierarchy:
        ROLE_ADMIN: ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

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

        - { path: ^/account, roles: ROLE_USER }

    encoders:
        App\Entity\Main\User:
            algorithm: bcrypt
            cost: 13

        App\Entity\Admin\Admin:
            algorithm: bcrypt
            cost: 13
