Skip to content

Commit

Permalink
[Security] removed un-needed event parameter from many interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
schmittjoh committed Mar 18, 2011
1 parent f36b10a commit 7e1c4d5
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 36 deletions.
Expand Up @@ -32,7 +32,7 @@ protected function registerSubscribers($prefix, $definition)
);

foreach ($subscribers as $id => $instances) {
$definition->addMethodCall('addSubscriber', array(new Reference($id)));
$definition->addMethodCall('addEventSubscriber', array(new Reference($id)));
}
}

Expand Down
Expand Up @@ -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" />
Expand Down
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Up @@ -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);
}
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Up @@ -15,7 +15,6 @@
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.
Expand All @@ -31,7 +30,7 @@ public function __construct($realmName)
$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));
Expand Down
Expand Up @@ -17,7 +17,6 @@
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.
Expand All @@ -39,7 +38,7 @@ public function __construct($realmName, $key, $nonceValiditySeconds = 300, Logge
$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);
Expand Down
Expand Up @@ -17,7 +17,6 @@
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.
Expand All @@ -28,26 +27,29 @@ 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;
}

/**
* {@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);
Expand Down
Expand Up @@ -16,7 +16,6 @@
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.
Expand All @@ -36,7 +35,7 @@ public function __construct($httpPort = 80, $httpsPort = 443)
$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) {
Expand Down
Expand Up @@ -174,7 +174,7 @@ private function onFailure(GetResponseEvent $event, Request $request, Authentica
$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']) {
Expand Down Expand Up @@ -219,7 +219,7 @@ private function onSuccess(GetResponseEvent $event, Request $request, TokenInter
}

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);
Expand Down
Expand Up @@ -78,7 +78,7 @@ public function onCoreException(GetResponseForExceptionEvent $event)
}

try {
$response = $this->startAuthentication($event, $request, $exception);
$response = $this->startAuthentication($request, $exception);
} catch (\Exception $e) {
$event->set('exception', $e);

Expand All @@ -92,7 +92,7 @@ public function onCoreException(GetResponseForExceptionEvent $event)
}

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);

Expand All @@ -105,7 +105,7 @@ public function onCoreException(GetResponseForExceptionEvent $event)

try {
if (null !== $this->accessDeniedHandler) {
$response = $this->accessDeniedHandler->handle($event, $request, $exception);
$response = $this->accessDeniedHandler->handle($request, $exception);

if (!$response instanceof Response) {
return;
Expand Down Expand Up @@ -138,7 +138,7 @@ public function onCoreException(GetResponseForExceptionEvent $event)
$event->setResponse($response);
}

private function startAuthentication(GetResponseForExceptionEvent $event, Request $request, AuthenticationException $authException)
private function startAuthentication(Request $request, AuthenticationException $authException)
{
$this->context->setToken(null);

Expand All @@ -155,6 +155,6 @@ private function startAuthentication(GetResponseForExceptionEvent $event, Reques
$request->getSession()->set('_security.target_path', $request->getUri());
}

return $this->authenticationEntryPoint->start($event, $request, $authException);
return $this->authenticationEntryPoint->start($request, $authException);
}
}
Expand Up @@ -74,7 +74,7 @@ public function handle(GetResponseEvent $event)
}

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.');
Expand Down
Expand Up @@ -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);
}

0 comments on commit 7e1c4d5

Please sign in to comment.