Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3cb947d

Browse filesBrowse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Security][WIP] Add authenticators info to the profiler [Translation] Use symfony default locale when pulling translations from providers added missing translations for Bosnian (bs) Add the missing greek translations for security core and validator component [HttpKernel] Fix return types in `EventDataCollector` Do not call substr_count() if ip is null to avoid deprecation warning in PHP 8.1 [Security][Validator] Add missing translations for Slovenian (sl) [Messenger] Add worker metadata inside logs [Messenger] Log when worker should stop and when `SIGTERM` is received cs fix [Security][Validator] Add missing translations for Finnish (fi) [VarDumper] returns a 500 when dd() is executed chore(VarDumper): declare that dd() never returns [MonologBridge] Deprecate the Swiftmailer handler [Cache] Commit items implicitly only when deferred keys are requested [MonologBridge] Deprecates ResetLoggersWorkerSubscriber Fix "can not" spelling [HttpClient] fix missing kernel.reset tag on TraceableHttpClient services [Form] Fix ChoiceType Extension to effectively set and use the translator Added new CssColor constraint
2 parents 143ecb3 + febe169 commit 3cb947d
Copy full SHA for 3cb947d

File tree

Expand file treeCollapse file tree

100 files changed

+1666
-361
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

100 files changed

+1666
-361
lines changed

‎UPGRADE-5.4.md

Copy file name to clipboardExpand all lines: UPGRADE-5.4.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Messenger
5151
SecurityBundle
5252
--------------
5353

54+
* Deprecate `FirewallConfig::getListeners()`, use `FirewallConfig::getAuthenticators()` instead
5455
* Deprecate `security.authentication.basic_entry_point` and `security.authentication.retry_entry_point` services, the logic is moved into the
5556
`HttpBasicAuthenticator` and `ChannelListener` respectively
5657
* Deprecate not setting `$authenticatorManagerEnabled` to `true` in `SecurityDataCollector` and `DebugFirewallCommand`

‎UPGRADE-6.0.md

Copy file name to clipboardExpand all lines: UPGRADE-6.0.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ Security
400400
SecurityBundle
401401
--------------
402402

403+
* Remove `FirewallConfig::getListeners()`, use `FirewallConfig::getAuthenticators()` instead
403404
* Remove `security.authentication.basic_entry_point` and `security.authentication.retry_entry_point` services,
404405
the logic is moved into the `HttpBasicAuthenticator` and `ChannelListener` respectively
405406
* Remove `SecurityFactoryInterface` and `SecurityExtension::addSecurityListenerFactory()` in favor of

‎src/Symfony/Bridge/Doctrine/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/CHANGELOG.md
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ CHANGELOG
88

99
5.4
1010
---
11-
* Add a middleware to log when transaction has been left open `DoctrineOpenTransactionLoggerMiddleware`
11+
12+
* Add `DoctrineOpenTransactionLoggerMiddleware` to log when a transaction has been left open
1213

1314
5.3
1415
---

‎src/Symfony/Bridge/Monolog/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ CHANGELOG
77
* The `$actionLevel` constructor argument of `NotFoundActivationStrategy` has been replaced by the `$inner` one which expects an `ActivationStrategyInterface` to decorate instead
88
* The `$actionLevel` constructor argument of `HttpCodeActivationStrategy` has been replaced by the `$inner` one which expects an `ActivationStrategyInterface` to decorate instead
99

10+
5.4
11+
---
12+
13+
* Deprecate `ResetLoggersWorkerSubscriber` to reset buffered logs in messenger
14+
workers, use "reset_on_message" option in messenger configuration instead.
15+
1016
5.3
1117
---
1218

‎src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
1616
use Symfony\Component\HttpKernel\Event\TerminateEvent;
1717

