From 01c913be4b13a672a14ed20ec4ce44131cdea9f1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 5 May 2013 18:58:35 +0200 Subject: [PATCH] moved the simple HTTP authenticator to a pre-auth one --- ...actory.php => SimplePreAuthenticationFactory.php} | 12 ++++++------ .../Resources/config/security_listeners.xml | 4 ++-- src/Symfony/Bundle/SecurityBundle/SecurityBundle.php | 4 ++-- ...rface.php => SimplePreAuthenticatorInterface.php} | 2 +- ...tener.php => SimplePreAuthenticationListener.php} | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) rename src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/{SimpleHttpFactory.php => SimplePreAuthenticationFactory.php} (82%) rename src/Symfony/Component/Security/Core/Authentication/{SimpleHttpAuthenticatorInterface.php => SimplePreAuthenticatorInterface.php} (85%) rename src/Symfony/Component/Security/Http/Firewall/{SimpleHttpAuthenticationListener.php => SimplePreAuthenticationListener.php} (87%) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleHttpFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php similarity index 82% rename from src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleHttpFactory.php rename to src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php index d9613c1ccd..27d8c5f050 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleHttpFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php @@ -19,16 +19,16 @@ use Symfony\Component\DependencyInjection\Reference; /** * @author Jordi Boggiano */ -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'])); diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml index 8281fc657d..2bd379931a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml @@ -14,7 +14,7 @@ Symfony\Component\Security\Http\Firewall\SimpleFormAuthenticationListener - Symfony\Component\Security\Http\Firewall\SimpleHttpAuthenticationListener + Symfony\Component\Security\Http\Firewall\SimplePreAuthenticationListener Symfony\Component\Security\Http\Firewall\BasicAuthenticationListener Symfony\Component\Security\Http\EntryPoint\BasicAuthenticationEntryPoint @@ -153,7 +153,7 @@ - + diff --git a/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php b/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php index 85c4a22b2e..5de4136586 100644 --- a/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php +++ b/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php @@ -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()); diff --git a/src/Symfony/Component/Security/Core/Authentication/SimpleHttpAuthenticatorInterface.php b/src/Symfony/Component/Security/Core/Authentication/SimplePreAuthenticatorInterface.php similarity index 85% rename from src/Symfony/Component/Security/Core/Authentication/SimpleHttpAuthenticatorInterface.php rename to src/Symfony/Component/Security/Core/Authentication/SimplePreAuthenticatorInterface.php index b64aad9193..6164e7d986 100644 --- a/src/Symfony/Component/Security/Core/Authentication/SimpleHttpAuthenticatorInterface.php +++ b/src/Symfony/Component/Security/Core/Authentication/SimplePreAuthenticatorInterface.php @@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Request; /** * @author Jordi Boggiano */ -interface SimpleHttpAuthenticatorInterface extends SimpleAuthenticatorInterface +interface SimplePreAuthenticatorInterface extends SimpleAuthenticatorInterface { public function createToken(Request $request, $providerKey); } diff --git a/src/Symfony/Component/Security/Http/Firewall/SimpleHttpAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php similarity index 87% rename from src/Symfony/Component/Security/Http/Firewall/SimpleHttpAuthenticationListener.php rename to src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php index ab49b14165..80b35a55ac 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SimpleHttpAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php @@ -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 */ -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 {