# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:
    encoders:
        Emgmbh\UserBundle\Entity\User:
            id: Emgmbh\UserBundle\Service\KohanaEncoder

    role_hierarchy:
        ROLE_ADMIN:  ROLE_MANAGER
        ROLE_MANAGER:  ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_ADMIN]

    # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
    providers:
        db:
            entity:
                class: Emgmbh\UserBundle\Entity\User

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

        api_login:
            pattern:  ^/api/login
            stateless: true
            anonymous: true
            form_login:
                login_path:               /api/login
                check_path:               /api/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/
            stateless: true
            lexik_jwt: ~

        admin:
            pattern:    ^/(en|de)/admin
            anonymous: ~
            form_login:
                provider: db
                login_path: user_login
                check_path: user_login_check
            logout:
                path: user_logout
                target: user_login

    access_control:
        - { path: ^/(en|de)/admin/(login|login_check|logout)$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/(en|de)/admin, roles: IS_AUTHENTICATED_FULLY }
        - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
