security:
    # https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
#    password_hashers:
#        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
    # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
#    providers:
#        users_in_memory: { memory: null }
    enable_authenticator_manager: true
    role_hierarchy:  
        

            
            
        ROLE_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH,ROLE_HOD,ROLE_ACCOUNTS,ROLE_CLAIMS_APPROVERS,ROLE_DEAN,ROLE_SCHOOL_ADMINISTRATOR,ROLE_COORDINATOR,ROLE_NORMAL_USER]
        
        
        ROLE_LIBRARY_STAFF: [ROLE_USER, ROLE_ADMIN_EXAM_PAPER_CREATE, ROLE_ADMIN_EXAM_PAPER_EDIT,ROLE_ADMIN]
        ROLE_LIBRARY_DIRECTOR: [ROLE_LIBRARY_STAFF, ROLE_ADMIN_EXAM_PAPER_EXPORT, ROLE_ADMIN_EXAM_PAPER_DELETE,ROLE_ADMIN]
        ROLE_IT_ADMIN: [ROLE_ADMIN,ROLE_LIBRARY_DIRECTOR, ROLE_SONATA_ADMIN, ROLE_SUPER_ADMIN]


    password_hashers:
        Sonata\UserBundle\Model\UserInterface: auto
#        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
        App\Entity\User:
            algorithm: auto

    providers:
        sonata_user_bundle:
            id: sonata.user.security.user_provider
        # 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:
#            lazy: true
#            provider: app_user_provider
#            form_login:
            
        admin:
            lazy: true
            switch_user: true
            pattern: /admin(.*)
            provider: sonata_user_bundle
            context: user
            
            form_login:
                login_path: sonata_user_admin_security_login
                check_path: sonata_user_admin_security_check
#                default_target_path: 
                default_target_path: app_past_questions_index
            logout:
#                path: sonata_user_admin_security_logout
                target: sonata_user_admin_security_login
                path:   /admin/logout

            remember_me:
                secret: '%env(APP_SECRET)%'
                lifetime: 2629746
                path: /admin
                
 # The main firewall for the regular user area
        main:
            pattern: ^/
            context: user
            form_login:
                provider: sonata_user_bundle
                login_path: /admin/login
                check_path: sonata_user_admin_security_check
                default_target_path: app_past_questions_index
            logout:
                path: /logout
                target: /admin/login
#            anonymous: true          
            
            
    access_control:
        # Admin login page needs to be accessed without credential
        - { path: ^/admin/login$, role: PUBLIC_ACCESS }
        - { path: ^/admin/logout$, role: PUBLIC_ACCESS }
        - { path: ^/admin/login_check$, role: PUBLIC_ACCESS }
        - { path: ^/admin/request$, role: PUBLIC_ACCESS }
        - { path: ^/admin/check-email$, role: PUBLIC_ACCESS }
        - { path: ^/admin/reset/.*$, role: PUBLIC_ACCESS }

        # Secured part of the site
        # This config requires being logged for the whole site and having the admin role for the admin part.
        # Change these rules to adapt them to your needs
        - { path: ^/admin/, role: ROLE_ADMIN }
        - { path: ^/profile/, role: ROLE_USER }
        - { path: ^/.*, role: PUBLIC_ACCESS }


        # Access control for the regular user area
        - { path: ^/login$, role: PUBLIC_ACCESS }
        - { path: ^/register$, role: PUBLIC_ACCESS }
        - { path: ^/logout$, role: PUBLIC_ACCESS }
        - { path: ^/profile, role: ROLE_USER }
        - { path: ^/dashboard, role: ROLE_USER }
            # activate different ways to authenticate
            # https://symfony.com/doc/current/security.html#the-firewall

            # 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: ^/admin, roles: ROLE_ADMIN }
        # - { path: ^/profile, roles: ROLE_USER }

when@test:
    security:
        password_hashers:
            # By default, password hashers are resource intensive and take time. This is
            # important to generate secure password hashes. In tests however, secure hashes
            # are not important, waste resources and increase test times. The following
            # reduces the work factor to the lowest possible values.
            Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
                algorithm: auto
                cost: 4 # Lowest possible value for bcrypt
                time_cost: 3 # Lowest possible value for argon
                memory_cost: 10 # Lowest possible value for argon
