security:
    password_hashers:
        App\Entity\User:
            algorithm: auto

    role_hierarchy:
        ROLE_USER: ROLE_USER
        ROLE_ADMIN: ROLE_ADMIN
        ROLE_SUPER_ADMIN: [ROLE_ALLOWED_TO_SWITCH]

    # 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
        main:
            entry_point: App\Security\AuthenticationEntryPoint
            anonymous: lazy
            provider: app_user_provider
            user_checker: App\Security\UserChecker
            guard:
                authenticators:
                    - app.security.login_form_authenticator

            remember_me:
                secret: '%kernel.secret%'
                name: REMEMBERME
                lifetime: 604800 # 1 week in seconds
                path: /
                samesite: 'lax'
                httponly: true
                secure: true
                always_remember_me: false
                remember_me_parameter: '_remember_me'
                token_provider: 'Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider'

            logout:
                path: security_logout
                target: security_login

            access_denied_handler: App\Security\AccessDeniedHandler
            access_denied_url: security_login

            # 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_SHEME)%' }
        - { path: ^/admin/, roles: [IS_AUTHENTICATED_FULLY, IS_AUTHENTICATED_REMEMBERED, ROLE_ADMIN, ROLE_SUPER_ADMIN], requires_channel: '%env(SECURE_SHEME)%' }
