security:
    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    firewalls:
        uidentify_secured:
            pattern:   /api/v[0-9]/.*
            stateless: true
            uidentify: true
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                login_path: /user/login
                check_path: /user/login_check
                default_target_path: _admin_backend_index
                always_use_default_target_path: true
                csrf_token_generator: security.csrf.token_manager
            logout:
                path: fos_user_security_logout
                target: _admin_backend_index
            anonymous: true
        
    access_control:
        # URL of FOSUserBundle which need to be available to anonymous users
        - { path: ^/_(wdt|profiler), role: IS_AUTHENTICATED_ANONYMOUSLY, allow_if: "'127.0.0.1' == request.getClientIp() or 'fe80::1' == request.getClientIp() or '::1' == request.getClientIp()" }
        - { path: ^/_(wdt|profiler), role: ROLE_SUPER_ADMIN }
       # - { path: ^/doc, roles: ROLE_SUPER_ADMIN, allow_if: "has_role('ROLE_SUPER_ADMIN')" }
        - { path: ^/user/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user/logout, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: ROLE_ADMIN }
        - { path: ^/resetting, role: ROLE_ADMIN }
    role_hierarchy:
        ROLE_ADMIN:         ROLE_USER
        ROLE_APP_ADMIN:     ROLE_ADMIN
        ROLE_USER_ADMIN:    ROLE_ADMIN
        ROLE_SERVICE_ADMIN: ROLE_ADMIN
        ROLE_API: ROLE_ADMIN
        ROLE_SUPER_ADMIN:  [ROLE_SERVICE_ADMIN,ROLE_USER_ADMIN,ROLE_API]
