security:
    encoders:
        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

        registration:
            pattern: ^/api/users
            stateless: true
            anonymous: true
            methods: [POST]

        login:
            pattern:  ^/api/login
            stateless: true
            anonymous: true
            json_login:
                check_path:               /api/login_check
                success_handler:          lexik_jwt_authentication.handler.authentication_success
                failure_handler:          lexik_jwt_authentication.handler.authentication_failure

        api:
            pattern:   ^/api
            stateless: true
            anonymous: true
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator
            
        main:
            anonymous: true
            lazy: true
            provider: app_user_provider

            # 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: ^/admin, roles: ROLE_ADMIN }
        - { path: ^/api/animations, roles: IS_AUTHENTICATED_ANONYMOUSLY, methods: [GET] }
        - { path: ^/api/animations, roles: ROLE_ADMIN, methods: [POST, PUT, DELETE] }
        - { path: ^/api/categories, roles: IS_AUTHENTICATED_ANONYMOUSLY, methods: [GET] }
        - { path: ^/api/categories, roles: ROLE_ADMIN, methods: [POST, PUT, DELETE] }
        - { path: ^/api/events, roles: IS_AUTHENTICATED_ANONYMOUSLY, methods: [GET] }
        - { path: ^/api/events, roles: ROLE_ADMIN, methods: [POST, PUT, DELETE] }
        - { path: ^/api/exhibitors, roles: IS_AUTHENTICATED_ANONYMOUSLY, methods: [GET] }
        - { path: ^/api/exhibitors, roles: ROLE_ADMIN, methods: [POST, PUT, DELETE] }
        - { path: ^/api/speakers, roles: IS_AUTHENTICATED_ANONYMOUSLY, methods: [GET] }
        - { path: ^/api/speakers, roles: ROLE_ADMIN, methods: [POST, PUT, DELETE] }
        - { path: ^/api/sponsors, roles: IS_AUTHENTICATED_ANONYMOUSLY, methods: [GET] }
        - { path: ^/api/sponsors, roles: ROLE_ADMIN, methods: [POST, PUT, DELETE] }
        - { path: ^/api/talks, roles: IS_AUTHENTICATED_ANONYMOUSLY, methods: [GET] }
        - { path: ^/api/talks, roles: ROLE_ADMIN, methods: [POST, PUT, DELETE] }
        - { path: ^/api/users, roles: IS_AUTHENTICATED_FULLY, methods: [GET, DELETE] }
        # - { path: ^/profile, roles: ROLE_USER }
