Skip to content

[Security][Authenticator-based] Multiple providers #40158

Closed
@mpiot

Description

@mpiot

Symfony version(s) affected: 5.2.3

Description
When using the new Authenticator-based Security with multiple providers, the UserBadge do not use the provider config in the firewall.

security:
    enable_authenticator_manager: true

    encoders:
        App\Entity\User:
            algorithm: auto
        Symfony\Component\Security\Core\User\User: auto

    providers:
        app_user_provider:
            entity:
                class: App\Entity\User
                property: username

        logbook_user_provider:
            memory:
                users:
                    logbook:
                        password: '%env(APP_LOGBOOK_USER_PASSWORD)%'
                        roles: 'ROLE_LOGBOOK_USER'

    firewalls:
        logbook:
            host: '%logbook_subdomain%'
            pattern: ^/logbook-entry
            provider: logbook_user_provider
            http_basic: ~

        main:
            provider: app_user_provider
            custom_authenticators:
                - App\Security\AppLoginAuthenticator
            logout:
                path: app_logout

In that exemple, when I use the UserBadge in App\Security\AppLoginAuthenticator, the Badge try to retrieve the user in the logbook_user_provider and not in app_user_provider.

I can use a callback as second argument in the UserBadge, and it works. But I think, because we define the Entity provider as provider in the firewall, we expect to use automatically that provider.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions