addAuthenticatorFactory example

class SecurityBundle extends Bundle
{
    /** * @return void */
    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        /** @var SecurityExtension $extension */
        $extension = $container->getExtension('security');
        $extension->addAuthenticatorFactory(new FormLoginFactory());
        $extension->addAuthenticatorFactory(new FormLoginLdapFactory());
        $extension->addAuthenticatorFactory(new JsonLoginFactory());
        $extension->addAuthenticatorFactory(new JsonLoginLdapFactory());
        $extension->addAuthenticatorFactory(new HttpBasicFactory());
        $extension->addAuthenticatorFactory(new HttpBasicLdapFactory());
        $extension->addAuthenticatorFactory(new RememberMeFactory());
        $extension->addAuthenticatorFactory(new X509Factory());
        $extension->addAuthenticatorFactory(new RemoteUserFactory());
        $extension->addAuthenticatorFactory(new CustomAuthenticatorFactory());
        $extension->addAuthenticatorFactory(new LoginThrottlingFactory());
        $extension->addAuthenticatorFactory(new LoginLinkFactory());
        
public static function provideUserCheckerConfig()
    {
        yield [[], InMemoryUserChecker::class];
        yield [['user_checker' => TestUserChecker::class], TestUserChecker::class];
    }

    public function testConfigureCustomFirewallListener()
    {
        $container = $this->getRawContainer();
        /** @var SecurityExtension $extension */
        $extension = $container->getExtension('security');
        $extension->addAuthenticatorFactory(new TestFirewallListenerFactory());

        $container->loadFromExtension('security', [
            'firewalls' => [
                'main' => [
                    'custom_listener' => true,
                ],
            ],
        ]);

        $container->compile();

        

        parent::build($container);

        $this->configureSecurityExtension($container);
    }

    private function configureSecurityExtension(ContainerBuilder $container): void
    {
        /** @var SecurityExtension $extension */
        $extension = $container->getExtension('security');

        $extension->addAuthenticatorFactory(new DummyFormLoginFactory());
    }
}
Home | Imprint | This part of the site doesn't use cookies.