18+
trigger_deprecation('symfony/monolog-bridge', '5.4', '"%s" is deprecated and will be removed in 6.0.', SwiftMailerHandler::class);
19+
1820
/**
1921
* Extended SwiftMailerHandler that flushes mail queue if necessary.
2022
*
2123
* @author Philipp Kräutli <pkraeutli@astina.ch>
2224
*
2325
* @final
26+
*
27+
* @deprecated since Symfony 5.4
2428
*/
2529
class SwiftMailerHandler extends BaseSwiftMailerHandler
2630
{

‎src/Symfony/Bridge/Monolog/Messenger/ResetLoggersWorkerSubscriber.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Messenger/ResetLoggersWorkerSubscriber.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
1717
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;
1818

19+
trigger_deprecation('symfony/monolog-bridge', '5.4', 'The "%s" class is deprecated, use "reset_on_message" option in messenger configuration instead.', ResetLoggersWorkerSubscriber::class);
20+
1921
/**
2022
* Reset loggers between messages being handled to release buffered handler logs.
2123
*
2224
* @author Laurent VOULLEMIER <laurent.voullemier@gmail.com>
25+
*
26+
* @deprecated since Symfony 5.4, use "reset_on_message" option in messenger configuration instead.
2327
*/
2428
class ResetLoggersWorkerSubscriber implements EventSubscriberInterface
2529
{

‎src/Symfony/Bridge/Monolog/Tests/Messenger/ResetLoggersWorkerSubscriberTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Tests/Messenger/ResetLoggersWorkerSubscriberTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
2626
use Symfony\Component\Messenger\Worker;
2727

28+
/** @group legacy */
2829
class ResetLoggersWorkerSubscriberTest extends TestCase
2930
{
3031
public function testLogsAreFlushed()

‎src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getExtractData()
8282
['{{ ("another " ~ "new " ~ "key") | trans() }}', ['another new key' => 'messages']],
8383
['{{ ("new" ~ " key") | trans(domain="domain") }}', ['new key' => 'domain']],
8484
['{{ ("another " ~ "new " ~ "key") | trans(domain="domain") }}', ['another new key' => 'domain']],
85-
// if it has a variable or other expression, we can not extract it
85+
// if it has a variable or other expression, we cannot extract it
8686
['{% set foo = "new" %} {{ ("new " ~ foo ~ "key") | trans() }}', []],
8787
['{{ ("foo " ~ "new"|trans ~ "key") | trans() }}', ['new' => 'messages']],
8888
];

‎src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private function absoluteSymlinkWithFallback(string $originDir, string $targetDi
231231
/**
232232
* Creates symbolic link.
233233
*
234-
* @throws IOException if link can not be created
234+
* @throws IOException if link cannot be created
235235
*/
236236
private function symlink(string $originDir, string $targetDir, bool $relative = false)
237237
{

‎src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ protected function validateInput(InputInterface $input)
206206

207207
$name = $input->getArgument('name');
208208
if ((null !== $name) && ($optionsCount > 0)) {
209-
throw new InvalidArgumentException('The options tags, tag, parameters & parameter can not be combined with the service name argument.');
209+
throw new InvalidArgumentException('The options tags, tag, parameters & parameter cannot be combined with the service name argument.');
210210
} elseif ((null === $name) && $optionsCount > 1) {
211-
throw new InvalidArgumentException('The options tags, tag, parameters & parameter can not be combined together.');
211+
throw new InvalidArgumentException('The options tags, tag, parameters & parameter cannot be combined together.');
212212
}
213213
}
214214

‎src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ protected function addFlash(string $type, mixed $message): void
175175
try {
176176
$this->container->get('request_stack')->getSession()->getFlashBag()->add($type, $message);
177177
} catch (SessionNotFoundException $e) {
178-
throw new \LogicException('You can not use the addFlash method if sessions are disabled. Enable them in "config/packages/framework.yaml".', 0, $e);
178+
throw new \LogicException('You cannot use the addFlash method if sessions are disabled. Enable them in "config/packages/framework.yaml".', 0, $e);
179179
}
180180
}
181181

@@ -216,7 +216,7 @@ protected function denyAccessUnlessGranted(mixed $attribute, mixed $subject = nu
216216
protected function renderView(string $view, array $parameters = []): string
217217
{
218218
if (!$this->container->has('twig')) {
219-
throw new \LogicException('You can not use the "renderView" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
219+
throw new \LogicException('You cannot use the "renderView" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
220220
}
221221

222222
return $this->container->get('twig')->render($view, $parameters);
@@ -274,7 +274,7 @@ protected function renderForm(string $view, array $parameters = [], Response $re
274274
protected function stream(string $view, array $parameters = [], StreamedResponse $response = null): StreamedResponse
275275
{
276276
if (!$this->container->has('twig')) {
277-
throw new \LogicException('You can not use the "stream" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
277+
throw new \LogicException('You cannot use the "stream" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
278278
}
279279

280280
$twig = $this->container->get('twig');
@@ -316,7 +316,7 @@ protected function createNotFoundException(string $message = 'Not Found', \Throw
316316
protected function createAccessDeniedException(string $message = 'Access Denied.', \Throwable $previous = null): AccessDeniedException
317317
{
318318
if (!class_exists(AccessDeniedException::class)) {
319-
throw new \LogicException('You can not use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require symfony/security-bundle".');
319+
throw new \LogicException('You cannot use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require symfony/security-bundle".');
320320
}
321321

322322
return new AccessDeniedException($message, $previous);
@@ -381,7 +381,7 @@ protected function isCsrfTokenValid(string $id, ?string $token): bool
381381
protected function addLink(Request $request, LinkInterface $link): void
382382
{
383383
if (!class_exists(AddLinkHeaderListener::class)) {
384-
throw new \LogicException('You can not use the "addLink" method if the WebLink component is not available. Try running "composer require symfony/web-link".');
384+
throw new \LogicException('You cannot use the "addLink" method if the WebLink component is not available. Try running "composer require symfony/web-link".');
385385
}
386386

387387
if (null === $linkProvider = $request->attributes->get('_links')) {

‎src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(Environment $twig = null)
4242
public function templateAction(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null, array $context = []): Response
4343
{
4444
if (null === $this->twig) {
45-
throw new \LogicException('You can not use the TemplateController if the Twig Bundle is not available.');
45+
throw new \LogicException('You cannot use the TemplateController if the Twig Bundle is not available.');
4646
}
4747

4848
$response = new Response($this->twig->render($template, $context));

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@
193193
->tag('monolog.logger', ['channel' => 'messenger'])
194194

195195
->set('messenger.listener.stop_worker_on_sigterm_signal_listener', StopWorkerOnSigtermSignalListener::class)
196+
->args([
197+
service('logger')->ignoreOnInvalid(),
198+
])
196199
->tag('kernel.event_subscriber')
197200

198201
->set('messenger.listener.stop_worker_on_stop_exception_listener', StopWorkerOnCustomStopExceptionListener::class)

‎src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testTwig()
3535
public function testNoTwig()
3636
{
3737
$this->expectException(\LogicException::class);
38-
$this->expectExceptionMessage('You can not use the TemplateController if the Twig Bundle is not available.');
38+
$this->expectExceptionMessage('You cannot use the TemplateController if the Twig Bundle is not available.');
3939
$controller = new TemplateController();
4040

4141
$controller->templateAction('mytemplate')->getContent();

‎src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ CHANGELOG
1616
5.4
1717
---
1818

19+
* Deprecate `FirewallConfig::getListeners()`, use `FirewallConfig::getAuthenticators()` instead
1920
* Deprecate `security.authentication.basic_entry_point` and `security.authentication.retry_entry_point` services, the logic is moved into the
2021
`HttpBasicAuthenticator` and `ChannelListener` respectively
2122
* Deprecate `FirewallConfig::allowsAnonymous()` and the `allows_anonymous` from the data collector data, there will be no anonymous concept as of version 6.

‎src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function collect(Request $request, Response $response, \Throwable $except
184184
'access_denied_handler' => $firewallConfig->getAccessDeniedHandler(),
185185
'access_denied_url' => $firewallConfig->getAccessDeniedUrl(),
186186
'user_checker' => $firewallConfig->getUserChecker(),
187-
'listeners' => $firewallConfig->getListeners(),
187+
'authenticators' => $firewallConfig->getAuthenticators(),
188188
];
189189

190190
// generate exit impersonation path from current request
@@ -203,6 +203,8 @@ public function collect(Request $request, Response $response, \Throwable $except
203203
if ($this->firewall) {
204204
$this->data['listeners'] = $this->firewall->getWrappedListeners();
205205
}
206+
207+
$this->data['authenticators'] = $this->firewall ? $this->firewall->getAuthenticatorsInfo() : [];
206208
}
207209

208210
/**
@@ -345,6 +347,11 @@ public function getListeners(): array|Data
345347
return $this->data['listeners'];
346348
}
347349

350+
public function getAuthenticators(): array|Data
351+
{
352+
return $this->data['authenticators'];
353+
}
354+
348355
/**
349356
* {@inheritdoc}
350357
*/
+104Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\SecurityBundle\Debug\Authenticator;
13+
14+
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\Response;
16+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
17+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
18+
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
19+
use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInterface;
20+
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
21+
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
22+
use Symfony\Component\Security\Http\EntryPoint\Exception\NotAnEntryPointException;
23+
use Symfony\Component\VarDumper\Caster\ClassStub;
24+
25+
/**
26+
* @author Robin Chalas <robin.chalas@gmail.com>
27+
*
28+
* @internal
29+
*/
30+
final class TraceableAuthenticator implements AuthenticatorInterface, InteractiveAuthenticatorInterface, AuthenticationEntryPointInterface
31+
{
32+
private $authenticator;
33+
private $passport;
34+
private $duration;
35+
private $stub;
36+
37+
public function __construct(AuthenticatorInterface $authenticator)
38+
{
39+
$this->authenticator = $authenticator;
40+
}
41+
42+
public function getInfo(): array
43+
{
44+
return [
45+
'supports' => true,
46+
'passport' => $this->passport,
47+
'duration' => $this->duration,
48+
'stub' => $this->stub ?? $this->stub = new ClassStub(\get_class($this->authenticator)),
49+
];
50+
}
51+
52+
public function supports(Request $request): ?bool
53+
{
54+
return $this->authenticator->supports($request);
55+
}
56+
57+
public function authenticate(Request $request): Passport
58+
{
59+
$startTime = microtime(true);
60+
$this->passport = $this->authenticator->authenticate($request);
61+
$this->duration = microtime(true) - $startTime;
62+
63+
return $this->passport;
64+
}
65+
66+
public function createToken(Passport $passport, string $firewallName): TokenInterface
67+
{
68+
return method_exists($this->authenticator, 'createToken') ? $this->authenticator->createToken($passport, $firewallName) : $this->authenticator->createAuthenticatedToken($passport, $firewallName);
69+
}
70+
71+
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
72+
{
73+
return $this->authenticator->createAuthenticatedToken($passport, $firewallName);
74+
}
75+
76+
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
77+
{
78+
return $this->authenticator->onAuthenticationSuccess($request, $token, $firewallName);
79+
}
80+
81+
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
82+
{
83+
return $this->authenticator->onAuthenticationFailure($request, $exception);
84+
}
85+
86+
public function start(Request $request, AuthenticationException $authException = null): Response
87+
{
88+
if (!$this->authenticator instanceof AuthenticationEntryPointInterface) {
89+
throw new NotAnEntryPointException();
90+
}
91+
92+
return $this->authenticator->start($request, $authException);
93+
}
94+
95+
public function isInteractive(): bool
96+
{
97+
return $this->authenticator instanceof InteractiveAuthenticatorInterface && $this->authenticator->isInteractive();
98+
}
99+
100+
public function __call($method, $args)
101+
{
102+
return $this->authenticator->{$method}(...$args);
103+
}
104+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.