# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512
        UserBundle\Entity\User:
            algorithm: sha512
    role_hierarchy:
        ROLE_BACKEND: ROLE_DASHBOARD, ROLE_DAF, ROLE_SELF, ROLE_FCMS_KELJOB, ROLE_FCMS_CADREMPLOI, ROLE_FCMS_INSIDERS, ROLE_PPA_PUBLISHERS, ROLE_ORGANIC_PUBLISHERS, ROLE_DAF_JOB_MANAGE, ROLE_ANALYTICS
        ROLE_SUPER_ADMIN: ROLE_BACKEND
    providers:
#        chain_provider:
#            chain:
#              providers: [fos_userbundle]
#
#        fos_userbundle:
#            id: fos_user.user_provider.username

        dashboard_users:
            entity:
                class: UserBundle\Entity\User
                property: username

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            pattern: ^/
            user_checker: UserBundle\Security\UserChecker
            form_login:
                provider: dashboard_users
                csrf_token_generator: security.csrf.token_manager
                login_path: app_login
                check_path: app_login
                default_target_path: redirectIndex
                use_referer: true
            logout:
                path: /logout
                target: app_login
            anonymous: true
            logout_on_user_change: true
            remember_me:
                secret: '%secret%'
                lifetime: 259200
                path: /
            provider: dashboard_users
            guard:
                authenticators:
                    - UserBundle\Security\LoginFormAuthenticator

    access_denied_url: /
    access_control:
        - { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register/recover-password, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/forgot, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/conditions-generales-wan2bee, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/send-email, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/check-email, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/ats/download-shared/, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/AdsOverview|^/StatisticsReport|^/ConversionsReport|^/ContextsReport, roles: ROLE_DASHBOARD }
        - { path: ^/portal, allow_if: "has_role('ROLE_DAF') and has_role('ROLE_SELF')" }
        - { path: /ats/advertiser/edit|/ats/advertiser/\d+/form/\d+/offers|^/ajax/ats/offers, roles: ROLE_DAF_JOB_MANAGE }
        - { path: /ats/overview, roles: [ROLE_DAF, ROLE_ANALYTICS] }
        - { path: ^/ats/advertiser/\d+/roi/|^/ajax/ats/roi/, roles: ROLE_ANALYTICS }
        - { path: /ats/advertiser/\d+/form/\d+/settings, roles: ROLE_DAF }
        - { path: /ats/advertiser/\d+/form/\d+/|/ajax/ats/advertiser/.*/statistics$|/ajax/ats/applies/instance|/ajax/daf/apply/(doc|pdf|one)$|/ajax/daf/qualif/applies|/ajax/ats/jobs?/applies|^/self/test/pdf/|/ajax/daf/check/new, roles: [ROLE_DAF, ROLE_SAAS] }
        - { path: ^/self/daf|^/ajax/daf|^/ats|^/ajax/ats, roles: ROLE_DAF }
        - { path: ^/self/overview|^/self/advertiser|^/ajax/self/advertisers|^/ajax/delete|^/self/test, roles: [ROLE_DAF, ROLE_SELF] }
        - { path: ^/self|^/ajax/self, roles: ROLE_SELF }
        - { path: ^/, roles: [ROLE_DASHBOARD, ROLE_DAF, ROLE_SELF, ROLE_SAAS, ROLE_ANALYTICS] }
