security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email

    firewalls:
        main:
            remember_me:
                secret: '%kernel.secret%'
                lifetime: 8604800
                path: /
#                always_remember_me: true
            pattern:            /admin(.*)
            context:            user
            form_login:
                provider:       fos_userbundle
                login_path:     /admin/login
                use_forward:    false
                check_path:     /admin/login_check
                failure_path:   /admin
            logout:
                path:           /admin/logout
                target:         /admin/login
            anonymous:          true
        register:
            pattern:  ^/api/register
            stateless: true
            anonymous: true

        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


    access_control:

        # The WDT has to be allowed to anonymous users to avoid requiring the login with the AJAX request
        - { path: ^/wdt/, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/profiler/, role: IS_AUTHENTICATED_ANONYMOUSLY }

        - { path: ^/api/mobile-version-api, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/getallinstitution, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/get_institution_config, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/mobile-version-prod-api, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/mobile-version-prod-en-api, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/register, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/eleve_annee_scolaires22, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/getMobileLang, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api,       roles: IS_AUTHENTICATED_FULLY }

        # AsseticBundle paths used when using the controller for assets
        - { path: ^/js/, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/css/, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # URL of FOSUserBundle which need to be available to anonymous users
        - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }

        - { path: ^/admin/, role: ROLE_USER }
        - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

    # Sonata "special" roles (ROLE_SONATA_ADMIN and ROLE_SUPER_ADMIN) are configurable
    role_hierarchy:
        ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
        ROLE_DRIVER:
            - ROLE_ADMIN_DRIVER_LIST
            - ROLE_ADMIN_DRIVER_VIEW
            - ROLE_ADMIN_DRIVER_EDIT
            - ROLE_ADMIN_DRIVER_CREATE
            - ROLE_ADMIN_DRIVER_DELETE
            - ROLE_ADMIN_VOYAGE_LIST
            - ROLE_ADMIN_VOYAGE_VIEW
            - ROLE_ADMIN_VOYAGE_EDIT
            - ROLE_ADMIN_VOYAGE_CREATE
            - ROLE_ADMIN_VOYAGE_DELETE
            - ROLE_ADMIN_CIRCUIT_LIST
            - ROLE_ADMIN_CIRCUIT_VIEW
            - ROLE_ADMIN_VEHICULE_LIST
            - ROLE_ADMIN_VEHICULE_VIEW
            - ROLE_ADMIN_VOYAGE_ATTENDANCE_LIST
            - ROLE_ADMIN_VOYAGE_ATTENDANCE_DELETE
            - ROLE_ADMIN_VOYAGE_ATTENDANCE_EDIT
            - ROLE_USER
        ROLE_ELEVE:
#            - ROLE_SONATA_USER_ADMIN_USER_VIEW
            - ROLE_USER
            - ROLE_ADMIN_COURS_LIST
            - ROLE_ADMIN_HOMEWORK_LIST
            - ROLE_ADMIN_ELEVE_LIST_LIST
            - ROLE_ADMIN_CHAT_USER_LIST
            - ROLE_ADMIN_CHAT_USER_VIEW
            - ROLE_ADMIN_ANNONCE_LIST
            - ROLE_ADMIN_ANNONCE_VIEW
            - ROLE_ADMIN_CHAT_USER_CREATE
            - ROLE_ADMIN_COURS_LIST
            - ROLE_ADMIN_COURS_VIEW
            - ROLE_ADMIN_TP_LIST
            - ROLE_ADMIN_TP_VIEW
            - ROLE_ADMIN_BULLETIN_ELEVE_LIST
            - ROLE_ADMIN_COURS_EN_LIGNE_LIST
            - ROLE_ADMIN_REPAS_LIST
            - ROLE_ADMIN_REPAS_VIEW
            - ROLE_ADMIN_MENU_LIST
            - ROLE_ADMIN_MENU_VIEW
            - ROLE_ADMIN_MENU_CONTINE_LIST
            - ROLE_ADMIN_MENU_CONTINE_VIEW
            - ROLE_ADMIN_RECLAMATION_CONTINE_LIST
            - ROLE_ADMIN_RECLAMATION_CONTINE_VIEW
            - ROLE_ADMIN_NOTE_LIST

        ROLE_PARENT:
