security:
    encoders:
            FOS\UserBundle\Model\UserInterface: bcrypt
            App\Entity\User:
                algorithm: sha512

    role_hierarchy:
            ROLE_ADMIN:       ROLE_USER
            ROLE_SUPER_ADMIN: ROLE_ADMIN

    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        login_api:
            pattern: ^/api/security/login
            stateless: true
            anonymous: true
            form_login:
                check_path:               /api/security/login_check
                success_handler:          lexik_jwt_authentication.handler.authentication_success
                failure_handler:          lexik_jwt_authentication.handler.authentication_failure
                require_previous_session: false
        api:
            pattern: ^/api/v1
            stateless: true
            anonymous: false
            provider: fos_userbundle
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_token_generator: security.csrf.token_manager
                default_target_path: dashboard_index

            logout:       true
            anonymous:    true
#####PRECAUCIÓN: Cuando se vaya a exceptuar de autenticación alguna ruta, recordar que también se tiene que exceptuar en el Event Listener "SecurityControl"
    access_control:
        - { path: ^/api/security/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/v1,       roles: IS_AUTHENTICATED_FULLY }
        - { path: ^/import/process-amazon-mws, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/invoice/generate-invoices, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        #- { path: ^/admin/, role: ROLE_ADMIN } con la documentación está así
        - { path: ^/, role: ROLE_USER }
            # activate different ways to authenticate

            # http_basic: ~
            # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate

            # form_login: ~
            # https://symfony.com/doc/current/security/form_login_setup.html
