security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    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_email
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        oauth_token:
            pattern: ^/oauth/v2/token
            security: false
        # Add this firewall only in the Authorization code flow
        oauth_authorize:
            pattern: ^/oauth/v2/auth
            anonymous: true

        api_doc:
            pattern: ^/api/doc
            fos_oauth: false
            stateless: true
            anonymous: true

        api:
            pattern: ^/api
            fos_oauth: true
            stateless: true
            anonymous: false

        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                login_path: fos_user_security_login
                check_path: fos_user_security_check
                default_target_path: home
                csrf_token_generator: security.csrf.token_manager
            logout:
              path: fos_user_security_logout
            anonymous: true
            fos_oauth: false


    # Easy way to control access for large sections of your site
    # Note: Only the *first* access control that matches will be used
    access_control:
        - { path: ^/fe/caj/diarias/crea-cajas/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/ut/facturas/autorizacion/cron/ , roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/oauth/v2/auth_login$, role: IS_AUTHENTICATED_ANONYMOUSLY } # Add this only in the Authorization code flow
        - { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
        - { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/users/user-existe/ , roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/palets/^ , roles: IS_AUTHENTICATED_ANONYMOUSLY }
        #- { path: ^/, roles: ROLE_USER }