#            - ROLE_SONATA_USER_ADMIN_USER_VIEW
            - ROLE_USER
            - ROLE_ADMIN_COURS_LIST
            - ROLE_ADMIN_HOMEWORK_LIST
            - ROLE_ADMIN_ELEVE_LIST_LIST
            - ROLE_ADMIN_CHAT_USER_LIST
            - ROLE_ADMIN_CHAT_USER_VIEW
            - ROLE_ADMIN_ANNONCE_LIST
            - ROLE_ADMIN_ANNONCE_VIEW
            - ROLE_ADMIN_CHAT_USER_CREATE
            - ROLE_ADMIN_COURS_LIST
            - ROLE_ADMIN_COURS_VIEW
            - ROLE_ADMIN_TP_LIST
            - ROLE_ADMIN_TP_VIEW
            - ROLE_ADMIN_CLASSE_LIST
            - ROLE_ADMIN_CONVERSATION_HOMEWORK_LIST
            - ROLE_ADMIN_BULLETIN_ELEVE_LIST
            - ROLE_ADMIN_REPAS_LIST
            - ROLE_ADMIN_REPAS_VIEW
            - ROLE_ADMIN_MENU_LIST
            - ROLE_ADMIN_MENU_VIEW
            - ROLE_ADMIN_MENU_CONTINE_LIST
            - ROLE_ADMIN_MENU_CONTINE_VIEW
            - ROLE_ADMIN_RECLAMATION_CONTINE_LIST
            - ROLE_ADMIN_RECLAMATION_CONTINE_VIEW
            - ROLE_ADMIN_RECLAMATION_CONTINE_CREATE
            - ROLE_ADMIN_DEMANDE_PARENT_LIST
            - ROLE_ADMIN_DEMANDE_PARENT_CREATE
            - ROLE_ADMIN_NOTIFICATION_LIST
            - ROLE_ADMIN_NOTE_LIST

        ROLE_ENSEIGNANT:
#            - ROLE_SONATA_USER_ADMIN_USER_VIEW
            - ROLE_USER
            - ROLE_ADMIN_COURS_LIST
            - ROLE_ADMIN_COURS_EDIT
            - ROLE_ADMIN_COURS_DELETE
            - ROLE_ADMIN_COURS_CREATE
            - ROLE_ADMIN_HOMEWORK_LIST
            - ROLE_ADMIN_HOMEWORK_EDIT
            - ROLE_ADMIN_HOMEWORK_DELETE
            - ROLE_ADMIN_HOMEWORK_CREATE
            - ROLE_ADMIN_ELEVE_LIST_LIST
            - ROLE_ADMIN_CHAT_USER_LIST
            - ROLE_ADMIN_CHAT_USER_VIEW
            - ROLE_ADMIN_CHAT_USER_CREATE
            - ROLE_ADMIN_TP_LIST
            - ROLE_ADMIN_TP_VIEW
            - ROLE_ADMIN_TP_DELETE
            - ROLE_ADMIN_TP_CREATE
            - ROLE_ADMIN_TP_EDIT
            - ROLE_ADMIN_CLASSE_LIST
            - ROLE_ADMIN_CONVERSATION_HOMEWORK_LIST
            - ROLE_ADMIN_BULLETIN_CLASSE_LIST
            - ROLE_ADMIN_BULLETIN_ELEVE_LIST
            - ROLE_ADMIN_COURS_EN_LIGNE_LIST
            - ROLE_ADMIN_LES_DEVOIR_LIST
            - ROLE_ADMIN_LES_DEVOIR_CREATE
            - ROLE_ADMIN_LES_DEVOIR_EDIT
