Browse Source

Merge remote branch 'schmittjoh/security'

Fabien Potencier 14 years ago
parent
commit
263c32aff0

+ 3 - 1
src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml

@@ -81,7 +81,9 @@
         <service id="security.logout.handler.session" class="%security.logout.handler.session.class%" public="false" />
         <service id="security.logout.handler.cookie_clearing" class="%security.logout.handler.cookie_clearing.class%" public="false" abstract="true" />
 
-        <service id="security.authentication.form_entry_point" class="%security.authentication.form_entry_point.class%" public="false" abstract="true" />
+        <service id="security.authentication.form_entry_point" class="%security.authentication.form_entry_point.class%" public="false" abstract="true">
+            <argument type="service" id="http_kernel" />
+        </service>
 
         <service id="security.authentication.listener.abstract" abstract="true" public="false">
             <argument type="service" id="security.context" />

+ 1 - 4
src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php

@@ -2,7 +2,6 @@
 
 namespace Symfony\Component\Security\Http\Authentication;
 
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
 use Symfony\Component\Security\Core\Exception\AuthenticationException;
 use Symfony\Component\HttpFoundation\Request;
 
@@ -22,12 +21,10 @@ interface AuthenticationFailureHandlerInterface
      * called by authentication listeners inheriting from
      * AbstractAuthenticationListener.
      *
-     * @param GetResponseEvent    $event the "onCoreRequest" event, this event always
-     *                                       has the kernel as target
      * @param Request                 $request
      * @param AuthenticationException $exception
      *
      * @return Response the response to return
      */
-    function onAuthenticationFailure(GetResponseEvent $event, Request $request, AuthenticationException $exception);
+    function onAuthenticationFailure(Request $request, AuthenticationException $exception);
 }

+ 1 - 4
src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php

@@ -2,7 +2,6 @@
 
 namespace Symfony\Component\Security\Http\Authentication;
 
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
 use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
 use Symfony\Component\HttpFoundation\Request;
 
@@ -22,12 +21,10 @@ interface AuthenticationSuccessHandlerInterface
      * is called by authentication listeners inheriting from
      * AbstractAuthenticationListener.
      *
-     * @param GetResponseEvent $event the "onCoreRequest" event, this event always
-     *                              has the kernel as target
      * @param Request        $request
      * @param TokenInterface $token
      *
      * @return Response the response to return
      */
-    function onAuthenticationSuccess(GetResponseEvent $event, Request $request, TokenInterface $token);
+    function onAuthenticationSuccess(Request $request, TokenInterface $token);
 }

+ 1 - 2
src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php

@@ -18,11 +18,10 @@ interface AccessDeniedHandlerInterface
     /**
      * Handles an access denied failure.
      *
-     * @param GetResponseForExceptionEvent $event
      * @param Request                      $request
      * @param AccessDeniedException        $accessDeniedException
      *
      * @return Response may return null
      */
-    function handle(GetResponseForExceptionEvent $event, Request $request, AccessDeniedException $accessDeniedException);
+    function handle(Request $request, AccessDeniedException $accessDeniedException);
 }

+ 4 - 4
src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php

@@ -11,7 +11,6 @@
 
 namespace Symfony\Component\Security\Http\EntryPoint;
 
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
 use Symfony\Component\Security\Core\Exception\AuthenticationException;
 use Symfony\Component\HttpFoundation\Request;
 
@@ -26,9 +25,10 @@ interface AuthenticationEntryPointInterface
     /**
      * Starts the authentication scheme.
      *
-     * @param GetResponseEvent        $event     The "onCoreRequest" event
-     * @param object                  $request       The request that resulted in an AuthenticationException
+     * @param Request                 $request       The request that resulted in an AuthenticationException
      * @param AuthenticationException $authException The exception that started the authentication process
+     *
+     * @return Response
      */
-    function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null);
+    function start(Request $request, AuthenticationException $authException = null);
 }

+ 1 - 2
src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php

@@ -15,7 +15,6 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
 use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
 
 /**
  * BasicAuthenticationEntryPoint starts an HTTP Basic authentication.
@@ -31,7 +30,7 @@ class BasicAuthenticationEntryPoint implements AuthenticationEntryPointInterface
         $this->realmName = $realmName;
     }
 
-    public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
+    public function start(Request $request, AuthenticationException $authException = null)
     {
         $response = new Response();
         $response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', $this->realmName));

+ 1 - 2
src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php

@@ -17,7 +17,6 @@ use Symfony\Component\Security\Core\Exception\NonceExpiredException;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Log\LoggerInterface;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
 
 /**
  * DigestAuthenticationEntryPoint starts an HTTP Digest authentication.
@@ -39,7 +38,7 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac
         $this->logger = $logger;
     }
 
-    public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
+    public function start(Request $request, AuthenticationException $authException = null)
     {
         $expiryTime = microtime(true) + $this->nonceValiditySeconds * 1000;
         $signatureValue = md5($expiryTime.':'.$this->key);

+ 6 - 4
src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php

@@ -17,7 +17,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\Security\Core\Exception\AuthenticationException;
 use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
 
 /**
  * FormAuthenticationEntryPoint starts an authentication via a login form.
@@ -28,15 +27,18 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
 {
     private $loginPath;
     private $useForward;
+    private $httpKernel;
 
     /**
      * Constructor
      *
+     * @param HttpKernelInterface $kernel
      * @param string  $loginPath  The path to the login form
      * @param Boolean $useForward Whether to forward or redirect to the login form
      */
