# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:

    # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
    providers:
        in_memory:
            memory:
                users:
                    admin:
                        password: 123
                        roles: ['ROLE_TELECENTRO_ADMIN']
        users:
            entity:
                class: TelecentroBundle\Entity\Usuario\Usuario
                property: apelido
        all_users:
            chain:
                providers: [in_memory,users]
        from_totus:
            id: telecentro.security.user_from_totus_provider

    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        Util\Entity\BaseEntityUser: bcrypt

    role_hierarchy:
        ROLE_TELECENTRO_USER:
            - ROLE_TELECENTRO
        ROLE_TELECENTRO_USER_IMPORTADO:
            - ROLE_TELECENTRO_USER
        ROLE_TELECENTRO_ADMIN:
            - ROLE_TELECENTRO
        ROLE_ACN_ADMIN:
            - ROLE_TELECENTRO_ADMIN

    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        api:
            pattern: /api/
            security: false

        user:
            pattern: ^/user
            anonymous: ~
            provider: from_totus
            simple_form:
                authenticator: telecentro.security.user_from_totus_authenticator
                use_referer: true
                login_path: telecentro.user.login
                check_path: telecentro.user.login
                failure_path: telecentro.user.login
                default_target_path: telecentro.user.home
                always_use_default_target_path: true
                username_parameter: 'user_login[login]'
                password_parameter: 'user_login[senha]'
            logout:
                invalidate_session: true
                path:   telecentro.user.logout
                target: telecentro.user.login

        telecentro:
            pattern: ^/admin
            anonymous: ~
            provider: in_memory
            form_login:
                use_referer: true
                login_path: telecentro.admin.login
                check_path: telecentro.admin.login
                failure_path: telecentro.admin.login
                default_target_path: telecentro.admin.home
                username_parameter: 'admin_login[login]'
                password_parameter: 'admin_login[senha]'
            logout:
                invalidate_session: true
                path:   telecentro.admin.logout
                target: telecentro.admin.login
            remember_me:
                remember_me_parameter: 'admin_login[lembrar]'
                secret:   '%secret%'
                lifetime: 86400
                path:     /

    access_control:
       - { path: ^/user/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/user/signup, roles: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/sim, roles: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/admin, roles: ROLE_TELECENTRO_ADMIN }
       - { path: ^/user, roles: ROLE_TELECENTRO_USER }
