I created my own authentication based on: http://symfony.com/doc/2.0/cookbook/security/custom_authentication_provider.html and it works well.
But now I need to have two authentication providers. AuthenticationProviderManager supports this but I can't find out how to add second auth provider to my security factory.
My code:
security.yml
firewalls:
wsse_secured:
pattern: /api/.*
wsse: true
WsseFactory.php
class WsseFactory implements SecurityFactoryInterface
{
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
{
$providerId = 'security.authentication.provider.wsse.'.$id;
$container
->setDefinition(
$providerId,
new DefinitionDecorator(
'wsse.security.authentication.provider'
)
)
->replaceArgument(
0,
new Reference($userProvider)
);
$listenerId = 'security.authentication.listener.wsse.'.$id;
$container->setDefinition(
$listenerId,
new DefinitionDecorator(
'wsse.security.authentication.listener'
)
);
return array($providerId, $listenerId, $defaultEntryPoint);
}
public function getPosition()
{
return 'pre_auth';
}
public function getKey()
{
return 'wsse';
}
public function addConfiguration(NodeDefinition $node)
{
}
}
services.yml:
wsse.security.authentication.provider:
class: LD\BinaryBackendBundle\Security\Authentication\Provider\WsseProvider
arguments: ['', %kernel.cache_dir%/security/nonces]
wsse.security.authentication.listener:
class: LD\BinaryBackendBundle\Security\Firewall\WsseListener
arguments: [@security.context, @security.authentication.manager, @logger]
So as you can see I have one auth provider registers. How can I add second?