security:
    role_hierarchy:
        ROLE_AGENT: ROLE_AGENT
        ROLE_ADMIN: [ROLE_AGENT, ROLE_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_SUPER_ADMIN]
        ROLE_CUSTOMER: ROLE_CUSTOMER
    
    encoders:
        Webkul\UVDesk\CoreFrameworkBundle\Entity\User: auto
    
    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        user_provider:
            id: user.provider

        api_user_provider:
            id: Webkul\UVDesk\ApiBundle\Providers\ApiCredentials
    
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

            # 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
        
        back_support:
            pattern: /%uvdesk_site_path.member_prefix%
            provider: user_provider
            anonymous: ~
            form_login:
                use_referer: true
                login_path: helpdesk_member_handle_login
                check_path: helpdesk_member_handle_login
                default_target_path: helpdesk_member_dashboard
                always_use_default_target_path: true
            logout:
                path: helpdesk_member_handle_logout
                target: helpdesk_member_handle_login
            remember_me:
                secret: '%kernel.secret%'
                lifetime: 604800       # 7 days
                path: /
                name: REMEMBERME
                remember_me_parameter: _remember_me
        
        uvdesk_api:
            pattern: ^/api
            anonymous: true
            provider: api_user_provider
            guard:
                authenticators:
                    Webkul\UVDesk\ApiBundle\Security\Guards\APIGuard: Webkul\UVDesk\ApiBundle\Security\Guards\APIGuard
        
        customer:
            pattern: /
            provider: user_provider
            anonymous: ~
            form_login:
                use_referer: true
                login_path: helpdesk_customer_login
                check_path: helpdesk_customer_login
                default_target_path: helpdesk_customer_ticket_collection
                always_use_default_target_path: true
            logout:
                path: helpdesk_customer_logout
                target: helpdesk_customer_login
    
    access_control:
        - { path: /%uvdesk_site_path.member_prefix%/login, roles: [IS_AUTHENTICATED_REMEMBERED, IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: /%uvdesk_site_path.member_prefix%/create-account, roles: [IS_AUTHENTICATED_REMEMBERED, IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: /%uvdesk_site_path.member_prefix%/forgot-password, roles: [IS_AUTHENTICATED_REMEMBERED,IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: /%uvdesk_site_path.member_prefix%/update-credentials, roles: [IS_AUTHENTICATED_REMEMBERED,IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: /%uvdesk_site_path.member_prefix%/mailbox/listener, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: /%uvdesk_site_path.member_prefix%/, roles: ROLE_AGENT }
        - { path: /%uvdesk_site_path.knowledgebase_customer_prefix%/login, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: /%uvdesk_site_path.knowledgebase_customer_prefix%/create-ticket, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: /%uvdesk_site_path.knowledgebase_customer_prefix%/forgot-password, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: /%uvdesk_site_path.knowledgebase_customer_prefix%/update-credentials, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
        - { path: /%uvdesk_site_path.knowledgebase_customer_prefix%/ticket/intermediate/public-access/read-only, roles: [IS_AUTHENTICATED_REMEMBERED, IS_AUTHENTICATED_ANONYMOUSLY, ROLE_CUSTOMER_READ_ONLY]  }
        - { path: /%uvdesk_site_path.knowledgebase_customer_prefix%/ticket/view, roles: [ROLE_CUSTOMER, ROLE_CUSTOMER_READ_ONLY] }
        - { path: /%uvdesk_site_path.knowledgebase_customer_prefix%/, roles: [ROLE_CUSTOMER] }