-    public function __construct($loginPath, $useForward = false)
+    public function __construct(HttpKernelInterface $kernel, $loginPath, $useForward = false)
     {
+        $this->httpKernel = $kernel;
         $this->loginPath = $loginPath;
         $this->useForward = (Boolean) $useForward;
     }
@@ -44,10 +46,10 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
     /**
      * {@inheritdoc}
      */
-    public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
+    public function start(Request $request, AuthenticationException $authException = null)
     {
         if ($this->useForward) {
-            return $event->getKernel()->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST);
+            return $this->httpKernel->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST);
         }
 
         return new RedirectResponse(0 !== strpos($this->loginPath, 'http') ? $request->getUriForPath($this->loginPath) : $this->loginPath, 302);

+ 1 - 2
src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php

@@ -16,7 +16,6 @@ use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
 
 /**
  * RetryAuthenticationEntryPoint redirects URL based on the configured scheme.
@@ -36,7 +35,7 @@ class RetryAuthenticationEntryPoint implements AuthenticationEntryPointInterface
         $this->httpsPort = $httpsPort;
     }
 
-    public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
+    public function start(Request $request, AuthenticationException $authException = null)
     {
         $scheme = $request->isSecure() ? 'http' : 'https';
         if ('http' === $scheme && 80 != $this->httpPort) {

+ 2 - 2
src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php

@@ -174,7 +174,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
         $this->securityContext->setToken(null);
 
         if (null !== $this->failureHandler) {
-            return $this->failureHandler->onAuthenticationFailure($event, $request, $failed);
+            return $this->failureHandler->onAuthenticationFailure($request, $failed);
         }
 
         if (null === $this->options['failure_path']) {
@@ -219,7 +219,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
         }
 
         if (null !== $this->successHandler) {
-            $response = $this->successHandler->onAuthenticationSuccess($event, $request, $token);
+            $response = $this->successHandler->onAuthenticationSuccess($request, $token);
         } else {
             $path = $this->determineTargetUrl($request);
             $response = new RedirectResponse(0 !== strpos($path, 'http') ? $request->getUriForPath($path) : $path, 302);

+ 4 - 4
src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

@@ -78,7 +78,7 @@ class ExceptionListener
             }
 
             try {
-                $response = $this->startAuthentication($event, $request, $exception);
+                $response = $this->startAuthentication($request, $exception);
             } catch (\Exception $e) {
                 $event->set('exception', $e);
 
@@ -92,7 +92,7 @@ class ExceptionListener
                 }
 
                 try {
-                    $response = $this->startAuthentication($event, $request, new InsufficientAuthenticationException('Full authentication is required to access this resource.', $token, 0, $exception));
+                    $response = $this->startAuthentication($request, new InsufficientAuthenticationException('Full authentication is required to access this resource.', $token, 0, $exception));
                 } catch (\Exception $e) {
                     $event->set('exception', $e);
 
@@ -105,7 +105,7 @@ class ExceptionListener
 
                 try {
                     if (null !== $this->accessDeniedHandler) {
-                        $response = $this->accessDeniedHandler->handle($event, $request, $exception);
+                        $response = $this->accessDeniedHandler->handle($request, $exception);
 
                         if (!$response instanceof Response) {
                             return;
@@ -155,6 +155,6 @@ class ExceptionListener
             $request->getSession()->set('_security.target_path', $request->getUri());
         }
 
-        return $this->authenticationEntryPoint->start($event, $request, $authException);
+        return $this->authenticationEntryPoint->start($request, $authException);
     }
 }

+ 1 - 1
src/Symfony/Component/Security/Http/Firewall/LogoutListener.php

@@ -74,7 +74,7 @@ class LogoutListener implements ListenerInterface
         }
 
         if (null !== $this->successHandler) {
-            $response = $this->successHandler->onLogoutSuccess($event, $request);
+            $response = $this->successHandler->onLogoutSuccess($request);
 
             if (!$response instanceof Response) {
                 throw new \RuntimeException('Logout Success Handler did not return a Response.');

+ 1 - 2
src/Symfony/Component/Security/Http/Logout/LogoutSuccessHandlerInterface.php

@@ -21,9 +21,8 @@ interface LogoutSuccessHandlerInterface
     /**
      * Creates a Response object to send upon a successful logout.
      *
-     * @param GetResponseEvent $event
      * @param Request $request
      * @return Response never null
      */
-    function onLogoutSuccess(GetResponseEvent $event, Request $request);
+    function onLogoutSuccess(Request $request);
 }