#            - ROLE_ADMIN_LES_DEVOIR_DELETE
            - ROLE_ADMIN_DEVOIR_LIST
            - ROLE_ADMIN_DEVOIR_CREATE
            - ROLE_ADMIN_DEVOIR_EDIT
#            - ROLE_ADMIN_DEVOIR_DELETE
            - ROLE_ADMIN_ANNONCE_LIST
            - ROLE_ADMIN_ANNONCE_VIEW
            - ROLE_ADMIN_ANNONCE_CREATE
            - ROLE_ADMIN_BULLETIN_CONSEIL_LIST
            - ROLE_ADMIN_BULLETIN_CONSEIL_EDIT

        ROLE_STAFF:
            - ROLE_ADMIN
            - ROLE_ADMIN_SERVICE_LIST
            - ROLE_ADMIN_SERVICE_EDIT
#            - ROLE_ADMIN_SERVICE_DELETE
            - ROLE_ADMIN_SERVICE_CREATE
            - ROLE_ADMIN_COURS_LIST
            - ROLE_ADMIN_COURS_EDIT
#            - ROLE_ADMIN_COURS_DELETE
            - ROLE_ADMIN_COURS_CREATE
            - ROLE_ADMIN_HOMEWORK_LIST
            - ROLE_ADMIN_HOMEWORK_EDIT
#            - ROLE_ADMIN_HOMEWORK_DELETE
            - ROLE_ADMIN_HOMEWORK_CREATE
            - ROLE_ADMIN_ELEVE_LIST_LIST
            - ROLE_ADMIN_ELEVE_LIST_CREATE
            - ROLE_ADMIN_ELEVE_LIST_EDIT
            - ROLE_ADMIN_ELEVE_ANNEE_SCOLAIRE_LIST
            - ROLE_ADMIN_ELEVE_ANNEE_SCOLAIRE_CREATE
            - ROLE_ADMIN_ELEVE_ANNEE_SCOLAIRE_EDIT
            - ROLE_ADMIN_CHAT_USER_LIST
            - ROLE_ADMIN_CHAT_USER_VIEW
            - ROLE_ADMIN_CHAT_USER_CREATE
            - ROLE_ADMIN_TP_LIST
            - ROLE_ADMIN_TP_VIEW
#            - ROLE_ADMIN_TP_DELETE
            - ROLE_ADMIN_TP_CREATE
            - ROLE_ADMIN_CONVERSATION_HOMEWORK_LIST
            - ROLE_ADMIN_COURS_EN_LIGNE_LIST
            - ROLE_ADMIN_LES_DEVOIR_LIST
            - ROLE_ADMIN_LES_DEVOIR_CREATE
            - ROLE_ADMIN_LES_DEVOIR_EDIT
#            - ROLE_ADMIN_LES_DEVOIR_DELETE
            - ROLE_ADMIN_DEVOIR_LIST
            - ROLE_ADMIN_DEVOIR_CREATE
            - ROLE_ADMIN_DEVOIR_EDIT
#            - ROLE_ADMIN_DEVOIR_DELETE
            - ROLE_ADMIN_MATIERE_LIST
            - ROLE_ADMIN_MATIERE_CREATE
            - ROLE_ADMIN_MATIERE_EDIT
            - ROLE_ADMIN_NIVEAU_LIST
            - ROLE_ADMIN_NIVEAU_CREATE
            - ROLE_ADMIN_NIVEAU_EDIT
            - ROLE_ADMIN_SPECIALITE_LIST
            - ROLE_ADMIN_SPECIALITE_CREATE
            - ROLE_ADMIN_SPECIALITE_EDIT
            - ROLE_ADMIN_GROUPE_MATIERE_LIST
            - ROLE_ADMIN_GROUPE_MATIERE_CREATE
            - ROLE_ADMIN_GROUPE_MATIERE_EDIT
            - ROLE_ADMIN_ENSEIGNANT_LIST
            - ROLE_ADMIN_ENSEIGNANT_CREATE
            - ROLE_ADMIN_ENSEIGNANT_EDIT
            - ROLE_ADMIN_ENSEIGNANT_LIST
            - ROLE_ADMIN_ENSEIGNANT_CREATE
            - ROLE_ADMIN_ENSEIGNANT_EDIT
