Symfony Use multiple providers for one firewall

I was wondering if we could use multiple providers for one firewall. I looked on the Internet but found nothing.

security:
    providers:
        chain_provider:
            chain:
                providers: [fos_userbundle, intranet_ldap]
        from_database:
            entity:
                class: AppEntityUser
                property: username
        fos_userbundle:
            id: fos_user.user_provider.username #fos_user.user_manager
        intranet_ldap:
            id: AppSecurityLdapUserProvider

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        admin:
            pattern:            /admin(.*)
            context:            user
            form_login:
                provider:       fos_userbundle
                login_path:     /admin/login
                use_forward:    false
                check_path:     /admin/login_check
                failure_path:   null
            logout:
                path:           /admin/logout
                target:         /admin/login
            anonymous:          true
        main:
            pattern:            ^/
            context:            user
            anonymous:          true
            form_login_ldap:
                service:        SymfonyComponentLdapLdap
                provider:       intranet_ldap
                login_path:     /login
                check_path:     /login_check
                dn_string:      'DC=xxx, DC=lan'
                query_string:   '(&(sAMAccountName={username}))'
                use_forward:    false
                always_use_default_target_path: true
                default_target_path: /profile
                use_referer:    true
            logout:
                path:  /logout
                target: /

Here’s my security.yaml. I would like for the main firewall to use the chainProviders, or directly use two services. or maybe in the main use two form_login. The goal is to be able to authenticate users from LDAP and from the BDD but using only one form, one route. I don’t know if it’s possible. Thanks for your answers

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *