how to configure firewall with multiple provider on symfony 4?

  firewall, provider, symfony4

i’m writing this message to ask you how it is possible on symfony to launch my app with multiple provider; this is my security yaml:

security:
    encoders:
        AppEntityUser:
            algorithm: auto


    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        chain_provider:
            chain:
                providers: [in_memory, app_user_provider]
        # used to reload user from session & other features (e.g. switch_user)
        app_user_provider:
            entity:
                class: AppEntityUser
                property: email
        in_memory:
            memory:
                users:
                    foo: { password: test , roles: [ 'ROLE_ADMIN' ] }
        # used to reload user from session & other features (e.g. switch_user)
#            memory:
#                users:
#                    admin: { password: '123412A' ,roles: ['ROLE_ADMIN']}
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
#            form_login:
#                csrf_token_generator : security.csrf.token_manager
            anonymous: true

            logout:
                path: app_logout
            guard:
                authenticators:
                    - AppSecurityUtilisateurAuthenticator

                # where to redirect after logout
                # target: app_any_route

                # where to redirect after logout
                # target: app_any_route

            # 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: ^/Conversation , roles: [ROLE_ADMIN , ROLE_USER] }
         - { path: ^/admin, roles: ROLE_ADMIN }
         - { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        # - { path: ^/profile, roles: ROLE_USER }

i have this error message , could you help me ?

Not configuring explicitly the provider for the "guard" liste
ner on "main" firewall is ambiguous as there is more than one
registered provider.

Source: Symfony4 Questions

LEAVE A COMMENT