#            - ROLE_ADMIN_ENSEIGNANT_DELETE
            - ROLE_ADMIN_CLASSE_LIST
            - ROLE_ADMIN_CLASSE_CREATE
            - ROLE_ADMIN_CLASSE_EDIT
#            - ROLE_ADMIN_CLASSE_DELETE
            - ROLE_ADMIN_BULLETIN_ELEVE_LIST
            - ROLE_ADMIN_BULLETIN_ELEVE_CREATE
            - ROLE_ADMIN_BULLETIN_ELEVE_EDIT
#            - ROLE_ADMIN_BULLETIN_ELEVE_DELETE
            - ROLE_ADMIN_BULLETIN_CLASSE_LIST
            - ROLE_ADMIN_BULLETIN_CLASSE_CREATE
            - ROLE_ADMIN_BULLETIN_CLASSE_EDIT
#            - ROLE_ADMIN_BULLETIN_CLASSE_DELETE
            - ROLE_ADMIN_COURS_EN_LIGNE_LIST
            - ROLE_ADMIN_COURS_EN_LIGNE_CREATE
            - ROLE_ADMIN_COURS_EN_LIGNE_EDIT
#            - ROLE_ADMIN_COURS_EN_LIGNE_DELETE
            - ROLE_ADMIN_COURS_EN_LIGNE_SHOW
            - ROLE_ADMIN_GROUP_CLASSE_LIST
            - ROLE_ADMIN_GROUP_CLASSE_CREATE
            - ROLE_ADMIN_GROUP_CLASSE_EDIT
#            - ROLE_ADMIN_GROUP_CLASSE_DELETE
            - ROLE_ADMIN_SALLE_CLASSE_LIST
            - ROLE_ADMIN_SALLE_CLASSE_CREATE
            - ROLE_ADMIN_SALLE_CLASSE_EDIT
#            - ROLE_ADMIN_SALLE_CLASSE_DELETE
            - ROLE_ADMIN_ANNEE_SCOLAIRE_LIST
            - ROLE_ADMIN_ANNEE_SCOLAIRE_CREATE
            - ROLE_ADMIN_ANNEE_SCOLAIRE_EDIT
#            - ROLE_ADMIN_ANNEE_SCOLAIRE_DELETE
            - ROLE_ADMIN_PERIODE_LIST
            - ROLE_ADMIN_PERIODE_CREATE
            - ROLE_ADMIN_PERIODE_EDIT
#            - ROLE_ADMIN_PERIODE_DELETE
            - ROLE_ADMIN_ATTESTATION_LIST
            - ROLE_ADMIN_ATTESTATION_CREATE
            - ROLE_ADMIN_ATTESTATION_EDIT
