summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Core/User/EntityUserProvider.php85
-rw-r--r--Http/Firewall.php2
-rw-r--r--Http/Firewall/AccessListener.php4
-rw-r--r--Http/Firewall/ExceptionListener.php11
-rw-r--r--Http/HttpUtils.php37
-rw-r--r--Http/RememberMe/AbstractRememberMeServices.php2
6 files changed, 37 insertions, 104 deletions
diff --git a/Core/User/EntityUserProvider.php b/Core/User/EntityUserProvider.php
deleted file mode 100644
index cc6f6ed..0000000
--- a/Core/User/EntityUserProvider.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Security\Core\User;
-
-use Doctrine\ORM\EntityManager;
-use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
-use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
-
-/**
- * Wrapper around a Doctrine EntityManager.
- *
- * Provides easy to use provisioning for Doctrine entity users.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- * @author Johannes M. Schmitt <schmittjoh@gmail.com>
- */
-class EntityUserProvider implements UserProviderInterface
-{
- private $class;
- private $repository;
- private $property;
-
- public function __construct(EntityManager $em, $class, $property = null)
- {
- $this->class = $class;
-
- if (false !== strpos($this->class, ':')) {
- $this->class = $em->getClassMetadata($class)->name;
- }
-
- $this->repository = $em->getRepository($class);
- $this->property = $property;
- }
-
- /**
- * {@inheritdoc}
- */
- public function loadUserByUsername($username)
- {
- if (null !== $this->property) {
- $user = $this->repository->findOneBy(array($this->property => $username));
- } else {
- if (!$this->repository instanceof UserProviderInterface) {
- throw new \InvalidArgumentException(sprintf('The Doctrine repository "%s" must implement UserProviderInterface.', get_class($this->repository)));
- }
-
- $user = $this->repository->loadUserByUsername($username);
- }
-
- if (null === $user) {
- throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
- }
-
- return $user;
- }
-
- /**
- * {@inheritDoc}
- */
- public function refreshUser(UserInterface $user)
- {
- if (!$user instanceof $this->class) {
- throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
- }
-
- return $this->loadUserByUsername($user->getUsername());
- }
-
- /**
- * {@inheritDoc}
- */
- public function supportsClass($class)
- {
- return $class === $this->class;
- }
-}
diff --git a/Http/Firewall.php b/Http/Firewall.php
index 996df29..9d05f86 100644
--- a/Http/Firewall.php
+++ b/Http/Firewall.php
@@ -30,7 +30,6 @@ class Firewall
{
private $map;
private $dispatcher;
- private $currentListeners;
/**
* Constructor.
@@ -42,7 +41,6 @@ class Firewall
{
$this->map = $map;
$this->dispatcher = $dispatcher;
- $this->currentListeners = array();
}
/**
diff --git a/Http/Firewall/AccessListener.php b/Http/Firewall/AccessListener.php
index 0cb45ac..877b6c3 100644
--- a/Http/Firewall/AccessListener.php
+++ b/Http/Firewall/AccessListener.php
@@ -11,7 +11,7 @@
namespace Symfony\Component\Security\Http\Firewall;
-use Symfony\Component\Security\Core\SecurityContext;
+use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Http\AccessMap;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
@@ -33,7 +33,7 @@ class AccessListener implements ListenerInterface
private $authManager;
private $logger;
- public function __construct(SecurityContext $context, AccessDecisionManagerInterface $accessDecisionManager, AccessMap $map, AuthenticationManagerInterface $authManager, LoggerInterface $logger = null)
+ public function __construct(SecurityContextInterface $context, AccessDecisionManagerInterface $accessDecisionManager, AccessMap $map, AuthenticationManagerInterface $authManager, LoggerInterface $logger = null)
{
$this->context = $context;
$this->accessDecisionManager = $accessDecisionManager;
diff --git a/Http/Firewall/ExceptionListener.php b/Http/Firewall/ExceptionListener.php
index 737d644..c757390 100644
--- a/Http/Firewall/ExceptionListener.php
+++ b/Http/Firewall/ExceptionListener.php
@@ -26,6 +26,7 @@ use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
@@ -113,16 +114,16 @@ class ExceptionListener
if (!$response instanceof Response) {
return;
}
- } else {
- if (null === $this->errorPage) {
- return;
- }
-
+ } elseif (null !== $this->errorPage) {
$subRequest = $this->httpUtils->createRequest($request, $this->errorPage);
$subRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR, $exception);
$response = $event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
$response->setStatusCode(403);
+ } else {
+ $event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
+
+ return;
}
} catch (\Exception $e) {
if (null !== $this->logger) {
diff --git a/Http/HttpUtils.php b/Http/HttpUtils.php
index 6b674aa..51168cc 100644
--- a/Http/HttpUtils.php
+++ b/Http/HttpUtils.php
@@ -13,7 +13,7 @@ namespace Symfony\Component\Security\Http;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Component\Routing\RouterInterface;
/**
* Encapsulates the logic needed to create sub-requests, redirect the user, and match URLs.
@@ -22,16 +22,16 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
*/
class HttpUtils
{
- private $urlGenerator;
+ private $router;
/**
* Constructor.
*
- * @param UrlGeneratorInterface $urlGenerator An UrlGeneratorInterface instance
+ * @param RouterInterface $router An RouterInterface instance
*/
- public function __construct(UrlGeneratorInterface $urlGenerator = null)
+ public function __construct(RouterInterface $router = null)
{
- $this->urlGenerator = $urlGenerator;
+ $this->router = $router;
}
/**
@@ -48,6 +48,19 @@ class HttpUtils
if (0 === strpos($path, '/')) {
$path = $request->getUriForPath($path);
} elseif (0 !== strpos($path, 'http')) {
+ // hack (don't have a better solution for now)
+ $context = $this->router->getContext();
+ try {
+ $parameters = $this->router->match($request->getPathInfo());
+ } catch (\Exception $e) {
+ }
+
+ if (isset($parameters['_locale'])) {
+ $context->setParameter('_locale', $parameters['_locale']);
+ } elseif ($session = $request->getSession()) {
+ $context->setParameter('_locale', $session->getLocale());
+ }
+
$path = $this->generateUrl($path, true);
}
@@ -82,7 +95,13 @@ class HttpUtils
public function checkRequestPath(Request $request, $path)
{
if ('/' !== $path[0]) {
- $path = preg_replace('#'.preg_quote($request->getBaseUrl(), '#').'#', '', $this->generateUrl($path));
+ try {
+ $parameters = $this->router->match($request->getPathInfo());
+
+ return $path === $parameters['_route'];
+ } catch (\Exception $e) {
+ return false;
+ }
}
return $path === $request->getPathInfo();
@@ -90,10 +109,10 @@ class HttpUtils
private function generateUrl($route, $absolute = false)
{
- if (null === $this->urlGenerator) {
- throw new \LogicException('You must provide a UrlGeneratorInterface instance to be able to use routes.');
+ if (null === $this->router) {
+ throw new \LogicException('You must provide a RouterInterface instance to be able to use routes.');
}
- return $this->urlGenerator->generate($route, array(), $absolute);
+ return $this->router->generate($route, array(), $absolute);
}
}
diff --git a/Http/RememberMe/AbstractRememberMeServices.php b/Http/RememberMe/AbstractRememberMeServices.php
index 7d273b9..2118a86 100644
--- a/Http/RememberMe/AbstractRememberMeServices.php
+++ b/Http/RememberMe/AbstractRememberMeServices.php
@@ -285,7 +285,7 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
return true;
}
- $parameter = $request->request->get($this->options['remember_me_parameter']);
+ $parameter = $request->request->get($this->options['remember_me_parameter'], null, true);
if ($parameter === null && null !== $this->logger) {
$this->logger->debug(sprintf('Did not send remember-me cookie (remember-me parameter "%s" was not sent).', $this->options['remember_me_parameter']));