security:
    encoders:
#        Symfony\Component\Security\Core\User\User: plaintext
        Symfony\Component\Security\Core\User\User: 
            algorithm:   sha512
            iterations: 1
            encode_as_base64: true
        FOS\UserBundle\Model\UserInterface:
            algorithm: sha512
            encode_as_base64: false
            iterations: 1  
        Application\Sonata\UserBundle\Entity\User: sha512
#        Amel\UserBundle\Entity\User: sha512
        
    role_hierarchy:
        ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
        SONATA:
            - ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT  # if you are using acl then this line must be commented

    providers:
        fos_userbundle:
            id: fos_user.user_manager

    firewalls:
        # Disabling the security for the web debug toolbar, the profiler and Assetic.
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        # -> custom firewall for the admin area of the URL
        admin:
            pattern:            /admin(.*)
            context:            user
            form_login:
                provider:       fos_userbundle
                login_path:     /admin/login
                use_forward:    true
                check_path:     /admin/login_check
                failure_path:   null
            logout:
                path:           /admin/logout
            anonymous:          true

        # -> end custom configuration

        # default login area for standard users

        # This firewall is used to handle the public login area
        # This part is handled by the FOS User Bundle
        main:
            pattern:             .*
            context:             user
            form_login:
                provider:       fos_userbundle
                login_path:     /login
                use_forward:    false
                check_path:     /login_check
                success_handler: mql_player.component.authentication.handler.login_success_handler
#                success_handler: mql_player.component.authentication_handler
#                failure_handler: mql_player.component.authentication_handler
                
                failure_path:   null
            logout:             true
            anonymous:          true
            
            
    access_control:
            # URL of FOSUserBundle which need to be available to anonymous users
            - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/user/app-login, role: IS_AUTHENTICATED_ANONYMOUSLY }
            
            #integracion con los juegos
#            - { path: ^/game/get/*, role: IS_AUTHENTICATED_ANONYMOUSLY }
#            - { path: ^/game/post/*, role: IS_AUTHENTICATED_ANONYMOUSLY }
#            - { path: ^/game/level/get/*, role: IS_AUTHENTICATED_ANONYMOUSLY }
#            - { path: ^/game/level/post/*, role: IS_AUTHENTICATED_ANONYMOUSLY }

            # Admin login page needs to be access without credential
            - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }

            # Secured part of the site
            # This config requires being logged for the whole site and having the admin role for the admin part.
            # Change these rules to adapt them to your needs
            - { path: ^/backend/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
#            - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/.*, role: [ROLE_USER, ROLE_ADMIN, ROLE_SONATA_ADMIN]  }