#            - ROLE_ADMIN_ATTESTATION_DELETE
            - ROLE_ADMIN_STAFF_LIST
            - ROLE_ADMIN_ANNONCE_LIST
            - ROLE_ADMIN_ANNONCE_VIEW
            - ROLE_ADMIN_ANNONCE_CREATE
            - ROLE_ADMIN_BULLETIN_CONSEIL_LIST
            - ROLE_ADMIN_BULLETIN_CONSEIL_EDIT
            - ROLE_ADMIN_BULLETIN_CONSEIL_VIEW
            - ROLE_ADMIN_DRIVER_LIST
            - ROLE_ADMIN_DRIVER_EDIT
            - ROLE_ADMIN_DRIVER_VIEW
            - ROLE_ADMIN_DRIVER_CREATE
            - ROLE_ADMIN_VEHICULE_LIST
            - ROLE_ADMIN_VEHICULE_EDIT
            - ROLE_ADMIN_VEHICULE_VIEW
            - ROLE_ADMIN_VEHICULE_CREATE
            - ROLE_ADMIN_CIRCUIT_LIST
            - ROLE_ADMIN_CIRCUIT_EDIT
            - ROLE_ADMIN_CIRCUIT_VIEW
            - ROLE_ADMIN_CIRCUIT_CREATE
            - ROLE_ADMIN_VOYAGE_LIST
            - ROLE_ADMIN_VOYAGE_EDIT
            - ROLE_ADMIN_VOYAGE_VIEW
            - ROLE_ADMIN_VOYAGE_CREATE
            - ROLE_ADMIN_VOYAGE_ATTENDANCE_LIST
            - ROLE_ADMIN_VOYAGE_ATTENDANCE_EDIT
            - ROLE_ADMIN_VOYAGE_ATTENDANCE_VIEW
            - ROLE_ADMIN_VOYAGE_ATTENDANCE_CREATE
            - ROLE_ADMIN_REPAS_LIST
            - ROLE_ADMIN_REPAS_VIEW
            - ROLE_ADMIN_REPAS_EDIT
            - ROLE_ADMIN_REPAS_CREATE
            - ROLE_ADMIN_MENU_LIST
            - ROLE_ADMIN_MENU_VIEW
            - ROLE_ADMIN_MENU_EDIT
            - ROLE_ADMIN_MENU_CREATE
            - ROLE_ADMIN_MENU_CONTINE_LIST
            - ROLE_ADMIN_MENU_CONTINE_VIEW
            - ROLE_ADMIN_MENU_CONTINE_EDIT
            - ROLE_ADMIN_MENU_CONTINE_CREATE
            - ROLE_ADMIN_RECLAMATION_CONTINE_LIST
            - ROLE_ADMIN_RECLAMATION_CONTINE_VIEW
            - ROLE_ADMIN_RECLAMATION_CONTINE_EDIT
#            - ROLE_ADMIN_RECLAMATION_CONTINE_CREATE
            - ROLE_ADMIN_SERVICE_JOURNALIER_ELEVE_LIST
            - ROLE_ADMIN_SERVICE_JOURNALIER_ELEVE_EDIT
            - ROLE_ADMIN_SERVICE_JOURNALIER_ELEVE_CREAT
            - ROLE_ADMIN_SERVICE_JOURNALIER_ELEVE_VIEW
            - ROLE_ADMIN_NOTIFICATION_LIST
            - ROLE_ADMIN_DEMANDE_PARENT_LIST
            - ROLE_ADMIN_DEMANDE_PARENT_CREATE
            - ROLE_ADMIN_DEMANDE_PARENT_EDIT
            - ROLE_ADMIN_EXAMEN_TYPE_LIST
            - ROLE_ADMIN_EXAMEN_TYPE_CREATE
            - ROLE_ADMIN_EXAMEN_TYPE_EDIT
            - ROLE_ADMIN_NATURE_EXAMEN_LIST
            - ROLE_ADMIN_NATURE_EXAMEN_CREATE
            - ROLE_ADMIN_NATURE_EXAMEN_EDIT
            - ROLE_ADMIN_SERVICE_CATEGORY_LIST
            - ROLE_ADMIN_SERVICE_CATEGORY_CREATE
            - ROLE_ADMIN_SERVICE_CATEGORY_EDIT
            - ROLE_ADMIN_CONFIGURATION_LIST
            - ROLE_ADMIN_CONFIGURATION_CREATE
            - ROLE_ADMIN_CONFIGURATION_EDIT
            - ROLE_ADMIN_SERVICE_PAIEMENT_LIST
            - ROLE_ADMIN_SERVICE_PAIEMENT_CREATE
            - ROLE_ADMIN_SERVICE_PAIEMENT_EDIT
            - ROLE_ADMIN_LOGS_LIST
services:
    security.authentication.listener.form:
        class: App\Form\Extension\UsernamePasswordFormAuthenticationListenerExtension
        parent: security.authentication.listener.abstract
        abstract: true
        calls: [ [setEntityManager, ["@doctrine.orm.entity_manager"]] ]
