security:
    # https://symfony.com/doc/current/security/experimental_authenticators.html
    enable_authenticator_manager: true
    password_hashers:
        App\Entity\User:
            algorithm: auto

    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        # used to reload user from session & other features (e.g. switch_user)
        app_user_provider:
            entity:
                class: App\Entity\User
                property: email
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        api:
            lazy: true
            stateless: true # Authentification demandée à chaque requête
            pattern: ^/api/
            custom_authenticators:
                - App\Security\TokenAuthenticator
        main:
            login_throttling:
                max_attempts: 3
                interval: '15 minutes'
            form_login:
                login_path: app_login
                check_path: app_login
                failure_path: app_login
            custom_authenticators:
                - App\Security\LoginFormAuthenticator
            entry_point: App\Security\LoginFormAuthenticator
            logout:
                path: app_logout

            # 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: /login, roles: IS_AUTHENTICATED_ANONYMOUSLY  }
        - { path: ^/admin/question/create, roles: [ ROLE_MODERATOR, ROLE_ADMIN, ROLE_SUPER_ADMIN ], requires_channel: '%router.request_context.scheme%' }
        - { path: ^/admin/question/edit, roles: [ ROLE_MODERATOR, ROLE_ADMIN, ROLE_SUPER_ADMIN ], requires_channel: '%router.request_context.scheme%' }
        - { path: ^/admin/question/tomoderate, roles: [ ROLE_MODERATOR, ROLE_ADMIN, ROLE_SUPER_ADMIN ], requires_channel: '%router.request_context.scheme%' }
        - { path: ^/admin/question/tocomplete, roles: [ ROLE_MODERATOR, ROLE_ADMIN, ROLE_SUPER_ADMIN ], requires_channel: '%router.request_context.scheme%' }
        - { path: ^/admin/question/moderate, roles: [ ROLE_MODERATOR, ROLE_ADMIN, ROLE_SUPER_ADMIN ], requires_channel: '%router.request_context.scheme%' }
        - { path: ^/admin/contestation, roles: [ ROLE_MODERATOR, ROLE_ADMIN, ROLE_SUPER_ADMIN ], requires_channel: '%router.request_context.scheme%' }
        - { path: ^/admin, roles: [ ROLE_ADMIN, ROLE_SUPER_ADMIN ], requires_channel: '%router.request_context.scheme%' }
        - { path: ^/api/forgot_password$, roles: PUBLIC_ACCESS, requires_channel: '%router.request_context.scheme%' }
        - { path: ^/api/signup$, roles: PUBLIC_ACCESS, requires_channel: '%router.request_context.scheme%' }
        - { path: ^/api/login$, roles: PUBLIC_ACCESS, requires_channel: '%router.request_context.scheme%' }
        - { path: ^/api/cron/weekly_reset, roles: PUBLIC_ACCESS, requires_channel: '%router.request_context.scheme%' }
        - { path: ^/api/cron/hourly_close_quiz, roles: PUBLIC_ACCESS, requires_channel: '%router.request_context.scheme%' }
        - { path: ^/api/cron/reset_password, roles: PUBLIC_ACCESS, requires_channel: '%router.request_context.scheme%' }
        - { path: ^/api/cron/proceed_notification, roles: PUBLIC_ACCESS, requires_channel: '%router.request_context.scheme%' }

    role_hierarchy:
        ROLE_SUPER_ADMIN: ROLE_ADMIN
        ROLE_ADMIN: ROLE_MODERATOR
        ROLE_MODERATOR: ROLE_USER
