Merge branch '2.7'
* 2.7: added type-hint [Security] removed usage of the deprecated SecurityContextInterface [Form] fixed deprecation triggers, removed usage of deprecated features [EventDispatcher] fixed deprecation notices in the EventDispatcher Component [HttpFoundation] maked a test as being for deprecated feature added missing error_reporting [Yaml] maked a test as being for deprecated feature [Yaml] removed deprecation notices on internal constant [Security] moved test files into the right place [HttpKernel] fixed deprecation notices for ESI classes [Form] moved a deprecation notice [Form] fixed the CSRF extension to allow using only the new interfaces [Form] tweaked a deprecation message [Validator] Add a Russian translation for the checkDNS option in the URL validator [Validator] Add a Slovenian translation for the checkDNS option in the URL validator [Validator] Add a Polish translation for the checkDNS option in the URL validator. fixed typo added missing support for factories in console descriptions [FrameworkBundle] fixed missing information in some descriptors Conflicts: src/Symfony/Bridge/Twig/composer.json src/Symfony/Bundle/SecurityBundle/composer.json src/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php src/Symfony/Component/Yaml/Tests/YamlTest.php
This commit is contained in:
commit
e1f30c4164
@ -12,7 +12,7 @@
|
||||
namespace Symfony\Bridge\Twig\Extension;
|
||||
|
||||
use Symfony\Component\Security\Acl\Voter\FieldVote;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
|
||||
/**
|
||||
* SecurityExtension exposes security context features.
|
||||
@ -21,16 +21,16 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
*/
|
||||
class SecurityExtension extends \Twig_Extension
|
||||
{
|
||||
private $context;
|
||||
private $securityChecker;
|
||||
|
||||
public function __construct(SecurityContextInterface $context = null)
|
||||
public function __construct(AuthorizationCheckerInterface $securityChecker = null)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->securityChecker = $securityChecker;
|
||||
}
|
||||
|
||||
public function isGranted($role, $object = null, $field = null)
|
||||
{
|
||||
if (null === $this->context) {
|
||||
if (null === $this->securityChecker) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ class SecurityExtension extends \Twig_Extension
|
||||
$object = new FieldVote($object, $field);
|
||||
}
|
||||
|
||||
return $this->context->isGranted($role, $object);
|
||||
return $this->securityChecker->isGranted($role, $object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
@ -184,14 +185,15 @@ class JsonDescriptor extends Descriptor
|
||||
|
||||
return array(
|
||||
'path' => $route->getPath(),
|
||||
'pathRegex' => $route->compile()->getRegex(),
|
||||
'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY',
|
||||
'hostRegex' => '' !== $route->getHost() ? $route->compile()->getHostRegex() : '',
|
||||
'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY',
|
||||
'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY',
|
||||
'class' => get_class($route),
|
||||
'defaults' => $route->getDefaults(),
|
||||
'requirements' => $requirements ?: 'NO CUSTOM',
|
||||
'options' => $route->getOptions(),
|
||||
'pathRegex' => $route->compile()->getRegex(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -208,9 +210,39 @@ class JsonDescriptor extends Descriptor
|
||||
'scope' => $definition->getScope(),
|
||||
'public' => $definition->isPublic(),
|
||||
'synthetic' => $definition->isSynthetic(),
|
||||
'lazy' => $definition->isLazy(),
|
||||
'synchronized' => $definition->isSynchronized(),
|
||||
'abstract' => $definition->isAbstract(),
|
||||
'file' => $definition->getFile(),
|
||||
);
|
||||
|
||||
if ($definition->getFactoryClass()) {
|
||||
$data['factory_class'] = $definition->getFactoryClass();
|
||||
}
|
||||
|
||||
if ($definition->getFactoryService()) {
|
||||
$data['factory_service'] = $definition->getFactoryService();
|
||||
}
|
||||
|
||||
if ($definition->getFactoryMethod()) {
|
||||
$data['factory_method'] = $definition->getFactoryMethod();
|
||||
}
|
||||
|
||||
if ($factory = $definition->getFactory()) {
|
||||
if (is_array($factory)) {
|
||||
if ($factory[0] instanceof Reference) {
|
||||
$data['factory_service'] = (string) $factory[0];
|
||||
} elseif ($factory[0] instanceof Definition) {
|
||||
throw new \InvalidArgumentException('Factory is not describable.');
|
||||
} else {
|
||||
$data['factory_class'] = $factory[0];
|
||||
}
|
||||
$data['factory_method'] = $factory[1];
|
||||
} else {
|
||||
$data['factory_function'] = $factory;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$omitTags) {
|
||||
$data['tags'] = array();
|
||||
if (count($definition->getTags())) {
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
@ -52,14 +53,15 @@ class MarkdownDescriptor extends Descriptor
|
||||
unset($requirements['_scheme'], $requirements['_method']);
|
||||
|
||||
$output = '- Path: '.$route->getPath()
|
||||
."\n".'- Path Regex: '.$route->compile()->getRegex()
|
||||
."\n".'- Host: '.('' !== $route->getHost() ? $route->getHost() : 'ANY')
|
||||
."\n".'- Host Regex: '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')
|
||||
."\n".'- Scheme: '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')
|
||||
."\n".'- Method: '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')
|
||||
."\n".'- Class: '.get_class($route)
|
||||
."\n".'- Defaults: '.$this->formatRouterConfig($route->getDefaults())
|
||||
."\n".'- Requirements: '.$this->formatRouterConfig($requirements) ?: 'NONE'
|
||||
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions())
|
||||
."\n".'- Path-Regex: '.$route->compile()->getRegex();
|
||||
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions());
|
||||
|
||||
$this->write(isset($options['name'])
|
||||
? $options['name']."\n".str_repeat('-', strlen($options['name']))."\n\n".$output
|
||||
@ -179,12 +181,42 @@ class MarkdownDescriptor extends Descriptor
|
||||
$output = '- Class: `'.$definition->getClass().'`'
|
||||
."\n".'- Scope: `'.$definition->getScope().'`'
|
||||
."\n".'- Public: '.($definition->isPublic() ? 'yes' : 'no')
|
||||
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no');
|
||||
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no')
|
||||
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')
|
||||
."\n".'- Synchronized: '.($definition->isSynchronized() ? 'yes' : 'no')
|
||||
."\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no');
|
||||
|
||||
if ($definition->getFile()) {
|
||||
$output .= "\n".'- File: `'.$definition->getFile().'`';
|
||||
}
|
||||
|
||||
if ($definition->getFactoryClass()) {
|
||||
$output .= "\n".'- Factory Class: `'.$definition->getFactoryClass().'`';
|
||||
}
|
||||
|
||||
if ($definition->getFactoryService()) {
|
||||
$output .= "\n".'- Factory Service: `'.$definition->getFactoryService().'`';
|
||||
}
|
||||
|
||||
if ($definition->getFactoryMethod()) {
|
||||
$output .= "\n".'- Factory Method: `'.$definition->getFactoryMethod().'`';
|
||||
}
|
||||
|
||||
if ($factory = $definition->getFactory()) {
|
||||
if (is_array($factory)) {
|
||||
if ($factory[0] instanceof Reference) {
|
||||
$output .= "\n".'- Factory Service: `'.$factory[0].'`';
|
||||
} elseif ($factory[0] instanceof Definition) {
|
||||
throw new \InvalidArgumentException('Factory is not describable.');
|
||||
} else {
|
||||
$output .= "\n".'- Factory Class: `'.$factory[0].'`';
|
||||
}
|
||||
$output .= "\n".'- Factory Method: `'.$factory[1].'`';
|
||||
} else {
|
||||
$output .= "\n".'- Factory Function: `'.$factory.'`';
|
||||
}
|
||||
}
|
||||
|
||||
if (!(isset($options['omit_tags']) && $options['omit_tags'])) {
|
||||
foreach ($definition->getTags() as $tagName => $tagData) {
|
||||
foreach ($tagData as $parameters) {
|
||||
|
@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
@ -75,14 +76,15 @@ class TextDescriptor extends Descriptor
|
||||
// fixme: values were originally written as raw
|
||||
$description = array(
|
||||
'<comment>Path</comment> '.$route->getPath(),
|
||||
'<comment>Path Regex</comment> '.$route->compile()->getRegex(),
|
||||
'<comment>Host</comment> '.('' !== $route->getHost() ? $route->getHost() : 'ANY'),
|
||||
'<comment>Host Regex</comment> '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : ''),
|
||||
'<comment>Scheme</comment> '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'),
|
||||
'<comment>Method</comment> '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'),
|
||||
'<comment>Class</comment> '.get_class($route),
|
||||
'<comment>Defaults</comment> '.$this->formatRouterConfig($route->getDefaults()),
|
||||
'<comment>Requirements</comment> '.$this->formatRouterConfig($requirements) ?: 'NO CUSTOM',
|
||||
'<comment>Options</comment> '.$this->formatRouterConfig($route->getOptions()),
|
||||
'<comment>Path-Regex</comment> '.$route->compile()->getRegex(),
|
||||
);
|
||||
|
||||
if (isset($options['name'])) {
|
||||
@ -90,10 +92,6 @@ class TextDescriptor extends Descriptor
|
||||
array_unshift($description, $this->formatSection('router', sprintf('Route "%s"', $options['name'])));
|
||||
}
|
||||
|
||||
if (null !== $route->compile()->getHostRegex()) {
|
||||
$description[] = '<comment>Host-Regex</comment> '.$route->compile()->getHostRegex();
|
||||
}
|
||||
|
||||
$this->writeText(implode("\n", $description)."\n", $options);
|
||||
}
|
||||
|
||||
@ -264,7 +262,40 @@ class TextDescriptor extends Descriptor
|
||||
$description[] = sprintf('<comment>Scope</comment> %s', $definition->getScope());
|
||||
$description[] = sprintf('<comment>Public</comment> %s', $definition->isPublic() ? 'yes' : 'no');
|
||||
$description[] = sprintf('<comment>Synthetic</comment> %s', $definition->isSynthetic() ? 'yes' : 'no');
|
||||
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
|
||||
$description[] = sprintf('<comment>Lazy</comment> %s', $definition->isLazy() ? 'yes' : 'no');
|
||||
$description[] = sprintf('<comment>Synchronized</comment> %s', $definition->isSynchronized() ? 'yes' : 'no');
|
||||
$description[] = sprintf('<comment>Abstract</comment> %s', $definition->isAbstract() ? 'yes' : 'no');
|
||||
|
||||
if ($definition->getFile()) {
|
||||
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
|
||||
}
|
||||
|
||||
if ($definition->getFactoryClass()) {
|
||||
$description[] = sprintf('<comment>Factory Class</comment> %s', $definition->getFactoryClass());
|
||||
}
|
||||
|
||||
if ($definition->getFactoryService()) {
|
||||
$description[] = sprintf('<comment>Factory Service</comment> %s', $definition->getFactoryService());
|
||||
}
|
||||
|
||||
if ($definition->getFactoryMethod()) {
|
||||
$description[] = sprintf('<comment>Factory Method</comment> %s', $definition->getFactoryMethod());
|
||||
}
|
||||
|
||||
if ($factory = $definition->getFactory()) {
|
||||
if (is_array($factory)) {
|
||||
if ($factory[0] instanceof Reference) {
|
||||
$description[] = sprintf('<comment>Factory Service</comment> %s', $factory[0]);
|
||||
} elseif ($factory[0] instanceof Definition) {
|
||||
throw new \InvalidArgumentException('Factory is not describable.');
|
||||
} else {
|
||||
$description[] = sprintf('<comment>Factory Class</comment> %s', $factory[0]);
|
||||
}
|
||||
$description[] = sprintf('<comment>Factory Method</comment> %s', $factory[1]);
|
||||
} else {
|
||||
$description[] = sprintf('<comment>Factory Function</comment> %s', $factory);
|
||||
}
|
||||
}
|
||||
|
||||
$this->writeText(implode("\n", $description)."\n", $options);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
<service id="form.type_extension.csrf" class="Symfony\Component\Form\Extension\Csrf\Type\FormTypeCsrfExtension">
|
||||
<tag name="form.type_extension" alias="form" />
|
||||
<argument type="service" id="form.csrf_provider" />
|
||||
<argument type="service" id="security.csrf.token_manager" />
|
||||
<argument>%form.type_extension.csrf.enabled%</argument>
|
||||
<argument>%form.type_extension.csrf.field_name%</argument>
|
||||
<argument type="service" id="translator.default" />
|
||||
|
@ -114,7 +114,7 @@
|
||||
|
||||
<service id="templating.form.renderer" class="%templating.form.renderer.class%" public="false">
|
||||
<argument type="service" id="templating.form.engine" />
|
||||
<argument type="service" id="form.csrf_provider" on-invalid="null" />
|
||||
<argument type="service" id="security.csrf.token_manager" on-invalid="null" />
|
||||
</service>
|
||||
|
||||
<service id="templating.globals" class="%templating.globals.class%">
|
||||
|
@ -5,7 +5,12 @@
|
||||
"scope": "container",
|
||||
"public": true,
|
||||
"synthetic": false,
|
||||
"lazy": true,
|
||||
"synchronized": true,
|
||||
"abstract": true,
|
||||
"file": null,
|
||||
"factory_class": "Full\\Qualified\\FactoryClass",
|
||||
"factory_method": "get",
|
||||
"tags": [
|
||||
|
||||
]
|
||||
|
@ -11,6 +11,11 @@ definition_1
|
||||
- Scope: `container`
|
||||
- Public: yes
|
||||
- Synthetic: no
|
||||
- Lazy: yes
|
||||
- Synchronized: yes
|
||||
- Abstract: yes
|
||||
- Factory Class: `Full\Qualified\FactoryClass`
|
||||
- Factory Method: `get`
|
||||
|
||||
|
||||
Aliases
|
||||
|
@ -5,7 +5,12 @@
|
||||
"scope": "container",
|
||||
"public": true,
|
||||
"synthetic": false,
|
||||
"lazy": true,
|
||||
"synchronized": true,
|
||||
"abstract": true,
|
||||
"file": null,
|
||||
"factory_class": "Full\\Qualified\\FactoryClass",
|
||||
"factory_method": "get",
|
||||
"tags": [
|
||||
|
||||
]
|
||||
@ -15,7 +20,12 @@
|
||||
"scope": "container",
|
||||
"public": false,
|
||||
"synthetic": true,
|
||||
"lazy": false,
|
||||
"synchronized": false,
|
||||
"abstract": false,
|
||||
"file": "\/path\/to\/file",
|
||||
"factory_service": "factory.service",
|
||||
"factory_method": "get",
|
||||
"tags": [
|
||||
{
|
||||
"name": "tag1",
|
||||
|
@ -11,6 +11,11 @@ definition_1
|
||||
- Scope: `container`
|
||||
- Public: yes
|
||||
- Synthetic: no
|
||||
- Lazy: yes
|
||||
- Synchronized: yes
|
||||
- Abstract: yes
|
||||
- Factory Class: `Full\Qualified\FactoryClass`
|
||||
- Factory Method: `get`
|
||||
|
||||
definition_2
|
||||
~~~~~~~~~~~~
|
||||
@ -19,7 +24,12 @@ definition_2
|
||||
- Scope: `container`
|
||||
- Public: no
|
||||
- Synthetic: yes
|
||||
- Lazy: no
|
||||
- Synchronized: no
|
||||
- Abstract: no
|
||||
- File: `/path/to/file`
|
||||
- Factory Service: `factory.service`
|
||||
- Factory Method: `get`
|
||||
- Tag: `tag1`
|
||||
- Attr1: val1
|
||||
- Attr2: val2
|
||||
|
@ -5,7 +5,12 @@
|
||||
"scope": "container",
|
||||
"public": false,
|
||||
"synthetic": true,
|
||||
"lazy": false,
|
||||
"synchronized": false,
|
||||
"abstract": false,
|
||||
"file": "\/path\/to\/file",
|
||||
"factory_service": "factory.service",
|
||||
"factory_method": "get",
|
||||
"tags": [
|
||||
{
|
||||
"name": "tag1",
|
||||
|
@ -11,7 +11,12 @@ definition_2
|
||||
- Scope: `container`
|
||||
- Public: no
|
||||
- Synthetic: yes
|
||||
- Lazy: no
|
||||
- Synchronized: no
|
||||
- Abstract: no
|
||||
- File: `/path/to/file`
|
||||
- Factory Service: `factory.service`
|
||||
- Factory Method: `get`
|
||||
- Tag: `tag1`
|
||||
- Attr1: val1
|
||||
- Attr2: val2
|
||||
|
@ -5,7 +5,12 @@
|
||||
"scope": "container",
|
||||
"public": false,
|
||||
"synthetic": true,
|
||||
"file": "\/path\/to\/file"
|
||||
"lazy": false,
|
||||
"synchronized": false,
|
||||
"abstract": false,
|
||||
"file": "\/path\/to\/file",
|
||||
"factory_service": "factory.service",
|
||||
"factory_method": "get"
|
||||
}
|
||||
],
|
||||
"tag2": [
|
||||
@ -14,7 +19,12 @@
|
||||
"scope": "container",
|
||||
"public": false,
|
||||
"synthetic": true,
|
||||
"file": "\/path\/to\/file"
|
||||
"lazy": false,
|
||||
"synchronized": false,
|
||||
"abstract": false,
|
||||
"file": "\/path\/to\/file",
|
||||
"factory_service": "factory.service",
|
||||
"factory_method": "get"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -11,7 +11,12 @@ definition_2
|
||||
- Scope: `container`
|
||||
- Public: no
|
||||
- Synthetic: yes
|
||||
- Lazy: no
|
||||
- Synchronized: no
|
||||
- Abstract: no
|
||||
- File: `/path/to/file`
|
||||
- Factory Service: `factory.service`
|
||||
- Factory Method: `get`
|
||||
|
||||
|
||||
tag2
|
||||
@ -24,4 +29,9 @@ definition_2
|
||||
- Scope: `container`
|
||||
- Public: no
|
||||
- Synthetic: yes
|
||||
- Lazy: no
|
||||
- Synchronized: no
|
||||
- Abstract: no
|
||||
- File: `/path/to/file`
|
||||
- Factory Service: `factory.service`
|
||||
- Factory Method: `get`
|
||||
|
@ -3,7 +3,12 @@
|
||||
"scope": "container",
|
||||
"public": true,
|
||||
"synthetic": false,
|
||||
"lazy": true,
|
||||
"synchronized": true,
|
||||
"abstract": true,
|
||||
"file": null,
|
||||
"factory_class": "Full\\Qualified\\FactoryClass",
|
||||
"factory_method": "get",
|
||||
"tags": [
|
||||
|
||||
]
|
||||
|
@ -1,4 +1,9 @@
|
||||
- Class: `Full\Qualified\Class1`
|
||||
- Scope: `container`
|
||||
- Public: yes
|
||||
- Synthetic: no
|
||||
- Synthetic: no
|
||||
- Lazy: yes
|
||||
- Synchronized: yes
|
||||
- Abstract: yes
|
||||
- Factory Class: `Full\Qualified\FactoryClass`
|
||||
- Factory Method: `get`
|
@ -4,4 +4,8 @@
|
||||
<comment>Scope</comment> container
|
||||
<comment>Public</comment> yes
|
||||
<comment>Synthetic</comment> no
|
||||
<comment>Required File</comment> -
|
||||
<comment>Lazy</comment> yes
|
||||
<comment>Synchronized</comment> yes
|
||||
<comment>Abstract</comment> yes
|
||||
<comment>Factory Class</comment> Full\Qualified\FactoryClass
|
||||
<comment>Factory Method</comment> get
|
||||
|
@ -3,7 +3,12 @@
|
||||
"scope": "container",
|
||||
"public": false,
|
||||
"synthetic": true,
|
||||
"lazy": false,
|
||||
"synchronized": false,
|
||||
"abstract": false,
|
||||
"file": "\/path\/to\/file",
|
||||
"factory_service": "factory.service",
|
||||
"factory_method": "get",
|
||||
"tags": [
|
||||
{
|
||||
"name": "tag1",
|
||||
|
@ -2,7 +2,12 @@
|
||||
- Scope: `container`
|
||||
- Public: no
|
||||
- Synthetic: yes
|
||||
- Lazy: no
|
||||
- Synchronized: no
|
||||
- Abstract: no
|
||||
- File: `/path/to/file`
|
||||
- Factory Service: `factory.service`
|
||||
- Factory Method: `get`
|
||||
- Tag: `tag1`
|
||||
- Attr1: val1
|
||||
- Attr2: val2
|
||||
|
@ -7,4 +7,9 @@
|
||||
<comment>Scope</comment> container
|
||||
<comment>Public</comment> no
|
||||
<comment>Synthetic</comment> yes
|
||||
<comment>Lazy</comment> no
|
||||
<comment>Synchronized</comment> no
|
||||
<comment>Abstract</comment> no
|
||||
<comment>Required File</comment> /path/to/file
|
||||
<comment>Factory Service</comment> factory.service
|
||||
<comment>Factory Method</comment> get
|
||||
|
@ -1,6 +1,8 @@
|
||||
{
|
||||
"path": "\/hello\/{name}",
|
||||
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s",
|
||||
"host": "localhost",
|
||||
"hostRegex": "#^localhost$#s",
|
||||
"scheme": "http|https",
|
||||
"method": "GET|HEAD",
|
||||
"class": "Symfony\\Component\\Routing\\Route",
|
||||
@ -14,6 +16,5 @@
|
||||
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
|
||||
"opt1": "val1",
|
||||
"opt2": "val2"
|
||||
},
|
||||
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
- Path: /hello/{name}
|
||||
- Path Regex: #^/hello(?:/(?P<name>[a-z]+))?$#s
|
||||
- Host: localhost
|
||||
- Host Regex: #^localhost$#s
|
||||
- Scheme: http|https
|
||||
- Method: GET|HEAD
|
||||
- Class: Symfony\Component\Routing\Route
|
||||
|
@ -1,5 +1,7 @@
|
||||
<comment>Path</comment> /hello/{name}
|
||||
<comment>Path Regex</comment> #^/hello(?:/(?P<name>[a-z]+))?$#s
|
||||
<comment>Host</comment> localhost
|
||||
<comment>Host Regex</comment> #^localhost$#s
|
||||
<comment>Scheme</comment> http|https
|
||||
<comment>Method</comment> GET|HEAD
|
||||
<comment>Class</comment> Symfony\Component\Routing\Route
|
||||
@ -7,6 +9,4 @@
|
||||
<comment>Requirements</comment> name: [a-z]+
|
||||
<comment>Options</comment> compiler_class: Symfony\Component\Routing\RouteCompiler
|
||||
opt1: val1
|
||||
opt2: val2
|
||||
<comment>Path-Regex</comment> #^/hello(?:/(?P<name>[a-z]+))?$#s
|
||||
<comment>Host-Regex</comment> #^localhost$#s
|
||||
opt2: val2
|
@ -1,6 +1,8 @@
|
||||
{
|
||||
"path": "\/name\/add",
|
||||
"pathRegex": "#^\/name\/add$#s",
|
||||
"host": "localhost",
|
||||
"hostRegex": "#^localhost$#s",
|
||||
"scheme": "http|https",
|
||||
"method": "PUT|POST",
|
||||
"class": "Symfony\\Component\\Routing\\Route",
|
||||
@ -12,6 +14,5 @@
|
||||
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
|
||||
"opt1": "val1",
|
||||
"opt2": "val2"
|
||||
},
|
||||
"pathRegex": "#^\/name\/add$#s"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
- Path: /name/add
|
||||
- Path Regex: #^/name/add$#s
|
||||
- Host: localhost
|
||||
- Host Regex: #^localhost$#s
|
||||
- Scheme: http|https
|
||||
- Method: PUT|POST
|
||||
- Class: Symfony\Component\Routing\Route
|
||||
|
@ -1,5 +1,7 @@
|
||||
<comment>Path</comment> /name/add
|
||||
<comment>Path Regex</comment> #^/name/add$#s
|
||||
<comment>Host</comment> localhost
|
||||
<comment>Host Regex</comment> #^localhost$#s
|
||||
<comment>Scheme</comment> http|https
|
||||
<comment>Method</comment> PUT|POST
|
||||
<comment>Class</comment> Symfony\Component\Routing\Route
|
||||
@ -7,6 +9,4 @@
|
||||
<comment>Requirements</comment>
|
||||
<comment>Options</comment> compiler_class: Symfony\Component\Routing\RouteCompiler
|
||||
opt1: val1
|
||||
opt2: val2
|
||||
<comment>Path-Regex</comment> #^/name/add$#s
|
||||
<comment>Host-Regex</comment> #^localhost$#s
|
||||
opt2: val2
|
@ -1,7 +1,9 @@
|
||||
{
|
||||
"route_1": {
|
||||
"path": "\/hello\/{name}",
|
||||
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s",
|
||||
"host": "localhost",
|
||||
"hostRegex": "#^localhost$#s",
|
||||
"scheme": "http|https",
|
||||
"method": "GET|HEAD",
|
||||
"class": "Symfony\\Component\\Routing\\Route",
|
||||
@ -15,12 +17,13 @@
|
||||
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
|
||||
"opt1": "val1",
|
||||
"opt2": "val2"
|
||||
},
|
||||
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s"
|
||||
}
|
||||
},
|
||||
"route_2": {
|
||||
"path": "\/name\/add",
|
||||
"pathRegex": "#^\/name\/add$#s",
|
||||
"host": "localhost",
|
||||
"hostRegex": "#^localhost$#s",
|
||||
"scheme": "http|https",
|
||||
"method": "PUT|POST",
|
||||
"class": "Symfony\\Component\\Routing\\Route",
|
||||
@ -32,7 +35,6 @@
|
||||
"compiler_class": "Symfony\\Component\\Routing\\RouteCompiler",
|
||||
"opt1": "val1",
|
||||
"opt2": "val2"
|
||||
},
|
||||
"pathRegex": "#^\/name\/add$#s"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ route_1
|
||||
-------
|
||||
|
||||
- Path: /hello/{name}
|
||||
- Path Regex: #^/hello(?:/(?P<name>[a-z]+))?$#s
|
||||
- Host: localhost
|
||||
- Host Regex: #^localhost$#s
|
||||
- Scheme: http|https
|
||||
- Method: GET|HEAD
|
||||
- Class: Symfony\Component\Routing\Route
|
||||
@ -16,7 +18,9 @@ route_2
|
||||
-------
|
||||
|
||||
- Path: /name/add
|
||||
- Path Regex: #^/name/add$#s
|
||||
- Host: localhost
|
||||
- Host Regex: #^localhost$#s
|
||||
- Scheme: http|https
|
||||
- Method: PUT|POST
|
||||
- Class: Symfony\Component\Routing\Route
|
||||
|
@ -52,7 +52,7 @@
|
||||
<services>
|
||||
<service id="security.authentication.listener.anonymous" class="%security.authentication.listener.anonymous.class%" public="false">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument /> <!-- Key -->
|
||||
<argument type="service" id="logger" on-invalid="null" />
|
||||
<argument type="service" id="security.authentication.manager" />
|
||||
@ -82,7 +82,7 @@
|
||||
|
||||
<service id="security.context_listener" class="%security.context_listener.class%" public="false">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument type="collection"></argument>
|
||||
<argument /> <!-- Provider Key -->
|
||||
<argument type="service" id="logger" on-invalid="null" />
|
||||
@ -90,7 +90,7 @@
|
||||
</service>
|
||||
|
||||
<service id="security.logout_listener" class="%security.logout_listener.class%" public="false" abstract="true">
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument type="service" id="security.http_utils" />
|
||||
<argument type="service" id="security.logout.success_handler" />
|
||||
<argument /> <!-- Options -->
|
||||
@ -109,7 +109,7 @@
|
||||
|
||||
<service id="security.authentication.listener.abstract" abstract="true" public="false">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument type="service" id="security.authentication.manager" />
|
||||
<argument type="service" id="security.authentication.session_strategy" />
|
||||
<argument type="service" id="security.http_utils" />
|
||||
@ -167,7 +167,7 @@
|
||||
|
||||
<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.token_storage" />
|
||||
<argument type="service" id="security.authentication.manager" />
|
||||
<argument /> <!-- Provider-shared Key -->
|
||||
<argument /> <!-- Authenticator -->
|
||||
@ -177,7 +177,7 @@
|
||||
|
||||
<service id="security.authentication.listener.x509" class="%security.authentication.listener.x509.class%" public="false" abstract="true">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument type="service" id="security.authentication.manager" />
|
||||
<argument /> <!-- Provider-shared Key -->
|
||||
<argument /> <!-- x509 user -->
|
||||
@ -188,7 +188,7 @@
|
||||
|
||||
<service id="security.authentication.listener.remote_user" class="Symfony\Component\Security\Http\Firewall\RemoteUserAuthenticationListener" public="false" abstract="true">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument type="service" id="security.authentication.manager" />
|
||||
<argument /> <!-- Provider-shared Key -->
|
||||
<argument /> <!-- REMOTE_USER server env var -->
|
||||
@ -198,7 +198,7 @@
|
||||
|
||||
<service id="security.authentication.listener.basic" class="%security.authentication.listener.basic.class%" public="false" abstract="true">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument type="service" id="security.authentication.manager" />
|
||||
<argument /> <!-- Provider-shared Key -->
|
||||
<argument /> <!-- Entry Point -->
|
||||
@ -207,7 +207,7 @@
|
||||
|
||||
<service id="security.authentication.listener.digest" class="%security.authentication.listener.digest.class%" public="false" abstract="true">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument /> <!-- User Provider -->
|
||||
<argument /> <!-- Provider-shared Key -->
|
||||
<argument /> <!-- Entry Point -->
|
||||
@ -235,7 +235,7 @@
|
||||
|
||||
<service id="security.exception_listener" class="%security.exception_listener.class%" public="false" abstract="true">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument type="service" id="security.authentication.trust_resolver" />
|
||||
<argument type="service" id="security.http_utils" />
|
||||
<argument />
|
||||
@ -247,7 +247,7 @@
|
||||
|
||||
<service id="security.authentication.switchuser_listener" class="%security.authentication.switchuser_listener.class%" public="false" abstract="true">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument /> <!-- User Provider -->
|
||||
<argument type="service" id="security.user_checker" />
|
||||
<argument /> <!-- Provider Key -->
|
||||
@ -260,7 +260,7 @@
|
||||
|
||||
<service id="security.access_listener" class="%security.access_listener.class%" public="false">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument type="service" id="security.access.decision_manager" />
|
||||
<argument type="service" id="security.access_map" />
|
||||
<argument type="service" id="security.authentication.manager" />
|
||||
|
@ -19,7 +19,7 @@
|
||||
<services>
|
||||
<service id="security.authentication.listener.rememberme" class="%security.authentication.listener.rememberme.class%" public="false" abstract="true">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="security.token_storage" />
|
||||
<argument type="service" id="security.authentication.rememberme" />
|
||||
<argument type="service" id="security.authentication.manager" />
|
||||
<argument type="service" id="logger" on-invalid="null" />
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
<service id="templating.helper.security" class="%templating.helper.security.class%">
|
||||
<tag name="templating.helper" alias="security" />
|
||||
<argument type="service" id="security.context" on-invalid="ignore" />
|
||||
<argument type="service" id="security.authorization_checker" on-invalid="ignore" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
<service id="twig.extension.security" class="%twig.extension.security.class%" public="false">
|
||||
<tag name="twig.extension" />
|
||||
<argument type="service" id="security.context" on-invalid="ignore" />
|
||||
<argument type="service" id="security.authorization_checker" on-invalid="ignore" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
@ -13,30 +13,25 @@ namespace Symfony\Bundle\SecurityBundle\Templating\Helper;
|
||||
|
||||
use Symfony\Component\Security\Acl\Voter\FieldVote;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
|
||||
/**
|
||||
* SecurityHelper provides read-only access to the security context.
|
||||
* SecurityHelper provides read-only access to the security checker.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class SecurityHelper extends Helper
|
||||
{
|
||||
private $context;
|
||||
private $securityChecker;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param SecurityContextInterface $context A SecurityContext instance
|
||||
*/
|
||||
public function __construct(SecurityContextInterface $context = null)
|
||||
public function __construct(AuthorizationCheckerInterface $securityChecker = null)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->securityChecker = $securityChecker;
|
||||
}
|
||||
|
||||
public function isGranted($role, $object = null, $field = null)
|
||||
{
|
||||
if (null === $this->context) {
|
||||
if (null === $this->securityChecker) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -44,7 +39,7 @@ class SecurityHelper extends Helper
|
||||
$object = new FieldVote($object, $field);
|
||||
}
|
||||
|
||||
return $this->context->isGranted($role, $object);
|
||||
return $this->securityChecker->isGranted($role, $object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,9 +25,9 @@ class SecurityDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEmpty($collector->getUser());
|
||||
}
|
||||
|
||||
/** @dataProvider provideTokenStorage */
|
||||
public function testCollectWhenAuthenticationTokenIsNull($tokenStorage)
|
||||
public function testCollectWhenAuthenticationTokenIsNull()
|
||||
{
|
||||
$tokenStorage = new TokenStorage();
|
||||
$collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy());
|
||||
$collector->collect($this->getRequest(), $this->getResponse());
|
||||
|
||||
@ -40,12 +40,21 @@ class SecurityDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEmpty($collector->getUser());
|
||||
}
|
||||
|
||||
public function provideTokenStorage()
|
||||
public function testLegacyCollectWhenAuthenticationTokenIsNull()
|
||||
{
|
||||
return array(
|
||||
array(new TokenStorage()),
|
||||
array($this->getMock('Symfony\Component\Security\Core\SecurityContextInterface')),
|
||||
);
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy());
|
||||
$collector->collect($this->getRequest(), $this->getResponse());
|
||||
|
||||
$this->assertTrue($collector->isEnabled());
|
||||
$this->assertFalse($collector->isAuthenticated());
|
||||
$this->assertNull($collector->getTokenClass());
|
||||
$this->assertTrue($collector->supportsRoleHierarchy());
|
||||
$this->assertCount(0, $collector->getRoles());
|
||||
$this->assertCount(0, $collector->getInheritedRoles());
|
||||
$this->assertEmpty($collector->getUser());
|
||||
}
|
||||
|
||||
/** @dataProvider provideRoles */
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller;
|
||||
|
||||
use Symfony\Component\Security\Core\SecurityContext;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
@ -21,15 +21,15 @@ class LocalizedController extends ContainerAware
|
||||
public function loginAction(Request $request)
|
||||
{
|
||||
// get the login error if there is one
|
||||
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
|
||||
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
|
||||
if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) {
|
||||
$error = $request->attributes->get(Security::AUTHENTICATION_ERROR);
|
||||
} else {
|
||||
$error = $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
|
||||
$error = $request->getSession()->get(Security::AUTHENTICATION_ERROR);
|
||||
}
|
||||
|
||||
return $this->container->get('templating')->renderResponse('FormLoginBundle:Localized:login.html.twig', array(
|
||||
// last username entered by the user
|
||||
'last_username' => $request->getSession()->get(SecurityContext::LAST_USERNAME),
|
||||
'last_username' => $request->getSession()->get(Security::LAST_USERNAME),
|
||||
'error' => $error,
|
||||
));
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\SecurityContext;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
|
||||
class LoginController extends ContainerAware
|
||||
@ -22,15 +22,15 @@ class LoginController extends ContainerAware
|
||||
public function loginAction(Request $request)
|
||||
{
|
||||
// get the login error if there is one
|
||||
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
|
||||
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
|
||||
if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) {
|
||||
$error = $request->attributes->get(Security::AUTHENTICATION_ERROR);
|
||||
} else {
|
||||
$error = $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
|
||||
$error = $request->getSession()->get(Security::AUTHENTICATION_ERROR);
|
||||
}
|
||||
|
||||
return $this->container->get('templating')->renderResponse('FormLoginBundle:Login:login.html.twig', array(
|
||||
// last username entered by the user
|
||||
'last_username' => $request->getSession()->get(SecurityContext::LAST_USERNAME),
|
||||
'last_username' => $request->getSession()->get(Security::LAST_USERNAME),
|
||||
'error' => $error,
|
||||
));
|
||||
}
|
||||
|
@ -114,7 +114,7 @@
|
||||
|
||||
<service id="twig.form.renderer" class="%twig.form.renderer.class%" public="false">
|
||||
<argument type="service" id="twig.form.engine" />
|
||||
<argument type="service" id="form.csrf_provider" on-invalid="null" />
|
||||
<argument type="service" id="security.csrf.token_manager" on-invalid="null" />
|
||||
</service>
|
||||
|
||||
<service id="twig.translation.extractor" class="%twig.translation.extractor.class%">
|
||||
|
@ -71,7 +71,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
return $this->arguments[$key];
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName()));
|
||||
throw new \InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,10 +118,18 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
|
||||
$event = new Event();
|
||||
$return = $this->dispatcher->dispatch(self::preFoo, $event);
|
||||
$this->assertEquals('pre.foo', $event->getName());
|
||||
$this->assertSame($event, $return);
|
||||
}
|
||||
|
||||
public function testLegacyDispatch()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$event = new Event();
|
||||
$return = $this->dispatcher->dispatch(self::preFoo, $event);
|
||||
$this->assertEquals('pre.foo', $event->getName());
|
||||
}
|
||||
|
||||
public function testDispatchForClosure()
|
||||
{
|
||||
$invoked = 0;
|
||||
@ -239,8 +247,10 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
|
||||
}
|
||||
|
||||
public function testEventReceivesTheDispatcherInstance()
|
||||
public function testLegacyEventReceivesTheDispatcherInstance()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$dispatcher = null;
|
||||
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
|
||||
$dispatcher = $event->getDispatcher();
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
trigger_error('The '.__NAMESPACE__.'\AlreadyBoundException class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Exception\AlreadySubmittedException class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Alias of {@link AlreadySubmittedException}.
|
||||
*
|
||||
@ -21,4 +19,12 @@ trigger_error('The '.__NAMESPACE__.'\AlreadyBoundException class is deprecated s
|
||||
*/
|
||||
class AlreadyBoundException extends LogicException
|
||||
{
|
||||
public function __construct($message = '', $code = 0, \Exception $previous = null)
|
||||
{
|
||||
if (__CLASS__ === get_class($this)) {
|
||||
trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Exception\AlreadySubmittedException class instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
|
||||
|
||||
trigger_error('The '.__NAMESPACE__.'\CsrfTokenManagerAdapter is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Security\Csrf\CsrfToken;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
|
||||
@ -36,8 +34,12 @@ class CsrfTokenManagerAdapter implements CsrfProviderInterface
|
||||
$this->tokenManager = $tokenManager;
|
||||
}
|
||||
|
||||
public function getTokenManager()
|
||||
public function getTokenManager($triggerDeprecationError = true)
|
||||
{
|
||||
if ($triggerDeprecationError) {
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return $this->tokenManager;
|
||||
}
|
||||
|
||||
@ -46,6 +48,8 @@ class CsrfTokenManagerAdapter implements CsrfProviderInterface
|
||||
*/
|
||||
public function generateCsrfToken($intention)
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->tokenManager->getToken($intention)->getValue();
|
||||
}
|
||||
|
||||
@ -54,6 +58,8 @@ class CsrfTokenManagerAdapter implements CsrfProviderInterface
|
||||
*/
|
||||
public function isCsrfTokenValid($intention, $token)
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->tokenManager->isTokenValid(new CsrfToken($intention, $token));
|
||||
}
|
||||
}
|
||||
|
@ -128,8 +128,12 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
|
||||
|
||||
// BC clause for the "csrf_provider" option
|
||||
$csrfTokenManager = function (Options $options) {
|
||||
if ($options['csrf_provider'] instanceof CsrfTokenManagerInterface) {
|
||||
return $options['csrf_provider'];
|
||||
}
|
||||
|
||||
return $options['csrf_provider'] instanceof CsrfTokenManagerAdapter
|
||||
? $options['csrf_provider']->getTokenManager()
|
||||
? $options['csrf_provider']->getTokenManager(false)
|
||||
: new CsrfProviderAdapter($options['csrf_provider']);
|
||||
};
|
||||
|
||||
@ -139,7 +143,7 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
|
||||
'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.',
|
||||
'csrf_token_manager' => $csrfTokenManager,
|
||||
'csrf_token_id' => $csrfTokenId,
|
||||
'csrf_provider' => new CsrfTokenManagerAdapter($this->defaultTokenManager),
|
||||
'csrf_provider' => $this->defaultTokenManager,
|
||||
'intention' => null,
|
||||
));
|
||||
}
|
||||
|
@ -127,8 +127,8 @@ class ViolationMapper implements ViolationMapperInterface
|
||||
$scope->addError(new FormError(
|
||||
$violation->getMessage(),
|
||||
$violation->getMessageTemplate(),
|
||||
$violation->getMessageParameters(),
|
||||
$violation->getMessagePluralization(),
|
||||
$violation->getParameters(),
|
||||
$violation->getPlural(),
|
||||
$violation
|
||||
));
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ class Form implements \IteratorAggregate, FormInterface
|
||||
*/
|
||||
public function getErrorsAsString($level = 0)
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the Form::getErrors(true, false) method instead and cast the result to a string.', E_USER_DEPRECATED);
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use (string) Form::getErrors(true, false) instead.', E_USER_DEPRECATED);
|
||||
|
||||
return self::indent((string) $this->getErrors(true, false), $level);
|
||||
}
|
||||
|
@ -787,8 +787,10 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$this->assertEquals(array('extra' => 'data'), $form->getExtraData());
|
||||
}
|
||||
|
||||
public function testGetErrorsAsStringDeep()
|
||||
public function testLegacyGetErrorsAsStringDeep()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$parent = $this->getBuilder()
|
||||
->setCompound(true)
|
||||
->setDataMapper($this->getDataMapper())
|
||||
@ -806,8 +808,10 @@ class CompoundFormTest extends AbstractFormTest
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetErrorsAsStringDeepWithIndentation()
|
||||
public function testLegacyGetErrorsAsStringDeepWithIndentation()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$parent = $this->getBuilder()
|
||||
->setCompound(true)
|
||||
->setDataMapper($this->getDataMapper())
|
||||
|
@ -637,8 +637,10 @@ class FormTypeTest extends BaseTypeTest
|
||||
$this->assertSame('0', $view->vars['label']);
|
||||
}
|
||||
|
||||
public function testCanGetErrorsWhenButtonInForm()
|
||||
public function testLegacyCanGetErrorsWhenButtonInForm()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$builder = $this->factory->createBuilder('form', null, array(
|
||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||
'required' => false,
|
||||
|
@ -575,7 +575,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
|
||||
->add($this->getBuilder('child'))
|
||||
->getForm();
|
||||
|
||||
$form->bind(array('foo' => 'bar'));
|
||||
$form->submit(array('foo' => 'bar'));
|
||||
|
||||
$context->expects($this->never())
|
||||
->method('addViolation');
|
||||
|
@ -732,8 +732,10 @@ class SimpleFormTest extends AbstractFormTest
|
||||
$this->assertSame($view, $form->createView($parentView));
|
||||
}
|
||||
|
||||
public function testGetErrorsAsString()
|
||||
public function testLegacyGetErrorsAsString()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$this->form->addError(new FormError('Error!'));
|
||||
|
||||
$this->assertEquals("ERROR: Error!\n", $this->form->getErrorsAsString());
|
||||
|
@ -135,8 +135,10 @@ class FlashBagTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::getIterator
|
||||
*/
|
||||
public function testGetIterator()
|
||||
public function testLegacyGetIterator()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$flashes = array('hello' => 'world', 'beep' => 'boop', 'notice' => 'nope');
|
||||
foreach ($flashes as $key => $val) {
|
||||
$this->bag->set($key, $val);
|
||||
|
@ -53,7 +53,7 @@ class Esi implements SurrogateInterface
|
||||
*/
|
||||
public function createCacheStrategy()
|
||||
{
|
||||
return new EsiResponseCacheStrategy();
|
||||
return new ResponseCacheStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,7 +65,11 @@ class Esi implements SurrogateInterface
|
||||
*/
|
||||
public function hasSurrogateCapability(Request $request)
|
||||
{
|
||||
return $this->hasSurrogateEsiCapability($request);
|
||||
if (null === $value = $request->headers->get('Surrogate-Capability')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false !== strpos($value, 'ESI/1.0');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,11 +85,7 @@ class Esi implements SurrogateInterface
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the hasSurrogateCapability() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (null === $value = $request->headers->get('Surrogate-Capability')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false !== strpos($value, 'ESI/1.0');
|
||||
return $this->hasSurrogateCapability($request);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +95,10 @@ class Esi implements SurrogateInterface
|
||||
*/
|
||||
public function addSurrogateCapability(Request $request)
|
||||
{
|
||||
$this->addSurrogateEsiCapability($request);
|
||||
$current = $request->headers->get('Surrogate-Capability');
|
||||
$new = 'symfony2="ESI/1.0"';
|
||||
|
||||
$request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,10 +112,7 @@ class Esi implements SurrogateInterface
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the addSurrogateCapability() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
$current = $request->headers->get('Surrogate-Capability');
|
||||
$new = 'symfony2="ESI/1.0"';
|
||||
|
||||
$request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new);
|
||||
$this->addSurrogateCapability($request);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +138,11 @@ class Esi implements SurrogateInterface
|
||||
*/
|
||||
public function needsParsing(Response $response)
|
||||
{
|
||||
return $this->needsEsiParsing($response);
|
||||
if (!$control = $response->headers->get('Surrogate-Control')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,11 +158,7 @@ class Esi implements SurrogateInterface
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the needsParsing() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (!$control = $response->headers->get('Surrogate-Control')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control);
|
||||
return $this->needsParsing($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\HttpCache;
|
||||
|
||||
trigger_error('The '.__NAMESPACE__.'\EsiResponseCacheStrategyInterface class is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategyInterface class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* ResponseCacheStrategyInterface implementations know how to compute the
|
||||
* Response cache HTTP header based on the different response cache headers.
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Security\Core;
|
||||
|
||||
trigger_error('The '.__NAMESPACE__.'\SecurityContext class is deprecated since version 2.6 and will be removed in 3.0. Use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage or Symfony\Component\Security\Core\Authorization\AuthorizationChecker instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
@ -76,8 +78,6 @@ class SecurityContext implements SecurityContextInterface
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::getToken() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->tokenStorage->getToken();
|
||||
}
|
||||
|
||||
@ -88,8 +88,6 @@ class SecurityContext implements SecurityContextInterface
|
||||
*/
|
||||
public function setToken(TokenInterface $token = null)
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::setToken() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->tokenStorage->setToken($token);
|
||||
}
|
||||
|
||||
@ -100,8 +98,6 @@ class SecurityContext implements SecurityContextInterface
|
||||
*/
|
||||
public function isGranted($attributes, $object = null)
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::isGranted() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->authorizationChecker->isGranted($attributes, $object);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Security\Core;
|
||||
|
||||
trigger_error('The '.__NAMESPACE__.'\SecurityContextInterface interface is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Security\Tests\Core\Authentication\Token;
|
||||
namespace Symfony\Component\Security\Core\Tests\Authentication\Token;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
|
||||
use Symfony\Component\Security\Core\SecurityContext;
|
||||
|
||||
class SecurityContextTest extends \PHPUnit_Framework_TestCase
|
||||
class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $tokenStorage;
|
||||
private $authorizationChecker;
|
||||
@ -23,6 +23,8 @@ class SecurityContextTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$this->authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');
|
||||
$this->securityContext = new SecurityContext($this->tokenStorage, $this->authorizationChecker);
|
@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Security\Tests\Core\User;
|
||||
namespace Symfony\Component\Security\Core\Tests\User;
|
||||
|
||||
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
|
||||
use Symfony\Component\Security\Core\User\User;
|
@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Security\Tests\Core\User;
|
||||
namespace Symfony\Component\Security\Core\Tests\User;
|
||||
|
||||
use Symfony\Component\Security\Core\User\UserChecker;
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
namespace Symfony\Component\Security\Core\Tests\Validator\Constraints;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
|
||||
use Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator;
|
||||
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
|
||||
@ -28,9 +28,9 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
|
||||
const SALT = '^S4lt$';
|
||||
|
||||
/**
|
||||
* @var SecurityContextInterface
|
||||
* @var TokenStorageInterface
|
||||
*/
|
||||
protected $securityContext;
|
||||
protected $tokenStorage;
|
||||
|
||||
/**
|
||||
* @var PasswordEncoderInterface
|
||||
@ -44,13 +44,13 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new UserPasswordValidator($this->securityContext, $this->encoderFactory);
|
||||
return new UserPasswordValidator($this->tokenStorage, $this->encoderFactory);
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$user = $this->createUser();
|
||||
$this->securityContext = $this->createSecurityContext($user);
|
||||
$this->tokenStorage = $this->createTokenStorage($user);
|
||||
$this->encoder = $this->createPasswordEncoder();
|
||||
$this->encoderFactory = $this->createEncoderFactory($this->encoder);
|
||||
|
||||
@ -97,7 +97,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
|
||||
{
|
||||
$user = $this->getMock('Foo\Bar\User');
|
||||
|
||||
$this->securityContext = $this->createSecurityContext($user);
|
||||
$this->tokenStorage = $this->createTokenStorage($user);
|
||||
$this->validator = $this->createValidator();
|
||||
$this->validator->initialize($this->context);
|
||||
|
||||
@ -141,11 +141,11 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
|
||||
return $mock;
|
||||
}
|
||||
|
||||
protected function createSecurityContext($user = null)
|
||||
protected function createTokenStorage($user = null)
|
||||
{
|
||||
$token = $this->createAuthenticationToken($user);
|
||||
|
||||
$mock = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$mock
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
|
@ -12,8 +12,8 @@
|
||||
namespace Symfony\Component\Security\Core\Validator\Constraints;
|
||||
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
@ -21,12 +21,12 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
class UserPasswordValidator extends ConstraintValidator
|
||||
{
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $encoderFactory;
|
||||
|
||||
public function __construct(SecurityContextInterface $securityContext, EncoderFactoryInterface $encoderFactory)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, EncoderFactoryInterface $encoderFactory)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->encoderFactory = $encoderFactory;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class UserPasswordValidator extends ConstraintValidator
|
||||
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UserPassword');
|
||||
}
|
||||
|
||||
$user = $this->securityContext->getToken()->getUser();
|
||||
$user = $this->tokenStorage->getToken()->getUser();
|
||||
|
||||
if (!$user instanceof UserInterface) {
|
||||
throw new ConstraintDefinitionException('The User object must implement the UserInterface interface.');
|
||||
|
@ -16,8 +16,8 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerI
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
|
||||
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Core\Exception\SessionUnavailableException;
|
||||
@ -56,7 +56,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
||||
protected $providerKey;
|
||||
protected $httpUtils;
|
||||
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $sessionStrategy;
|
||||
private $dispatcher;
|
||||
private $successHandler;
|
||||
@ -66,7 +66,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param SecurityContextInterface $securityContext A SecurityContext instance
|
||||
* @param TokenStorageInterface $tokenStorage A TokenStorageInterface instance
|
||||
* @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance
|
||||
* @param SessionAuthenticationStrategyInterface $sessionStrategy
|
||||
* @param HttpUtils $httpUtils An HttpUtilsInterface instance
|
||||
@ -80,13 +80,13 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
if (empty($providerKey)) {
|
||||
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
||||
}
|
||||
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->authenticationManager = $authenticationManager;
|
||||
$this->sessionStrategy = $sessionStrategy;
|
||||
$this->providerKey = $providerKey;
|
||||
@ -196,9 +196,9 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
||||
$this->logger->info(sprintf('Authentication request failed: %s', $failed->getMessage()));
|
||||
}
|
||||
|
||||
$token = $this->securityContext->getToken();
|
||||
$token = $this->tokenStorage->getToken();
|
||||
if ($token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey()) {
|
||||
$this->securityContext->setToken(null);
|
||||
$this->tokenStorage->setToken(null);
|
||||
}
|
||||
|
||||
$response = $this->failureHandler->onAuthenticationFailure($request, $failed);
|
||||
@ -216,7 +216,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
||||
$this->logger->info(sprintf('User "%s" has been authenticated successfully', $token->getUsername()));
|
||||
}
|
||||
|
||||
$this->securityContext->setToken($token);
|
||||
$this->tokenStorage->setToken($token);
|
||||
|
||||
$session = $request->getSession();
|
||||
$session->remove(Security::AUTHENTICATION_ERROR);
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
namespace Symfony\Component\Security\Http\Firewall;
|
||||
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
|
||||
use Symfony\Component\Security\Http\SecurityEvents;
|
||||
@ -33,14 +33,14 @@ use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||
abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
||||
{
|
||||
protected $logger;
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $authenticationManager;
|
||||
private $providerKey;
|
||||
private $dispatcher;
|
||||
|
||||
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->authenticationManager = $authenticationManager;
|
||||
$this->providerKey = $providerKey;
|
||||
$this->logger = $logger;
|
||||
@ -57,7 +57,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
||||
$request = $event->getRequest();
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Checking secure context token: %s', $this->securityContext->getToken()));
|
||||
$this->logger->debug(sprintf('Checking secure context token: %s', $this->tokenStorage->getToken()));
|
||||
}
|
||||
|
||||
try {
|
||||
@ -68,7 +68,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (null !== $token = $this->securityContext->getToken()) {
|
||||
if (null !== $token = $this->tokenStorage->getToken()) {
|
||||
if ($token instanceof PreAuthenticatedToken && $this->providerKey == $token->getProviderKey() && $token->isAuthenticated() && $token->getUsername() === $user) {
|
||||
return;
|
||||
}
|
||||
@ -84,7 +84,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info(sprintf('Authentication success: %s', $token));
|
||||
}
|
||||
$this->securityContext->setToken($token);
|
||||
$this->tokenStorage->setToken($token);
|
||||
|
||||
if (null !== $this->dispatcher) {
|
||||
$loginEvent = new InteractiveLoginEvent($request, $token);
|
||||
@ -102,9 +102,9 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
||||
*/
|
||||
private function clearToken(AuthenticationException $exception)
|
||||
{
|
||||
$token = $this->securityContext->getToken();
|
||||
$token = $this->tokenStorage->getToken();
|
||||
if ($token instanceof PreAuthenticatedToken && $this->providerKey === $token->getProviderKey()) {
|
||||
$this->securityContext->setToken(null);
|
||||
$this->tokenStorage->setToken(null);
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info(sprintf("Cleared security context due to exception: %s", $exception->getMessage()));
|
||||
|
@ -11,10 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Security\Http\Firewall;
|
||||
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
||||
use Symfony\Component\Security\Http\AccessMapInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
@ -26,14 +26,14 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
*/
|
||||
class AccessListener implements ListenerInterface
|
||||
{
|
||||
private $context;
|
||||
private $tokenStorage;
|
||||
private $accessDecisionManager;
|
||||
private $map;
|
||||
private $authManager;
|
||||
|
||||
public function __construct(SecurityContextInterface $context, AccessDecisionManagerInterface $accessDecisionManager, AccessMapInterface $map, AuthenticationManagerInterface $authManager)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AccessDecisionManagerInterface $accessDecisionManager, AccessMapInterface $map, AuthenticationManagerInterface $authManager)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->accessDecisionManager = $accessDecisionManager;
|
||||
$this->map = $map;
|
||||
$this->authManager = $authManager;
|
||||
@ -49,7 +49,7 @@ class AccessListener implements ListenerInterface
|
||||
*/
|
||||
public function handle(GetResponseEvent $event)
|
||||
{
|
||||
if (null === $token = $this->context->getToken()) {
|
||||
if (null === $token = $this->tokenStorage->getToken()) {
|
||||
throw new AuthenticationCredentialsNotFoundException('A Token was not found in the SecurityContext.');
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ class AccessListener implements ListenerInterface
|
||||
|
||||
if (!$token->isAuthenticated()) {
|
||||
$token = $this->authManager->authenticate($token);
|
||||
$this->context->setToken($token);
|
||||
$this->tokenStorage->setToken($token);
|
||||
}
|
||||
|
||||
if (!$this->accessDecisionManager->decide($token, $attributes, $request)) {
|
||||
|
@ -12,8 +12,8 @@
|
||||
namespace Symfony\Component\Security\Http\Firewall;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
||||
@ -26,14 +26,14 @@ use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
||||
*/
|
||||
class AnonymousAuthenticationListener implements ListenerInterface
|
||||
{
|
||||
private $context;
|
||||
private $tokenStorage;
|
||||
private $key;
|
||||
private $authenticationManager;
|
||||
private $logger;
|
||||
|
||||
public function __construct(SecurityContextInterface $context, $key, LoggerInterface $logger = null, AuthenticationManagerInterface $authenticationManager = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, $key, LoggerInterface $logger = null, AuthenticationManagerInterface $authenticationManager = null)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->key = $key;
|
||||
$this->authenticationManager = $authenticationManager;
|
||||
$this->logger = $logger;
|
||||
@ -46,7 +46,7 @@ class AnonymousAuthenticationListener implements ListenerInterface
|
||||
*/
|
||||
public function handle(GetResponseEvent $event)
|
||||
{
|
||||
if (null !== $this->context->getToken()) {
|
||||
if (null !== $this->tokenStorage->getToken()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -56,10 +56,10 @@ class AnonymousAuthenticationListener implements ListenerInterface
|
||||
$token = $this->authenticationManager->authenticate($token);
|
||||
}
|
||||
|
||||
$this->context->setToken($token);
|
||||
$this->tokenStorage->setToken($token);
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info('Populated SecurityContext with an anonymous Token');
|
||||
$this->logger->info('Populated TokenStorage with an anonymous Token');
|
||||
}
|
||||
} catch (AuthenticationException $failed) {
|
||||
if (null !== $this->logger) {
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Security\Http\Firewall;
|
||||
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
@ -26,20 +26,20 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
*/
|
||||
class BasicAuthenticationListener implements ListenerInterface
|
||||
{
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $authenticationManager;
|
||||
private $providerKey;
|
||||
private $authenticationEntryPoint;
|
||||
private $logger;
|
||||
private $ignoreFailure;
|
||||
|
||||
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null)
|
||||
{
|
||||
if (empty($providerKey)) {
|
||||
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
||||
}
|
||||
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->authenticationManager = $authenticationManager;
|
||||
$this->providerKey = $providerKey;
|
||||
$this->authenticationEntryPoint = $authenticationEntryPoint;
|
||||
@ -60,7 +60,7 @@ class BasicAuthenticationListener implements ListenerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (null !== $token = $this->securityContext->getToken()) {
|
||||
if (null !== $token = $this->tokenStorage->getToken()) {
|
||||
if ($token instanceof UsernamePasswordToken && $token->isAuthenticated() && $token->getUsername() === $username) {
|
||||
return;
|
||||
}
|
||||
@ -72,11 +72,11 @@ class BasicAuthenticationListener implements ListenerInterface
|
||||
|
||||
try {
|
||||
$token = $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $request->headers->get('PHP_AUTH_PW'), $this->providerKey));
|
||||
$this->securityContext->setToken($token);
|
||||
$this->tokenStorage->setToken($token);
|
||||
} catch (AuthenticationException $failed) {
|
||||
$token = $this->securityContext->getToken();
|
||||
$token = $this->tokenStorage->getToken();
|
||||
if ($token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey()) {
|
||||
$this->securityContext->setToken(null);
|
||||
$this->tokenStorage->setToken(null);
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
|
@ -16,10 +16,10 @@ use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
@ -32,14 +32,14 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
*/
|
||||
class ContextListener implements ListenerInterface
|
||||
{
|
||||
private $context;
|
||||
private $tokenStorage;
|
||||
private $contextKey;
|
||||
private $logger;
|
||||
private $userProviders;
|
||||
private $dispatcher;
|
||||
private $registered;
|
||||
|
||||
public function __construct(SecurityContextInterface $context, array $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, array $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
if (empty($contextKey)) {
|
||||
throw new \InvalidArgumentException('$contextKey must not be empty.');
|
||||
@ -51,7 +51,7 @@ class ContextListener implements ListenerInterface
|
||||
}
|
||||
}
|
||||
|
||||
$this->context = $context;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->userProviders = $userProviders;
|
||||
$this->contextKey = $contextKey;
|
||||
$this->logger = $logger;
|
||||
@ -74,7 +74,7 @@ class ContextListener implements ListenerInterface
|
||||
$session = $request->hasPreviousSession() ? $request->getSession() : null;
|
||||
|
||||
if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) {
|
||||
$this->context->setToken(null);
|
||||
$this->tokenStorage->setToken(null);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -95,7 +95,7 @@ class ContextListener implements ListenerInterface
|
||||
$token = null;
|
||||
}
|
||||
|
||||
$this->context->setToken($token);
|
||||
$this->tokenStorage->setToken($token);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,7 +124,7 @@ class ContextListener implements ListenerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if ((null === $token = $this->context->getToken()) || ($token instanceof AnonymousToken)) {
|
||||
if ((null === $token = $this->tokenStorage->getToken()) || ($token instanceof AnonymousToken)) {
|
||||
if ($request->hasPreviousSession()) {
|
||||
$session->remove('_security_'.$this->contextKey);
|
||||
}
|
||||
|
@ -11,12 +11,12 @@
|
||||
|
||||
namespace Symfony\Component\Security\Http\Firewall;
|
||||
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
use Symfony\Component\Security\Http\EntryPoint\DigestAuthenticationEntryPoint;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationServiceException;
|
||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||
@ -31,19 +31,19 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
*/
|
||||
class DigestAuthenticationListener implements ListenerInterface
|
||||
{
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $provider;
|
||||
private $providerKey;
|
||||
private $authenticationEntryPoint;
|
||||
private $logger;
|
||||
|
||||
public function __construct(SecurityContextInterface $securityContext, UserProviderInterface $provider, $providerKey, DigestAuthenticationEntryPoint $authenticationEntryPoint, LoggerInterface $logger = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, UserProviderInterface $provider, $providerKey, DigestAuthenticationEntryPoint $authenticationEntryPoint, LoggerInterface $logger = null)
|
||||
{
|
||||
if (empty($providerKey)) {
|
||||
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
||||
}
|
||||
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->provider = $provider;
|
||||
$this->providerKey = $providerKey;
|
||||
$this->authenticationEntryPoint = $authenticationEntryPoint;
|
||||
@ -67,7 +67,7 @@ class DigestAuthenticationListener implements ListenerInterface
|
||||
|
||||
$digestAuth = new DigestData($header);
|
||||
|
||||
if (null !== $token = $this->securityContext->getToken()) {
|
||||
if (null !== $token = $this->tokenStorage->getToken()) {
|
||||
if ($token instanceof UsernamePasswordToken && $token->isAuthenticated() && $token->getUsername() === $digestAuth->getUsername()) {
|
||||
return;
|
||||
}
|
||||
@ -119,14 +119,14 @@ class DigestAuthenticationListener implements ListenerInterface
|
||||
$this->logger->info(sprintf('Authentication success for user "%s" with response "%s"', $digestAuth->getUsername(), $digestAuth->getResponse()));
|
||||
}
|
||||
|
||||
$this->securityContext->setToken(new UsernamePasswordToken($user, $user->getPassword(), $this->providerKey));
|
||||
$this->tokenStorage->setToken(new UsernamePasswordToken($user, $user->getPassword(), $this->providerKey));
|
||||
}
|
||||
|
||||
private function fail(GetResponseEvent $event, Request $request, AuthenticationException $authException)
|
||||
{
|
||||
$token = $this->securityContext->getToken();
|
||||
$token = $this->tokenStorage->getToken();
|
||||
if ($token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey()) {
|
||||
$this->securityContext->setToken(null);
|
||||
$this->tokenStorage->setToken(null);
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
|
@ -14,8 +14,8 @@ namespace Symfony\Component\Security\Http\Firewall;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AccountStatusException;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
@ -39,7 +39,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
*/
|
||||
class ExceptionListener
|
||||
{
|
||||
private $context;
|
||||
private $tokenStorage;
|
||||
private $providerKey;
|
||||
private $accessDeniedHandler;
|
||||
private $authenticationEntryPoint;
|
||||
@ -48,9 +48,9 @@ class ExceptionListener
|
||||
private $logger;
|
||||
private $httpUtils;
|
||||
|
||||
public function __construct(SecurityContextInterface $context, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->accessDeniedHandler = $accessDeniedHandler;
|
||||
$this->httpUtils = $httpUtils;
|
||||
$this->providerKey = $providerKey;
|
||||
@ -116,7 +116,7 @@ class ExceptionListener
|
||||
{
|
||||
$event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
|
||||
|
||||
$token = $this->context->getToken();
|
||||
$token = $this->tokenStorage->getToken();
|
||||
if (!$this->authenticationTrustResolver->isFullFledged($token)) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Access is denied (user is not fully authenticated) by "%s" at line %s; redirecting to authentication entry point', $exception->getFile(), $exception->getLine()));
|
||||
@ -189,7 +189,7 @@ class ExceptionListener
|
||||
|
||||
if ($authException instanceof AccountStatusException) {
|
||||
// remove the security token to prevent infinite redirect loops
|
||||
$this->context->setToken(null);
|
||||
$this->tokenStorage->setToken(null);
|
||||
}
|
||||
|
||||
return $this->authenticationEntryPoint->start($request, $authException);
|
||||
|
@ -16,8 +16,8 @@ use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Exception\LogoutException;
|
||||
use Symfony\Component\Security\Csrf\CsrfToken;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
@ -32,7 +32,7 @@ use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface;
|
||||
*/
|
||||
class LogoutListener implements ListenerInterface
|
||||
{
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $options;
|
||||
private $handlers;
|
||||
private $successHandler;
|
||||
@ -42,13 +42,13 @@ class LogoutListener implements ListenerInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param SecurityContextInterface $securityContext
|
||||
* @param TokenStorageInterface $tokenStorage
|
||||
* @param HttpUtils $httpUtils An HttpUtilsInterface instance
|
||||
* @param LogoutSuccessHandlerInterface $successHandler A LogoutSuccessHandlerInterface instance
|
||||
* @param array $options An array of options to process a logout attempt
|
||||
* @param CsrfTokenManagerInterface $csrfTokenManager A CsrfTokenManagerInterface instance
|
||||
*/
|
||||
public function __construct(SecurityContextInterface $securityContext, HttpUtils $httpUtils, LogoutSuccessHandlerInterface $successHandler, array $options = array(), $csrfTokenManager = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, HttpUtils $httpUtils, LogoutSuccessHandlerInterface $successHandler, array $options = array(), $csrfTokenManager = null)
|
||||
{
|
||||
if ($csrfTokenManager instanceof CsrfProviderInterface) {
|
||||
$csrfTokenManager = new CsrfProviderAdapter($csrfTokenManager);
|
||||
@ -56,7 +56,7 @@ class LogoutListener implements ListenerInterface
|
||||
throw new InvalidArgumentException('The CSRF token manager should be an instance of CsrfProviderInterface or CsrfTokenManagerInterface.');
|
||||
}
|
||||
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->httpUtils = $httpUtils;
|
||||
$this->options = array_merge(array(
|
||||
'csrf_parameter' => '_csrf_token',
|
||||
@ -111,13 +111,13 @@ class LogoutListener implements ListenerInterface
|
||||
}
|
||||
|
||||
// handle multiple logout attempts gracefully
|
||||
if ($token = $this->securityContext->getToken()) {
|
||||
if ($token = $this->tokenStorage->getToken()) {
|
||||
foreach ($this->handlers as $handler) {
|
||||
$handler->logout($request, $response, $token);
|
||||
}
|
||||
}
|
||||
|
||||
$this->securityContext->setToken(null);
|
||||
$this->tokenStorage->setToken(null);
|
||||
|
||||
$event->setResponse($response);
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ namespace Symfony\Component\Security\Http\Firewall;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
||||
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
|
||||
use Symfony\Component\Security\Http\SecurityEvents;
|
||||
@ -28,7 +28,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
*/
|
||||
class RememberMeListener implements ListenerInterface
|
||||
{
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $rememberMeServices;
|
||||
private $authenticationManager;
|
||||
private $logger;
|
||||
@ -38,16 +38,16 @@ class RememberMeListener implements ListenerInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param SecurityContextInterface $securityContext
|
||||
* @param TokenStorageInterface $tokenStorage
|
||||
* @param RememberMeServicesInterface $rememberMeServices
|
||||
* @param AuthenticationManagerInterface $authenticationManager
|
||||
* @param LoggerInterface $logger
|
||||
* @param EventDispatcherInterface $dispatcher
|
||||
* @param bool $catchExceptions
|
||||
*/
|
||||
public function __construct(SecurityContextInterface $securityContext, RememberMeServicesInterface $rememberMeServices, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, $catchExceptions = true)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, RememberMeServicesInterface $rememberMeServices, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, $catchExceptions = true)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->rememberMeServices = $rememberMeServices;
|
||||
$this->authenticationManager = $authenticationManager;
|
||||
$this->logger = $logger;
|
||||
@ -62,7 +62,7 @@ class RememberMeListener implements ListenerInterface
|
||||
*/
|
||||
public function handle(GetResponseEvent $event)
|
||||
{
|
||||
if (null !== $this->securityContext->getToken()) {
|
||||
if (null !== $this->tokenStorage->getToken()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ class RememberMeListener implements ListenerInterface
|
||||
|
||||
try {
|
||||
$token = $this->authenticationManager->authenticate($token);
|
||||
$this->securityContext->setToken($token);
|
||||
$this->tokenStorage->setToken($token);
|
||||
|
||||
if (null !== $this->dispatcher) {
|
||||
$loginEvent = new InteractiveLoginEvent($request, $token);
|
||||
@ -81,12 +81,12 @@ class RememberMeListener implements ListenerInterface
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug('SecurityContext populated with remember-me token.');
|
||||
$this->logger->debug('Token storage populated with remember-me token.');
|
||||
}
|
||||
} catch (AuthenticationException $failed) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->warning(
|
||||
'SecurityContext not populated with remember-me token as the'
|
||||
'Token storage not populated with remember-me token as the'
|
||||
.' AuthenticationManager rejected the AuthenticationToken returned'
|
||||
.' by the RememberMeServices: '.$failed->getMessage()
|
||||
);
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Security\Http\Firewall;
|
||||
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||
@ -28,9 +28,9 @@ class RemoteUserAuthenticationListener extends AbstractPreAuthenticatedListener
|
||||
{
|
||||
private $userKey;
|
||||
|
||||
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, $userKey = 'REMOTE_USER', LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, $userKey = 'REMOTE_USER', LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
parent::__construct($securityContext, $authenticationManager, $providerKey, $logger, $dispatcher);
|
||||
parent::__construct($tokenStorage, $authenticationManager, $providerKey, $logger, $dispatcher);
|
||||
|
||||
$this->userKey = $userKey;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerI
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\SimpleFormAuthenticatorInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Http\HttpUtils;
|
||||
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -40,7 +40,7 @@ class SimpleFormAuthenticationListener extends AbstractAuthenticationListener
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param SecurityContextInterface $securityContext A SecurityContext instance
|
||||
* @param TokenStorageInterface $tokenStorage A TokenStorageInterface instance
|
||||
* @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance
|
||||
* @param SessionAuthenticationStrategyInterface $sessionStrategy
|
||||
* @param HttpUtils $httpUtils An HttpUtilsInterface instance
|
||||
@ -57,7 +57,7 @@ class SimpleFormAuthenticationListener extends AbstractAuthenticationListener
|
||||
* @throws \InvalidArgumentException In case no simple authenticator is provided
|
||||
* @throws InvalidArgumentException In case an invalid CSRF token manager is passed
|
||||
*/
|
||||
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, $csrfTokenManager = null, SimpleFormAuthenticatorInterface $simpleAuthenticator = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, $csrfTokenManager = null, SimpleFormAuthenticatorInterface $simpleAuthenticator = null)
|
||||
{
|
||||
if (!$simpleAuthenticator) {
|
||||
throw new \InvalidArgumentException('Missing simple authenticator');
|
||||
@ -79,7 +79,8 @@ class SimpleFormAuthenticationListener extends AbstractAuthenticationListener
|
||||
'intention' => 'authenticate',
|
||||
'post_only' => true,
|
||||
), $options);
|
||||
parent::__construct($securityContext, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, $options, $logger, $dispatcher);
|
||||
|
||||
parent::__construct($tokenStorage, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, $options, $logger, $dispatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,13 +11,13 @@
|
||||
|
||||
namespace Symfony\Component\Security\Http\Firewall;
|
||||
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
|
||||
@ -32,7 +32,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
*/
|
||||
class SimplePreAuthenticationListener implements ListenerInterface
|
||||
{
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $authenticationManager;
|
||||
private $providerKey;
|
||||
private $simpleAuthenticator;
|
||||
@ -42,20 +42,20 @@ class SimplePreAuthenticationListener implements ListenerInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param SecurityContextInterface $securityContext A SecurityContext instance
|
||||
* @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance
|
||||
* @param string $providerKey
|
||||
* @param SimplePreAuthenticatorInterface $simpleAuthenticator A SimplePreAuthenticatorInterface instance
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
|
||||
* @param TokenStorageInterface $tokenStorage A TokenStorageInterface instance
|
||||
* @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance
|
||||
* @param string $providerKey
|
||||
* @param SimplePreAuthenticatorInterface $simpleAuthenticator A SimplePreAuthenticatorInterface instance
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
|
||||
*/
|
||||
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, SimplePreAuthenticatorInterface $simpleAuthenticator, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, SimplePreAuthenticatorInterface $simpleAuthenticator, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
if (empty($providerKey)) {
|
||||
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
||||
}
|
||||
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->authenticationManager = $authenticationManager;
|
||||
$this->providerKey = $providerKey;
|
||||
$this->simpleAuthenticator = $simpleAuthenticator;
|
||||
@ -76,7 +76,7 @@ class SimplePreAuthenticationListener implements ListenerInterface
|
||||
$this->logger->info(sprintf('Attempting simple pre-authorization %s', $this->providerKey));
|
||||
}
|
||||
|
||||
if (null !== $this->securityContext->getToken() && !$this->securityContext->getToken() instanceof AnonymousToken) {
|
||||
if (null !== $this->tokenStorage->getToken() && !$this->tokenStorage->getToken() instanceof AnonymousToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -89,14 +89,14 @@ class SimplePreAuthenticationListener implements ListenerInterface
|
||||
}
|
||||
|
||||
$token = $this->authenticationManager->authenticate($token);
|
||||
$this->securityContext->setToken($token);
|
||||
$this->tokenStorage->setToken($token);
|
||||
|
||||
if (null !== $this->dispatcher) {
|
||||
$loginEvent = new InteractiveLoginEvent($request, $token);
|
||||
$this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
|
||||
}
|
||||
} catch (AuthenticationException $e) {
|
||||
$this->securityContext->setToken(null);
|
||||
$this->tokenStorage->setToken(null);
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info(sprintf('Authentication request failed: %s', $e->getMessage()));
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Security\Http\Firewall;
|
||||
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
||||
@ -23,6 +22,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Role\SwitchUserRole;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Http\Event\SwitchUserEvent;
|
||||
@ -37,7 +37,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
*/
|
||||
class SwitchUserListener implements ListenerInterface
|
||||
{
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $provider;
|
||||
private $userChecker;
|
||||
private $providerKey;
|
||||
@ -47,16 +47,13 @@ class SwitchUserListener implements ListenerInterface
|
||||
private $logger;
|
||||
private $dispatcher;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(SecurityContextInterface $securityContext, UserProviderInterface $provider, UserCheckerInterface $userChecker, $providerKey, AccessDecisionManagerInterface $accessDecisionManager, LoggerInterface $logger = null, $usernameParameter = '_switch_user', $role = 'ROLE_ALLOWED_TO_SWITCH', EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, UserProviderInterface $provider, UserCheckerInterface $userChecker, $providerKey, AccessDecisionManagerInterface $accessDecisionManager, LoggerInterface $logger = null, $usernameParameter = '_switch_user', $role = 'ROLE_ALLOWED_TO_SWITCH', EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
if (empty($providerKey)) {
|
||||
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
||||
}
|
||||
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->provider = $provider;
|
||||
$this->userChecker = $userChecker;
|
||||
$this->providerKey = $providerKey;
|
||||
@ -83,10 +80,10 @@ class SwitchUserListener implements ListenerInterface
|
||||
}
|
||||
|
||||
if ('_exit' === $request->get($this->usernameParameter)) {
|
||||
$this->securityContext->setToken($this->attemptExitUser($request));
|
||||
$this->tokenStorage->setToken($this->attemptExitUser($request));
|
||||
} else {
|
||||
try {
|
||||
$this->securityContext->setToken($this->attemptSwitchUser($request));
|
||||
$this->tokenStorage->setToken($this->attemptSwitchUser($request));
|
||||
} catch (AuthenticationException $e) {
|
||||
throw new \LogicException(sprintf('Switch User failed: "%s"', $e->getMessage()));
|
||||
}
|
||||
@ -112,7 +109,7 @@ class SwitchUserListener implements ListenerInterface
|
||||
*/
|
||||
private function attemptSwitchUser(Request $request)
|
||||
{
|
||||
$token = $this->securityContext->getToken();
|
||||
$token = $this->tokenStorage->getToken();
|
||||
$originalToken = $this->getOriginalToken($token);
|
||||
|
||||
if (false !== $originalToken) {
|
||||
@ -137,7 +134,7 @@ class SwitchUserListener implements ListenerInterface
|
||||
$this->userChecker->checkPostAuth($user);
|
||||
|
||||
$roles = $user->getRoles();
|
||||
$roles[] = new SwitchUserRole('ROLE_PREVIOUS_ADMIN', $this->securityContext->getToken());
|
||||
$roles[] = new SwitchUserRole('ROLE_PREVIOUS_ADMIN', $this->tokenStorage->getToken());
|
||||
|
||||
$token = new UsernamePasswordToken($user, $user->getPassword(), $this->providerKey, $roles);
|
||||
|
||||
@ -160,7 +157,7 @@ class SwitchUserListener implements ListenerInterface
|
||||
*/
|
||||
private function attemptExitUser(Request $request)
|
||||
{
|
||||
if (false === $original = $this->getOriginalToken($this->securityContext->getToken())) {
|
||||
if (false === $original = $this->getOriginalToken($this->tokenStorage->getToken())) {
|
||||
throw new AuthenticationCredentialsNotFoundException('Could not find original Token object.');
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,11 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerI
|
||||
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface;
|
||||
use Symfony\Component\Security\Http\HttpUtils;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
@ -39,10 +39,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
|
||||
{
|
||||
private $csrfTokenManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, $csrfTokenManager = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, $csrfTokenManager = null)
|
||||
{
|
||||
if ($csrfTokenManager instanceof CsrfProviderInterface) {
|
||||
$csrfTokenManager = new CsrfProviderAdapter($csrfTokenManager);
|
||||
@ -50,7 +47,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
|
||||
throw new InvalidArgumentException('The CSRF token manager should be an instance of CsrfProviderInterface or CsrfTokenManagerInterface.');
|
||||
}
|
||||
|
||||
parent::__construct($securityContext, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, array_merge(array(
|
||||
parent::__construct($tokenStorage, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, array_merge(array(
|
||||
'username_parameter' => '_username',
|
||||
'password_parameter' => '_password',
|
||||
'csrf_parameter' => '_csrf_token',
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Security\Http\Firewall;
|
||||
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||
@ -28,9 +28,9 @@ class X509AuthenticationListener extends AbstractPreAuthenticatedListener
|
||||
private $userKey;
|
||||
private $credentialKey;
|
||||
|
||||
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, $userKey = 'SSL_CLIENT_S_DN_Email', $credentialKey = 'SSL_CLIENT_S_DN', LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, $userKey = 'SSL_CLIENT_S_DN_Email', $credentialKey = 'SSL_CLIENT_S_DN', LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
parent::__construct($securityContext, $authenticationManager, $providerKey, $logger, $dispatcher);
|
||||
parent::__construct($tokenStorage, $authenticationManager, $providerKey, $logger, $dispatcher);
|
||||
|
||||
$this->userKey = $userKey;
|
||||
$this->credentialKey = $credentialKey;
|
||||
|
@ -26,13 +26,13 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
;
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('setToken')
|
||||
->with($this->equalTo($token))
|
||||
@ -47,7 +47,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey',
|
||||
));
|
||||
@ -72,13 +72,13 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$request = new Request(array(), array(), array(), array(), array(), array());
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
;
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->never())
|
||||
->method('setToken')
|
||||
;
|
||||
@ -93,7 +93,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey',
|
||||
));
|
||||
@ -120,13 +120,13 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$request = new Request(array(), array(), array(), array(), array(), array());
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token))
|
||||
;
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->never())
|
||||
->method('setToken')
|
||||
;
|
||||
@ -141,7 +141,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey',
|
||||
));
|
||||
@ -168,8 +168,8 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO'));
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token))
|
||||
@ -182,7 +182,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey',
|
||||
));
|
||||
@ -209,13 +209,13 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$token = new PreAuthenticatedToken('AnotherUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO'));
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token))
|
||||
;
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('setToken')
|
||||
->with($this->equalTo(null))
|
||||
@ -231,7 +231,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey',
|
||||
));
|
||||
|
@ -37,8 +37,8 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue(true))
|
||||
;
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token))
|
||||
@ -53,7 +53,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = new AccessListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$accessDecisionManager,
|
||||
$accessMap,
|
||||
$this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
|
||||
@ -103,13 +103,13 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue($authenticatedToken))
|
||||
;
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($notAuthenticatedToken))
|
||||
;
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('setToken')
|
||||
->with($this->equalTo($authenticatedToken))
|
||||
@ -124,7 +124,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = new AccessListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$accessDecisionManager,
|
||||
$accessMap,
|
||||
$authManager
|
||||
@ -158,15 +158,15 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->method('isAuthenticated')
|
||||
;
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token))
|
||||
;
|
||||
|
||||
$listener = new AccessListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'),
|
||||
$accessMap,
|
||||
$this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
|
||||
@ -185,17 +185,17 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException
|
||||
*/
|
||||
public function testHandleWhenTheSecurityContextHasNoToken()
|
||||
public function testHandleWhenTheSecurityTokenStorageHasNoToken()
|
||||
{
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
;
|
||||
|
||||
$listener = new AccessListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'),
|
||||
$this->getMock('Symfony\Component\Security\Http\AccessMapInterface'),
|
||||
$this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
|
||||
|
@ -16,15 +16,15 @@ use Symfony\Component\Security\Http\Firewall\AnonymousAuthenticationListener;
|
||||
|
||||
class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testHandleWithContextHavingAToken()
|
||||
public function testHandleWithTokenStorageHavingAToken()
|
||||
{
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')))
|
||||
;
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->never())
|
||||
->method('setToken')
|
||||
;
|
||||
@ -35,14 +35,14 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->method('authenticate')
|
||||
;
|
||||
|
||||
$listener = new AnonymousAuthenticationListener($context, 'TheKey', null, $authenticationManager);
|
||||
$listener = new AnonymousAuthenticationListener($tokenStorage, 'TheKey', null, $authenticationManager);
|
||||
$listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false));
|
||||
}
|
||||
|
||||
public function testHandleWithContextHavingNoToken()
|
||||
public function testHandleWithTokenStorageHavingNoToken()
|
||||
{
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
@ -61,28 +61,28 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue($anonymousToken))
|
||||
;
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('setToken')
|
||||
->with($anonymousToken)
|
||||
;
|
||||
|
||||
$listener = new AnonymousAuthenticationListener($context, 'TheKey', null, $authenticationManager);
|
||||
$listener = new AnonymousAuthenticationListener($tokenStorage, 'TheKey', null, $authenticationManager);
|
||||
$listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false));
|
||||
}
|
||||
|
||||
public function testHandledEventIsLogged()
|
||||
{
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||
$logger->expects($this->once())
|
||||
->method('info')
|
||||
->with('Populated SecurityContext with an anonymous Token')
|
||||
->with('Populated TokenStorage with an anonymous Token')
|
||||
;
|
||||
|
||||
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
|
||||
|
||||
$listener = new AnonymousAuthenticationListener($context, 'TheKey', $logger, $authenticationManager);
|
||||
$listener = new AnonymousAuthenticationListener($tokenStorage, 'TheKey', $logger, $authenticationManager);
|
||||
$listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false));
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
;
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('setToken')
|
||||
->with($this->equalTo($token))
|
||||
@ -50,7 +50,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = new BasicAuthenticationListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey',
|
||||
$this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')
|
||||
@ -75,13 +75,13 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
;
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->never())
|
||||
->method('setToken')
|
||||
;
|
||||
@ -97,7 +97,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = new BasicAuthenticationListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
new AuthenticationProviderManager(array($this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'))),
|
||||
'TheProviderKey',
|
||||
$authenticationEntryPoint
|
||||
@ -122,14 +122,14 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$request = new Request();
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->never())
|
||||
->method('getToken')
|
||||
;
|
||||
|
||||
$listener = new BasicAuthenticationListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'),
|
||||
'TheProviderKey',
|
||||
$this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')
|
||||
@ -151,8 +151,8 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$token = new UsernamePasswordToken('TheUsername', 'ThePassword', 'TheProviderKey', array('ROLE_FOO'));
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token))
|
||||
@ -165,7 +165,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = new BasicAuthenticationListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey',
|
||||
$this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')
|
||||
@ -188,7 +188,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testItRequiresProviderKey()
|
||||
{
|
||||
new BasicAuthenticationListener(
|
||||
$this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'),
|
||||
$this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'),
|
||||
$this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'),
|
||||
'',
|
||||
$this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')
|
||||
@ -204,13 +204,13 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO'));
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage
|
||||
->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token))
|
||||
;
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->never())
|
||||
->method('setToken')
|
||||
;
|
||||
@ -226,7 +226,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$listener = new BasicAuthenticationListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
new AuthenticationProviderManager(array($this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'))),
|
||||
'TheProviderKey',
|
||||
$authenticationEntryPoint
|
||||
|
@ -20,24 +20,10 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\Security\Core\SecurityContext;
|
||||
use Symfony\Component\Security\Http\Firewall\ContextListener;
|
||||
|
||||
class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$this->securityContext = new SecurityContext(
|
||||
new TokenStorage(),
|
||||
$this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')
|
||||
);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
unset($this->securityContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage $contextKey must not be empty
|
||||
@ -45,7 +31,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testItRequiresContextKey()
|
||||
{
|
||||
new ContextListener(
|
||||
$this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'),
|
||||
$this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'),
|
||||
array(),
|
||||
''
|
||||
);
|
||||
@ -58,7 +44,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testUserProvidersNeedToImplementAnInterface()
|
||||
{
|
||||
new ContextListener(
|
||||
$this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'),
|
||||
$this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'),
|
||||
array(new \stdClass()),
|
||||
'key123'
|
||||
);
|
||||
@ -100,7 +86,8 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testOnKernelResponseWithoutSession()
|
||||
{
|
||||
$this->securityContext->setToken(new UsernamePasswordToken('test1', 'pass1', 'phpunit'));
|
||||
$tokenStorage = new TokenStorage();
|
||||
$tokenStorage->setToken(new UsernamePasswordToken('test1', 'pass1', 'phpunit'));
|
||||
$request = new Request();
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$request->setSession($session);
|
||||
@ -112,7 +99,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
new Response()
|
||||
);
|
||||
|
||||
$listener = new ContextListener($this->securityContext, array(), 'session');
|
||||
$listener = new ContextListener($tokenStorage, array(), 'session');
|
||||
$listener->onKernelResponse($event);
|
||||
|
||||
$this->assertTrue($session->isStarted());
|
||||
@ -131,7 +118,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
new Response()
|
||||
);
|
||||
|
||||
$listener = new ContextListener($this->securityContext, array(), 'session');
|
||||
$listener = new ContextListener(new TokenStorage(), array(), 'session');
|
||||
$listener->onKernelResponse($event);
|
||||
|
||||
$this->assertFalse($session->isStarted());
|
||||
@ -142,7 +129,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testInvalidTokenInSession($token)
|
||||
{
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
@ -162,11 +149,11 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->method('get')
|
||||
->with('_security_key123')
|
||||
->will($this->returnValue($token));
|
||||
$context->expects($this->once())
|
||||
$tokenStorage->expects($this->once())
|
||||
->method('setToken')
|
||||
->with(null);
|
||||
|
||||
$listener = new ContextListener($context, array(), 'key123');
|
||||
$listener = new ContextListener($tokenStorage, array(), 'key123');
|
||||
$listener->handle($event);
|
||||
}
|
||||
|
||||
@ -181,13 +168,13 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testHandleAddsKernelResponseListener()
|
||||
{
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$listener = new ContextListener($context, array(), 'key123', null, $dispatcher);
|
||||
$listener = new ContextListener($tokenStorage, array(), 'key123', null, $dispatcher);
|
||||
|
||||
$event->expects($this->any())
|
||||
->method('isMasterRequest')
|
||||
@ -213,10 +200,10 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->getMock();
|
||||
$event->expects($this->any())->method('getRequest')->will($this->returnValue($request));
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context->expects($this->once())->method('setToken')->with(null);
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage->expects($this->once())->method('setToken')->with(null);
|
||||
|
||||
$listener = new ContextListener($context, array(), 'key123');
|
||||
$listener = new ContextListener($tokenStorage, array(), 'key123');
|
||||
$listener->handle($event);
|
||||
}
|
||||
|
||||
@ -228,7 +215,8 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$session->set('_security_session', $original);
|
||||
}
|
||||
|
||||
$this->securityContext->setToken($newToken);
|
||||
$tokenStorage = new TokenStorage();
|
||||
$tokenStorage->setToken($newToken);
|
||||
|
||||
$request = new Request();
|
||||
$request->setSession($session);
|
||||
@ -241,7 +229,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
||||
new Response()
|
||||
);
|
||||
|
||||
$listener = new ContextListener($this->securityContext, array(), 'session');
|
||||
$listener = new ContextListener($tokenStorage, array(), 'session');
|
||||
$listener->onKernelResponse($event);
|
||||
|
||||
return $session;
|
||||
|
@ -9,16 +9,16 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Security\Tests\Http\Firewall;
|
||||
namespace Symfony\Component\Security\Http\Tests\Firewall;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
|
||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
|
||||
@ -123,10 +123,10 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$event = $this->createEvent($exception);
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$context->expects($this->once())->method('getToken')->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
|
||||
|
||||
$listener = $this->createExceptionListener($context, $this->createTrustResolver(false), null, $this->createEntryPoint());
|
||||
$listener = $this->createExceptionListener($tokenStorage, $this->createTrustResolver(false), null, $this->createEntryPoint());
|
||||
$listener->onKernelException($event);
|
||||
|
||||
$this->assertEquals('OK', $event->getResponse()->getContent());
|
||||
@ -169,10 +169,10 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
|
||||
return new GetResponseForExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $exception);
|
||||
}
|
||||
|
||||
private function createExceptionListener(SecurityContextInterface $context = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null)
|
||||
private function createExceptionListener(TokenStorageInterface $tokenStorage = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null)
|
||||
{
|
||||
return new ExceptionListener(
|
||||
$context ? $context : $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'),
|
||||
$tokenStorage ? $tokenStorage : $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'),
|
||||
$trustResolver ? $trustResolver : $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'),
|
||||
$httpUtils ? $httpUtils : $this->getMock('Symfony\Component\Security\Http\HttpUtils'),
|
||||
'key',
|
@ -19,7 +19,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testHandleUnmatchedPath()
|
||||
{
|
||||
list($listener, $context, $httpUtils, $options) = $this->getListener();
|
||||
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener();
|
||||
|
||||
list($event, $request) = $this->getGetResponseEvent();
|
||||
|
||||
@ -39,7 +39,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$successHandler = $this->getSuccessHandler();
|
||||
$tokenManager = $this->getTokenManager();
|
||||
|
||||
list($listener, $context, $httpUtils, $options) = $this->getListener($successHandler, $tokenManager);
|
||||
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener($successHandler, $tokenManager);
|
||||
|
||||
list($event, $request) = $this->getGetResponseEvent();
|
||||
|
||||
@ -59,7 +59,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->with($request)
|
||||
->will($this->returnValue($response = new Response()));
|
||||
|
||||
$context->expects($this->once())
|
||||
$tokenStorage->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token = $this->getToken()));
|
||||
|
||||
@ -68,7 +68,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->method('logout')
|
||||
->with($request, $response, $token);
|
||||
|
||||
$context->expects($this->once())
|
||||
$tokenStorage->expects($this->once())
|
||||
->method('setToken')
|
||||
->with(null);
|
||||
|
||||
@ -85,7 +85,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$successHandler = $this->getSuccessHandler();
|
||||
|
||||
list($listener, $context, $httpUtils, $options) = $this->getListener($successHandler);
|
||||
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener($successHandler);
|
||||
|
||||
list($event, $request) = $this->getGetResponseEvent();
|
||||
|
||||
@ -99,7 +99,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->with($request)
|
||||
->will($this->returnValue($response = new Response()));
|
||||
|
||||
$context->expects($this->once())
|
||||
$tokenStorage->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token = $this->getToken()));
|
||||
|
||||
@ -108,7 +108,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->method('logout')
|
||||
->with($request, $response, $token);
|
||||
|
||||
$context->expects($this->once())
|
||||
$tokenStorage->expects($this->once())
|
||||
->method('setToken')
|
||||
->with(null);
|
||||
|
||||
@ -128,7 +128,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$successHandler = $this->getSuccessHandler();
|
||||
|
||||
list($listener, $context, $httpUtils, $options) = $this->getListener($successHandler);
|
||||
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener($successHandler);
|
||||
|
||||
list($event, $request) = $this->getGetResponseEvent();
|
||||
|
||||
@ -152,7 +152,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$tokenManager = $this->getTokenManager();
|
||||
|
||||
list($listener, $context, $httpUtils, $options) = $this->getListener(null, $tokenManager);
|
||||
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener(null, $tokenManager);
|
||||
|
||||
list($event, $request) = $this->getGetResponseEvent();
|
||||
|
||||
@ -175,11 +175,9 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
return $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
|
||||
}
|
||||
|
||||
private function getContext()
|
||||
private function getTokenStorage()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContext')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
}
|
||||
|
||||
private function getGetResponseEvent()
|
||||
@ -210,7 +208,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
private function getListener($successHandler = null, $tokenManager = null)
|
||||
{
|
||||
$listener = new LogoutListener(
|
||||
$context = $this->getContext(),
|
||||
$tokenStorage = $this->getTokenStorage(),
|
||||
$httpUtils = $this->getHttpUtils(),
|
||||
$successHandler ?: $this->getSuccessHandler(),
|
||||
$options = array(
|
||||
@ -222,7 +220,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$tokenManager
|
||||
);
|
||||
|
||||
return array($listener, $context, $httpUtils, $options);
|
||||
return array($listener, $tokenStorage, $httpUtils, $options);
|
||||
}
|
||||
|
||||
private function getSuccessHandler()
|
||||
|
@ -18,17 +18,17 @@ use Symfony\Component\Security\Http\SecurityEvents;
|
||||
|
||||
class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testOnCoreSecurityDoesNotTryToPopulateNonEmptySecurityContext()
|
||||
public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage()
|
||||
{
|
||||
list($listener, $context, , , ,) = $this->getListener();
|
||||
list($listener, $tokenStorage, , , ,) = $this->getListener();
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')))
|
||||
;
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->never())
|
||||
->method('setToken')
|
||||
;
|
||||
@ -38,9 +38,9 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet()
|
||||
{
|
||||
list($listener, $context, $service, ,) = $this->getListener();
|
||||
list($listener, $tokenStorage, $service, ,) = $this->getListener();
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
@ -64,9 +64,9 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenticationManagerImplementation()
|
||||
{
|
||||
list($listener, $context, $service, $manager,) = $this->getListener();
|
||||
list($listener, $tokenStorage, $service, $manager,) = $this->getListener();
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
@ -106,9 +106,9 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation()
|
||||
{
|
||||
list($listener, $context, $service, $manager,) = $this->getListener(false, false);
|
||||
list($listener, $tokenStorage, $service, $manager,) = $this->getListener(false, false);
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
@ -144,9 +144,9 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testOnCoreSecurity()
|
||||
{
|
||||
list($listener, $context, $service, $manager,) = $this->getListener();
|
||||
list($listener, $tokenStorage, $service, $manager,) = $this->getListener();
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
@ -159,7 +159,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue($token))
|
||||
;
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('setToken')
|
||||
->with($this->equalTo($token))
|
||||
@ -183,9 +183,9 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherIsPresent()
|
||||
{
|
||||
list($listener, $context, $service, $manager, , $dispatcher) = $this->getListener(true);
|
||||
list($listener, $tokenStorage, $service, $manager, , $dispatcher) = $this->getListener(true);
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue(null))
|
||||
@ -198,7 +198,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue($token))
|
||||
;
|
||||
|
||||
$context
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('setToken')
|
||||
->with($this->equalTo($token))
|
||||
@ -243,7 +243,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
protected function getListener($withDispatcher = false, $catchExceptions = true)
|
||||
{
|
||||
$listener = new RememberMeListener(
|
||||
$context = $this->getContext(),
|
||||
$tokenStorage = $this->getTokenStorage(),
|
||||
$service = $this->getService(),
|
||||
$manager = $this->getManager(),
|
||||
$logger = $this->getLogger(),
|
||||
@ -251,7 +251,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$catchExceptions
|
||||
);
|
||||
|
||||
return array($listener, $context, $service, $manager, $logger, $dispatcher);
|
||||
return array($listener, $tokenStorage, $service, $manager, $logger, $dispatcher);
|
||||
}
|
||||
|
||||
protected function getLogger()
|
||||
@ -269,9 +269,9 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
return $this->getMock('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface');
|
||||
}
|
||||
|
||||
protected function getContext()
|
||||
protected function getTokenStorage()
|
||||
{
|
||||
return $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
}
|
||||
|
||||
protected function getDispatcher()
|
||||
|
@ -24,12 +24,12 @@ class RemoteUserAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$request = new Request(array(), array(), array(), array(), array(), $serverVars);
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
|
||||
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
|
||||
|
||||
$listener = new RemoteUserAuthenticationListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey'
|
||||
);
|
||||
@ -48,12 +48,12 @@ class RemoteUserAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$request = new Request(array(), array(), array(), array(), array(), array());
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
|
||||
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
|
||||
|
||||
$listener = new RemoteUserAuthenticationListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey'
|
||||
);
|
||||
@ -71,12 +71,12 @@ class RemoteUserAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$request = new Request(array(), array(), array(), array(), array(), array(
|
||||
'TheUserKey' => 'TheUser',
|
||||
));
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
|
||||
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
|
||||
|
||||
$listener = new RemoteUserAuthenticationListener(
|
||||
$context,
|
||||
$tokenStorage,
|
||||
$authenticationManager,
|
||||
'TheProviderKey',
|
||||
'TheUserKey'
|
||||
|
@ -24,12 +24,12 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
private $event;
|
||||
private $logger;
|
||||
private $request;
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
private $token;
|
||||
|
||||
public function testHandle()
|
||||
{
|
||||
$this->securityContext
|
||||
$this->tokenStorage
|
||||
->expects($this->once())
|
||||
->method('setToken')
|
||||
->with($this->equalTo($this->token))
|
||||
@ -58,7 +58,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->with($this->equalTo(SecurityEvents::INTERACTIVE_LOGIN), $this->equalTo($loginEvent))
|
||||
;
|
||||
|
||||
$listener = new SimplePreAuthenticationListener($this->securityContext, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher);
|
||||
$listener = new SimplePreAuthenticationListener($this->tokenStorage, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher);
|
||||
|
||||
$listener->handle($this->event);
|
||||
}
|
||||
@ -74,7 +74,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->throwException($exception))
|
||||
;
|
||||
|
||||
$this->securityContext->expects($this->once())
|
||||
$this->tokenStorage->expects($this->once())
|
||||
->method('setToken')
|
||||
->with($this->equalTo(null))
|
||||
;
|
||||
@ -87,7 +87,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue($this->token))
|
||||
;
|
||||
|
||||
$listener = new SimplePreAuthenticationListener($this->securityContext, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher);
|
||||
$listener = new SimplePreAuthenticationListener($this->tokenStorage, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher);
|
||||
|
||||
$listener->handle($this->event);
|
||||
}
|
||||
@ -111,12 +111,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$this->logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||
|
||||
$this->securityContext = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContext')
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
|
||||
}
|
||||
|
||||
@ -127,7 +122,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->event = null;
|
||||
$this->logger = null;
|
||||
$this->request = null;
|
||||
$this->securityContext = null;
|
||||
$this->tokenStorage = null;
|
||||
$this->token = null;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use Symfony\Component\Security\Http\Firewall\SwitchUserListener;
|
||||
|
||||
class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $securityContext;
|
||||
private $tokenStorage;
|
||||
|
||||
private $userProvider;
|
||||
|
||||
@ -29,7 +29,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
$this->userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
|
||||
$this->userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
||||
$this->accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface');
|
||||
@ -45,7 +45,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testProviderKeyIsRequired()
|
||||
{
|
||||
new SwitchUserListener($this->securityContext, $this->userProvider, $this->userChecker, '', $this->accessDecisionManager);
|
||||
new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, '', $this->accessDecisionManager);
|
||||
}
|
||||
|
||||
public function testEventIsIgnoredIfUsernameIsNotPassedWithTheRequest()
|
||||
@ -53,9 +53,9 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue(null));
|
||||
|
||||
$this->event->expects($this->never())->method('setResponse');
|
||||
$this->securityContext->expects($this->never())->method('setToken');
|
||||
$this->tokenStorage->expects($this->never())->method('setToken');
|
||||
|
||||
$listener = new SwitchUserListener($this->securityContext, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener->handle($this->event);
|
||||
}
|
||||
|
||||
@ -66,10 +66,10 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
|
||||
|
||||
$this->securityContext->expects($this->any())->method('getToken')->will($this->returnValue($token));
|
||||
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
|
||||
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('_exit'));
|
||||
|
||||
$listener = new SwitchUserListener($this->securityContext, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener->handle($this->event);
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->getMock();
|
||||
$role->expects($this->any())->method('getSource')->will($this->returnValue($originalToken));
|
||||
|
||||
$this->securityContext->expects($this->any())
|
||||
$this->tokenStorage->expects($this->any())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($this->getToken(array($role))));
|
||||
|
||||
@ -91,12 +91,12 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->request->query->expects($this->any())->method('all')->will($this->returnValue(array()));
|
||||
$this->request->server->expects($this->once())->method('set')->with('QUERY_STRING', '');
|
||||
|
||||
$this->securityContext->expects($this->once())
|
||||
$this->tokenStorage->expects($this->once())
|
||||
->method('setToken')->with($originalToken);
|
||||
$this->event->expects($this->once())
|
||||
->method('setResponse')->with($this->isInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse'));
|
||||
|
||||
$listener = new SwitchUserListener($this->securityContext, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener->handle($this->event);
|
||||
}
|
||||
|
||||
@ -107,14 +107,14 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
|
||||
|
||||
$this->securityContext->expects($this->any())->method('getToken')->will($this->returnValue($token));
|
||||
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
|
||||
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('kuba'));
|
||||
|
||||
$this->accessDecisionManager->expects($this->once())
|
||||
->method('decide')->with($token, array('ROLE_ALLOWED_TO_SWITCH'))
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$listener = new SwitchUserListener($this->securityContext, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener->handle($this->event);
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
|
||||
$user->expects($this->any())->method('getRoles')->will($this->returnValue(array()));
|
||||
|
||||
$this->securityContext->expects($this->any())->method('getToken')->will($this->returnValue($token));
|
||||
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
|
||||
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('kuba'));
|
||||
$this->request->query->expects($this->once())->method('remove', '_switch_user');
|
||||
$this->request->query->expects($this->any())->method('all')->will($this->returnValue(array()));
|
||||
@ -141,10 +141,10 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue($user));
|
||||
$this->userChecker->expects($this->once())
|
||||
->method('checkPostAuth')->with($user);
|
||||
$this->securityContext->expects($this->once())
|
||||
$this->tokenStorage->expects($this->once())
|
||||
->method('setToken')->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken'));
|
||||
|
||||
$listener = new SwitchUserListener($this->securityContext, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener->handle($this->event);
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
|
||||
$user->expects($this->any())->method('getRoles')->will($this->returnValue(array()));
|
||||
|
||||
$this->securityContext->expects($this->any())->method('getToken')->will($this->returnValue($token));
|
||||
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
|
||||
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('kuba'));
|
||||
$this->request->query->expects($this->once())->method('remove', '_switch_user');
|
||||
$this->request->query->expects($this->any())->method('all')->will($this->returnValue(array('page' => 3, 'section' => 2)));
|
||||
@ -170,10 +170,10 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue($user));
|
||||
$this->userChecker->expects($this->once())
|
||||
->method('checkPostAuth')->with($user);
|
||||
$this->securityContext->expects($this->once())
|
||||
$this->tokenStorage->expects($this->once())
|
||||
->method('setToken')->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken'));
|
||||
|
||||
$listener = new SwitchUserListener($this->securityContext, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||
$listener->handle($this->event);
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,11 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$request = new Request(array(), array(), array(), array(), array(), $serverVars);
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
|
||||
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
|
||||
|
||||
$listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey');
|
||||
$listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey');
|
||||
|
||||
$method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
|
||||
$method->setAccessible(true);
|
||||
@ -60,11 +60,11 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress;
|
||||
$request = new Request(array(), array(), array(), array(), array(), array('SSL_CLIENT_S_DN' => $credentials));
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
|
||||
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
|
||||
|
||||
$listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey');
|
||||
$listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey');
|
||||
|
||||
$method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
|
||||
$method->setAccessible(true);
|
||||
@ -88,11 +88,11 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$request = new Request(array(), array(), array(), array(), array(), array());
|
||||
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
|
||||
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
|
||||
|
||||
$listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey');
|
||||
$listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey');
|
||||
|
||||
$method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
|
||||
$method->setAccessible(true);
|
||||
@ -108,11 +108,11 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
||||
'TheUserKey' => 'TheUser',
|
||||
'TheCredentialsKey' => 'TheCredentials',
|
||||
));
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
|
||||
|
||||
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
|
||||
|
||||
$listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey', 'TheUserKey', 'TheCredentialsKey');
|
||||
$listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey', 'TheUserKey', 'TheCredentialsKey');
|
||||
|
||||
$method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
|
||||
$method->setAccessible(true);
|
||||
|
@ -302,6 +302,10 @@
|
||||
<source>An empty file is not allowed.</source>
|
||||
<target>Plik nie może być pusty.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="79">
|
||||
<source>The host could not be resolved.</source>
|
||||
<target>Nazwa hosta nie została rozpoznana.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
@ -302,6 +302,10 @@
|
||||
<source>An empty file is not allowed.</source>
|
||||
<target>Пустые файлы не разрешены.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="79">
|
||||
<source>The host could not be resolved.</source>
|
||||
<target>Имя хоста не может быть разрешено.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
@ -302,6 +302,10 @@
|
||||
<source>An empty file is not allowed.</source>
|
||||
<target>Prazna datoteka ni dovoljena.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="79">
|
||||
<source>The host could not be resolved.</source>
|
||||
<target>Gostitelja ni bilo mogoče prepoznati.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Yaml\Deprecated;
|
||||
|
||||
trigger_error('Constant ENCODING in class Symfony\Component\Yaml\Unescaper is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.7, to be removed in 3.0.
|
||||
* @internal
|
||||
*/
|
||||
final class Unescaper
|
||||
{
|
||||
const ENCODING = 'UTF-8';
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
use Symfony\Component\Yaml\Deprecated\Unescaper as Deprecated;
|
||||
|
||||
/**
|
||||
* Unescaper encapsulates unescaping rules for single and double-quoted
|
||||
* YAML strings.
|
||||
@ -26,8 +24,9 @@ class Unescaper
|
||||
* must be converted to that encoding.
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0
|
||||
* @internal
|
||||
*/
|
||||
const ENCODING = Deprecated::ENCODING;
|
||||
const ENCODING = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Regex fragment that matches an escaped character in a double quoted string.
|
||||
|
Reference in New Issue
Block a user