2
我基於:http://symfony.com/doc/2.0/cookbook/security/custom_authentication_provider.html創建了自己的身份驗證,並且運行良好。如何在Symfony2中註冊多個身份驗證提供程序?
但現在我需要有兩個身份驗證提供程序。 AuthenticationProviderManager支持這一點,但我無法找到如何添加第二個身份驗證提供程序到我的安全工廠。
我的代碼:
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]
所以你可以看到我有一個認證提供者註冊。我如何添加第二個?
我想與simple_form和simple_preauth但總是simple_preauth嘗試第一 – rkmax