moved the simple HTTP authenticator to a pre-auth one

This commit is contained in:
Fabien Potencier 2013-05-05 18:58:35 +02:00 committed by Jordi Boggiano
parent 887d9b8473
commit 01c913be4b
5 changed files with 17 additions and 17 deletions

View File

@ -19,16 +19,16 @@ use Symfony\Component\DependencyInjection\Reference;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class SimpleHttpFactory implements SecurityFactoryInterface
class SimplePreAuthenticationFactory implements SecurityFactoryInterface
{
public function getPosition()
{
return 'http';
return 'pre_auth';
}
public function getKey()
{
return 'simple-http';
return 'simple-preauth';
}
public function addConfiguration(NodeDefinition $node)
@ -43,7 +43,7 @@ class SimpleHttpFactory implements SecurityFactoryInterface
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
{
$provider = 'security.authentication.provider.simple_http.'.$id;
$provider = 'security.authentication.provider.simple_preauth.'.$id;
$container
->setDefinition($provider, new DefinitionDecorator('security.authentication.provider.simple'))
->replaceArgument(0, new Reference($config['authenticator']))
@ -52,8 +52,8 @@ class SimpleHttpFactory implements SecurityFactoryInterface
;
// listener
$listenerId = 'security.authentication.listener.simple_http.'.$id;
$listener = $container->setDefinition($listenerId, new DefinitionDecorator('security.authentication.listener.simple_http'));
$listenerId = 'security.authentication.listener.simple_preauth.'.$id;
$listener = $container->setDefinition($listenerId, new DefinitionDecorator('security.authentication.listener.simple_preauth'));
$listener->replaceArgument(2, $id);
$listener->replaceArgument(3, new Reference($config['authenticator']));

View File

@ -14,7 +14,7 @@
<parameter key="security.authentication.listener.simple_form.class">Symfony\Component\Security\Http\Firewall\SimpleFormAuthenticationListener</parameter>
<parameter key="security.authentication.listener.simple_http.class">Symfony\Component\Security\Http\Firewall\SimpleHttpAuthenticationListener</parameter>
<parameter key="security.authentication.listener.simple_preauth.class">Symfony\Component\Security\Http\Firewall\SimplePreAuthenticationListener</parameter>
<parameter key="security.authentication.listener.basic.class">Symfony\Component\Security\Http\Firewall\BasicAuthenticationListener</parameter>
<parameter key="security.authentication.basic_entry_point.class">Symfony\Component\Security\Http\EntryPoint\BasicAuthenticationEntryPoint</parameter>
@ -153,7 +153,7 @@
<argument type="service" id="logger" on-invalid="null" />
</service>
<service id="security.authentication.listener.simple_http" class="%security.authentication.listener.simple_http.class%" public="false" abstract="true">
<service id="security.authentication.listener.simple_preauth" class="%security.authentication.listener.simple_preauth.class%" public="false" abstract="true">
<tag name="monolog.logger" channel="security" />
<argument type="service" id="security.context" />
<argument type="service" id="security.authentication.manager" />

View File

@ -19,7 +19,7 @@ use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpBasic
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\HttpDigestFactory;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RememberMeFactory;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\X509Factory;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimpleHttpFactory;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimplePreAuthenticationFactory;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimpleFormFactory;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\InMemoryFactory;
@ -40,7 +40,7 @@ class SecurityBundle extends Bundle
$extension->addSecurityListenerFactory(new HttpDigestFactory());
$extension->addSecurityListenerFactory(new RememberMeFactory());
$extension->addSecurityListenerFactory(new X509Factory());
$extension->addSecurityListenerFactory(new SimpleHttpFactory());
$extension->addSecurityListenerFactory(new SimplePreAuthenticationFactory());
$extension->addSecurityListenerFactory(new SimpleFormFactory());
$extension->addUserProviderFactory(new InMemoryFactory());

View File

@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
interface SimpleHttpAuthenticatorInterface extends SimpleAuthenticatorInterface
interface SimplePreAuthenticatorInterface extends SimpleAuthenticatorInterface
{
public function createToken(Request $request, $providerKey);
}

View File

@ -17,18 +17,18 @@ use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\SimpleHttpAuthenticatorInterface;
use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
/**
* SimpleHttpListener implements simple proxying to an authenticator.
* SimplePreAuthenticationListener implements simple proxying to an authenticator.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class SimpleHttpAuthenticationListener implements ListenerInterface
class SimplePreAuthenticationListener implements ListenerInterface
{
private $securityContext;
private $authenticationManager;
@ -42,10 +42,10 @@ class SimpleHttpAuthenticationListener implements ListenerInterface
* @param SecurityContextInterface $securityContext A SecurityContext instance
* @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance
* @param string $providerKey
* @param SimpleHttpAuthenticatorInterface $simpleAuthenticator A SimpleHttpAuthenticatorInterface instance
* @param SimplePreAuthenticatorInterface $simpleAuthenticator A SimplePreAuthenticatorInterface instance
* @param LoggerInterface $logger A LoggerInterface instance
*/
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, SimpleHttpAuthenticatorInterface $simpleAuthenticator, LoggerInterface $logger = null)
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, SimplePreAuthenticatorInterface $simpleAuthenticator, LoggerInterface $logger = null)
{
if (empty($providerKey)) {
throw new \InvalidArgumentException('$providerKey must not be empty.');
@ -68,7 +68,7 @@ class SimpleHttpAuthenticationListener implements ListenerInterface
$request = $event->getRequest();
if (null !== $this->logger) {
$this->logger->info(sprintf('Attempting simple http authorization %s', $this->providerKey));
$this->logger->info(sprintf('Attempting simple pre-authorization %s', $this->providerKey));
}
try {