security:
    encoders:
        App\Entity\User:
            algorithm: auto
        token:
            algorithm: auto
        Symfony\Component\Security\Core\User\User:
            algorithm: plaintext

    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        chain_provider:
            chain:
                providers: [in_memory, app_user_provider]
        # used to reload user from session & other features (e.g. switch_user)
        app_user_provider:
            entity:
                class: App\Entity\User
                property: email
        in_memory:
            memory:
                users:
                    observer@min.com: {password: 7ppdV46E, roles: ['ROLE_OBSERVER']}
                    #7ppdV46E
        client_api_user_provider:
            memory:
                users:
                    client: {roles: ['ROLE_ADMIN']}

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        login:
            pattern: ^/api/v1/auth/login$
            stateless: true
            anonymous: true
            json_login:
                provider: chain_provider
                check_path: /api/v1/auth/login
                success_handler: lexik_jwt_authentication.handler.authentication_success
                failure_handler: lexik_jwt_authentication.handler.authentication_failure
        api:
            pattern: ^/api/v1
            stateless: true
            provider: chain_provider
            guard:
                provider: chain_provider
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator
                    - App\Security\Guard\SaasAuthenticator
                    - App\Security\Guard\ForgotPasswordAuthenticator
                    - App\Security\Guard\ResetPasswordAuthenticator
                entry_point: lexik_jwt_authentication.jwt_token_authenticator
            logout:
                path: /api/v1/auth/logout
                target: landing
        api_client:
            pattern: ^/api/client/v1
            stateless: true
            provider: client_api_user_provider
            guard:
                provider: client_api_user_provider
                authenticators:
                    - App\Security\Guard\ApiKeyAuthenticator
        main:
            anonymous: true

            # activate different ways to authenticate
            # https://symfony.com/doc/current/security.html#firewalls-authentication

            # https://symfony.com/doc/current/security/impersonating_user.html
            # switch_user: true

    # 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: ^/,                   roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: '%env(SECURE_SCHEME)%' }
        - { path: ^/api/v1,             roles: IS_AUTHENTICATED_FULLY,       requires_channel: '%env(SECURE_SCHEME)%' }
        - { path: ^/api/v1/auth/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: '%env(SECURE_SCHEME)%' }
        - { path: ^/api/client/v1,             roles: IS_AUTHENTICATED_FULLY,       requires_channel: '%env(SECURE_SCHEME)%' }
        - { path: ^/api/client/v1/auth/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: '%env(SECURE_SCHEME)%' }
    role_hierarchy:
        ROLE_ADMIN:      [ROLE_USER]
        ROLE_SUPERADMIN: [ROLE_ADMIN]
        ROLE_ODSERVER: [ROLE_OBSERVER]
