security:
    # https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
    password_hashers:
        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
    role_hierarchy:
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_COMMERCIAL, ROLE_COMPANY_ADMIN, ROLE_PROJECT_MANAGER, ROLE_PROJECT_USER, ROLE_BILLING, ROLE_ACCOUNTING, ROLE_ROUTINE_MANAGER, ROLE_COMMUNICATION_MANAGER, ROLE_COMMUNICATION_EDITOR, ROLE_COMMUNICATION_REVIEWER, ROLE_GENERATION_MANAGER, ROLE_USER]
        ROLE_ADMIN: [ROLE_COMMERCIAL, ROLE_PROSPECTION, ROLE_COMPANY_ADMIN, ROLE_PROJECT_MANAGER, ROLE_PROJECT_USER, ROLE_BILLING, ROLE_ACCOUNTING, ROLE_ROUTINE_MANAGER, ROLE_COMMUNICATION_MANAGER, ROLE_COMMUNICATION_EDITOR, ROLE_COMMUNICATION_REVIEWER, ROLE_GENERATION_MANAGER, ROLE_USER]
        ROLE_COMPANY_ADMIN: [ROLE_COMMERCIAL, ROLE_PROSPECTION, ROLE_PROJECT_MANAGER, ROLE_PROJECT_USER, ROLE_BILLING, ROLE_ACCOUNTING, ROLE_ROUTINE_MANAGER, ROLE_COMMUNICATION_MANAGER, ROLE_COMMUNICATION_EDITOR, ROLE_COMMUNICATION_REVIEWER, ROLE_GENERATION_MANAGER, ROLE_USER]
        ROLE_GENERATION_MANAGER: [ROLE_GENERATION_USER, ROLE_USER]
        ROLE_GENERATION_USER: [ROLE_USER]
        ROLE_COMMUNICATION_MANAGER: [ROLE_COMMUNICATION_EDITOR, ROLE_COMMUNICATION_REVIEWER, ROLE_USER]
        ROLE_COMMUNICATION_EDITOR: [ROLE_USER]
        ROLE_COMMUNICATION_REVIEWER: [ROLE_USER]
        ROLE_ROUTINE_MANAGER: [ROLE_USER]
        ROLE_PROSPECTION: [ROLE_USER]
        ROLE_PROJECT_MANAGER: [ROLE_PROJECT_USER, ROLE_USER]
        ROLE_MANAGER: [ROLE_COMMERCIAL, ROLE_USER]
        ROLE_COMMERCIAL_READONLY: [ROLE_USER]
    # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
    providers:
        app_user_provider:
            entity:
                class: App\Bundle\AdminBundle\Entity\User
                property: email
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            lazy: true
            provider: app_user_provider
            form_login:
                login_path: app_login
                check_path: app_login
                enable_csrf: true
                success_handler: App\Bundles\AppBundle\Security\LoginSuccessHandler
            logout:
                path: app_logout

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

            # https://symfony.com/doc/current/security/impersonating_user.html
            # switch_user: true

    # 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: ^/login, roles: PUBLIC_ACCESS }
        - { path: ^/webhooks/google/calendar, roles: PUBLIC_ACCESS }
        - { path: ^/calendar, roles: ROLE_USER }
        - { path: ^/billing, roles: ROLE_BILLING }
        - { path: ^/projets, roles: ROLE_PROJECT_USER }
        - { path: ^/commercial/calendar, roles: ROLE_USER }
        - { path: ^/commercial, roles: [ROLE_COMMERCIAL, ROLE_COMMERCIAL_READONLY] }
        - { path: ^/prospection, roles: [ROLE_PROSPECTION, ROLE_COMMERCIAL] }
        - { path: ^/routine, roles: ROLE_USER }
        - { path: ^/communication, roles: [ROLE_COMMUNICATION_MANAGER, ROLE_COMMUNICATION_EDITOR, ROLE_COMMUNICATION_REVIEWER] }
        - { path: ^/generation, roles: ROLE_USER }
        - { path: ^/societe, roles: ROLE_USER }
        - { path: ^/salaires, roles: ROLE_USER }
        - { path: ^/admin, roles: ROLE_COMPANY_ADMIN }
        # - { path: ^/admin, roles: ROLE_ADMIN }
        # - { path: ^/profile, roles: ROLE_USER }

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
