SYMFONY 5 : Authentication JWT on multiple Entity

Viewed 341

I am creating a SYMFONY application and I have to use differents users type: Clients, Expert and CustomerSuccess. Each user's type will have an authenticator's form. But, how can I create tokens with JWT on more than one entity? Here is the Security.yaml file:

    providers:
        app_user_provider:
            entity:
                class: App\Entity\CustomerSuccess
                property: email
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
            pattern: ^/api/login
            stateless: true
            anonymous: false
            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
            jwt: ~

        main:
            lazy: true
            provider: app_user_provider

This Security.yaml is working well but when I try to add another type of users, my API returns : Not configuring explicitly the provider for the json_login authenticator on login firewall is ambiguous as there is more than one registered provider. (500 Internal Server Error). Does anyone knows how to setup more than one users in SYMFONY's app with JWT token?

Thanks you ;)

0 Answers
Related