8000 Merge branch '2.8' · symfony/symfony@4067a5c · GitHub
[go: up one dir, main page]

Skip to content

Commit 4067a5c

Browse files
committed
Merge branch '2.8'
* 2.8: Updated the stlyes of the YAML commands [Security] Configuring a user checker per firewall [PropertyInfo] Test behavior when an extractor return null.
2 parents 7e3c4a6 + 112c66c commit 4067a5c

File tree

24 files changed

+203
-34
lines changed

24 files changed

+203
-34
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Console\Input\InputInterface;
1616
use Symfony\Component\Console\Input\InputOption;
1717
use Symfony\Component\Console\Output\OutputInterface;
18+
use Symfony\Component\Console\Style\SymfonyStyle;
1819
use Symfony\Component\Finder\Finder;
1920
use Symfony\Component\Yaml\Exception\ParseException;
2021
use Symfony\Component\Yaml\Parser;
@@ -61,6 +62,8 @@ protected function configure()
6162

6263
protected function execute(InputInterface $input, OutputInterface $output)
6364
{
65+
$stdout = $output;
66+
$output = new SymfonyStyle($input, $output);
6467
$filename = $input->getArgument('filename');
6568

6669
if (!$filename) {
@@ -73,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7376
$content .= fread(STDIN, 1024);
7477
}
7578

76-
return $this->display($input, $output, array($this->validate($content)));
79+
return $this->display($input, $stdout, $output, array($this->validate($content)));
7780
}
7881

7982
if (0 !== strpos($filename, '@') && !is_readable($filename)) {
@@ -95,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9598
$filesInfo[] = $this->validate(file_get_contents($file), $file);
9699
}
97100

98-
return $this->display($input, $output, $filesInfo);
101+
return $this->display($input, $stdout, $output, $filesInfo);
99102
}
100103

101104
private function validate($content, $file = null)
@@ -110,33 +113,37 @@ private function validate($content, $file = null)
110113
return array('file' => $file, 'valid' => true);
111114
}
112115

113-
private function display(InputInterface $input, OutputInterface $output, $files)
116+
private function display(InputInterface $input, OutputInterface $stdout, $output, $files)
114117
{
115118
switch ($input->getOption('format')) {
116119
case 'txt':
117-
return $this->displayTxt($output, $files);
120+
return $this->displayTxt($stdout, $output, $files);
118121
case 'json':
119122
return $this->displayJson($output, $files);
120123
default:
121124
throw new \InvalidArgumentException(sprintf('The format "%s" is not supported.', $input->getOption('format')));
122125
}
123126
}
124127

125-
private function displayTxt(OutputInterface $output, $filesInfo)
128+
private function displayTxt(OutputInterface $stdout, $output, $filesInfo)
126129
{
127130
$errors = 0;
128131

129132
foreach ($filesInfo as $info) {
130-
if ($info['valid'] && $output->isVerbose()) {
131-
$output->writeln('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
133+
if ($info['valid'] && $stdout->isVerbose()) {
134+
$output->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
132135
} elseif (!$info['valid']) {
133136
++$errors;
134-
$output->writeln(sprintf('<error>KO</error> in %s', $info['file']));
135-
$output->writeln(sprintf('<error>>> %s</error>', $info['message']));
137+
$output->text(sprintf('<error> ERROR </error> in %s', $info['file']));
138+
$output->text(sprintf('<error> >> %s</error>', $info['message']));
136139
}
137140
}
138141

139-
$output->writeln(sprintf('<comment>%d/%d valid files</comment>', count($filesInfo) - $errors, count($filesInfo)));
142+
if ($errors === 0) {
143+
$output->success(sprintf('All %d YAML files contain valid syntax.', count($filesInfo)));
144+
} else {
145+
$output->warning(sprintf('%d YAML files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors));
146+
}
140147

141148
return min($errors, 1);
142149
}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public function testDebugAllRoutes()
2525
$ret = $tester->execute(array('name' => null), array('decorated' => false));
2626

2727
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
28-
$this->assertContains('Path', $tester->getDisplay());
29-
$this->assertContains('/foo', $tester->getDisplay());
28+
$this->assertContains('Name Method Scheme Host Path', $tester->getDisplay());
3029
}
3130

3231
public function testDebugSingleRoute()

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
216216
->prototype('scalar')->end()
217217
->end()
218218
->booleanNode('security')->defaultTrue()->end()
219+
->scalarNode('user_checker')
220+
->defaultValue('security.user_checker')
221+
->treatNullLike('security.user_checker')
222+
->info('The UserChecker to use when authenticating users in this firewall.')
223+
->end()
219224
->scalarNode('request_matcher')->end()
220225
->scalarNode('access_denied_url')->end()
221226
->scalarNode('access_denied_handler')->end()

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
6565
$container
6666
->setDefinition($provider, new DefinitionDecorator('security.authentication.provider.dao'))
6767
->replaceArgument(0, new Reference($userProviderId))
68+
->replaceArgument(1, new Reference('security.user_checker.'.$id))
6869
->replaceArgument(2, $id)
6970
;
7071

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginLdapFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
3030
$container
3131
->setDefinition($provider, new DefinitionDecorator('security.authentication.provider.ldap_bind'))
3232
->replaceArgument(0, new Reference($userProviderId))
33+
->replaceArgument(1, new Reference('security.user_checker.'.$id))
3334
->replaceArgument(2, $id)
3435
->replaceArgument(3, new Reference($config['service']))
3536
->replaceArgument(4, $config['dn_string'])

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
6969
->replaceArgument(0, $authenticatorReferences)
7070
->replaceArgument(1, new Reference($userProvider))
7171
->replaceArgument(2, $id)
72+
->replaceArgument(3, new Reference('security.user_checker.'.$id))
7273
;
7374

7475
// listener

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
2929
$container
3030
->setDefinition($provider, new DefinitionDecorator('security.authentication.provider.dao'))
3131
->replaceArgument(0, new Reference($userProvider))
32+
->replaceArgument(1, new Reference('security.user_checker.'.$id))
3233
->replaceArgument(2, $id)
3334
;
3435

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicLdapFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
3131
$container
3232
->setDefinition($provider, new DefinitionDecorator('security.authentication.provider.ldap_bind'))
3333
->replaceArgument(0, new Reference($userProvider))
34+
->replaceArgument(1, new Reference('security.user_checker.'.$id))
3435
->replaceArgument(2, $id)
3536
->replaceArgument(3, new Reference($config['service']))
3637
->replaceArgument(4, $config['dn_string'])

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
3535
$authProviderId = 'security.authentication.provider.rememberme.'.$id;
3636
$container
3737
->setDefinition($authProviderId, new DefinitionDecorator('security.authentication.provider.rememberme'))
38+
->replaceArgument(0, new Reference('security.user_checker.'.$id))
3839
->addArgument($config['secret'])
3940
->addArgument($id)
4041
;

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RemoteUserFactory.php

Lines changed: 1 addition & 0 deletions
< 639E div data-testid="neutral diffstat" class="DiffSquares-module__diffSquare--KZMTU DiffSquares-module__neutral--_tGgY">
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
3030
$container
3131
->setDefinition($providerId, new DefinitionDecorator('security.authentication.provider.pre_authenticated'))
3232
->replaceArgument(0, new Reference($userProvider))
33+
->replaceArgument(1, new Reference('security.user_checker.'.$id))
3334
->addArgument($id)
3435
;
3536

0 commit comments

Comments
 (0)
0