Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FrameworkBundle] made firewall authentication listeners configurable
- Loading branch information
Showing
7 changed files
with
236 additions
and
148 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Security/Factory/FormLoginFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class FormLoginFactory implements SecurityFactoryInterface | ||
{ | ||
public function create(ContainerBuilder $container, $id, $config, $userProvider, $providerIds, $defaultEntryPoint) | ||
{ | ||
$provider = 'security.authentication.provider.dao.'.$id; | ||
$container | ||
->register($provider, '%security.authentication.provider.dao.class%') | ||
->setArguments(array(new Reference($userProvider), new Reference('security.account_checker'), new Reference('security.encoder.'.$providerIds[$userProvider]))); | ||
; | ||
|
||
// listener | ||
$listenerId = 'security.authentication.listener.form.'.$id; | ||
$listener = $container->setDefinition($listenerId, clone $container->getDefinition('security.authentication.listener.form')); | ||
$arguments = $listener->getArguments(); | ||
$arguments[1] = new Reference($provider); | ||
$listener->setArguments($arguments); | ||
|
||
$options = array( | ||
'check_path' => '/login_check', | ||
'login_path' => '/login', | ||
'use_forward' => false, | ||
'always_use_default_target_path' => false, | ||
'default_target_path' => '/', | ||
'target_path_parameter' => '_target_path', | ||
'use_referer' => false, | ||
'failure_path' => null, | ||
'failure_forward' => false, | ||
); | ||
foreach (array_keys($options) as $key) { | ||
if (isset($config[$key])) { | ||
$options[$key] = $config[$key]; | ||
} | ||
} | ||
$container->setParameter('security.authentication.form.options', $options); | ||
$container->setParameter('security.authentication.form.login_path', $options['login_path']); | ||
$container->setParameter('security.authentication.form.use_forward', $options['use_forward']); | ||
|
||
return array($provider, $listenerId, 'security.authentication.form_entry_point'); | ||
} | ||
|
||
public function getPosition() | ||
{ | ||
return 'form'; | ||
} | ||
|
||
public function getKey() | ||
{ | ||
return 'form-login'; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Security/Factory/HttpBasicFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class HttpBasicFactory implements SecurityFactoryInterface | ||
{ | ||
public function create(ContainerBuilder $container, $id, $config, $userProvider, $providerIds, $defaultEntryPoint) | ||
{ | ||
$provider = 'security.authentication.provider.dao.'.$id; | ||
$container | ||
->register($provider, '%security.authentication.provider.dao.class%') | ||
->setArguments(array(new Reference($userProvider), new Reference('security.account_checker'), new Reference('security.encoder.'.$providerIds[$userProvider]))); | ||
; | ||
|
||
// listener | ||
$listenerId = 'security.authentication.listener.basic.'.$id; | ||
$listener = $container->setDefinition($listenerId, clone $container->getDefinition('security.authentication.listener.basic')); | ||
$arguments = $listener->getArguments(); | ||
$arguments[1] = new Reference($provider); | ||
$listener->setArguments($arguments); | ||
|
||
if (isset($config['path'])) { | ||
$container->setParameter('security.authentication.form.path', $config['path']); | ||
} | ||
|
||
if (null === $defaultEntryPoint) { | ||
$defaultEntryPoint = 'security.authentication.basic_entry_point'; | ||
} | ||
|
||
return array($provider, $listenerId, $defaultEntryPoint); | ||
} | ||
|
||
public function getPosition() | ||
{ | ||
return 'http'; | ||
} | ||
|
||
public function getKey() | ||
{ | ||
return 'http-basic'; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...Symfony/Bundle/FrameworkBundle/DependencyInjection/Security/Factory/HttpDigestFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class HttpDigestFactory implements SecurityFactoryInterface | ||
{ | ||
public function create(ContainerBuilder $container, $id, $config, $userProvider, $providerIds, $defaultEntryPoint) | ||
{ | ||
$provider = 'security.authentication.provider.dao.'.$id; | ||
$container | ||
->register($provider, '%security.authentication.provider.dao.class%') | ||
->setArguments(array(new Reference($userProvider), new Reference('security.account_checker'), new Reference('security.encoder.'.$providerIds[$userProvider]))); | ||
; | ||
|
||
// listener | ||
$listenerId = 'security.authentication.listener.digest.'.$id; | ||
$listener = $container->setDefinition($listenerId, clone $container->getDefinition('security.authentication.listener.digest')); | ||
$arguments = $listener->getArguments(); | ||
$arguments[1] = new Reference($userProvider); | ||
$listener->setArguments($arguments); | ||
|
||
if (null === $defaultEntryPoint) { | ||
$defaultEntryPoint = 'security.authentication.digest_entry_point'; | ||
} | ||
|
||
return array($provider, $listenerId, $defaultEntryPoint); | ||
} | ||
|
||
public function getPosition() | ||
{ | ||
return 'http'; | ||
} | ||
|
||
public function getKey() | ||
{ | ||
return 'http-digest'; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../Bundle/FrameworkBundle/DependencyInjection/Security/Factory/SecurityFactoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
interface SecurityFactoryInterface | ||
{ | ||
public function create(ContainerBuilder $container, $id, $config, $userProvider, $providerIds, $defaultEntryPoint); | ||
|
||
public function getPosition(); | ||
|
||
public function getKey(); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Security/Factory/X509Factory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class X509Factory implements SecurityFactoryInterface | ||
{ | ||
public function create(ContainerBuilder $container, $id, $config, $userProvider, $providerIds, $defaultEntryPoint) | ||
{ | ||
$provider = 'security.authentication.provider.pre_authenticated.'.$id; | ||
$container | ||
->register($provider, '%security.authentication.provider.pre_authenticated.class%') | ||
->setArguments(array(new Reference($userProvider), new Reference('security.account_checker'))) | ||
; | ||
|
||
// listener | ||
$listenerId = 'security.authentication.listener.x509.'.$id; | ||
$listener = $container->setDefinition($listenerId, clone $container->getDefinition('security.authentication.listener.x509')); | ||
$arguments = $listener->getArguments(); | ||
$arguments[1] = new Reference($provider); | ||
$listener->setArguments($arguments); | ||
|
||
return array($provider, $listenerId, $defaultEntryPoint); | ||
} | ||
|
||
public function getPosition() | ||
{ | ||
return 'pre_auth'; | ||
} | ||
|
||
public function getKey() | ||
{ | ||
return 'x509'; | ||
} | ||
} |
Oops, something went wrong.