Skip to content

Commit 2b6a6b4

Browse files
Merge branch '5.4' into 6.3
* 5.4: Fix implicitly-required parameters List CS fix in .git-blame-ignore-revs Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value [Messenger][AmazonSqs] Allow async-aws/sqs version 2
2 parents a185fa0 + ed19471 commit 2b6a6b4

File tree

12 files changed

+165
-11
lines changed

12 files changed

+165
-11
lines changed

Diff for: DataCollector/SecurityDataCollector.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
4444
private ?TraceableFirewallListener $firewall;
4545
private bool $hasVarDumper;
4646

47-
public function __construct(TokenStorageInterface $tokenStorage = null, RoleHierarchyInterface $roleHierarchy = null, LogoutUrlGenerator $logoutUrlGenerator = null, AccessDecisionManagerInterface $accessDecisionManager = null, FirewallMapInterface $firewallMap = null, TraceableFirewallListener $firewall = null)
47+
public function __construct(?TokenStorageInterface $tokenStorage = null, ?RoleHierarchyInterface $roleHierarchy = null, ?LogoutUrlGenerator $logoutUrlGenerator = null, ?AccessDecisionManagerInterface $accessDecisionManager = null, ?FirewallMapInterface $firewallMap = null, ?TraceableFirewallListener $firewall = null)
4848
{
4949
$this->tokenStorage = $tokenStorage;
5050
$this->roleHierarchy = $roleHierarchy;
@@ -55,7 +55,7 @@ public function __construct(TokenStorageInterface $tokenStorage = null, RoleHier
5555
$this->hasVarDumper = class_exists(ClassStub::class);
5656
}
5757

58-
public function collect(Request $request, Response $response, \Throwable $exception = null): void
58+
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
5959
{
6060
if (null === $this->tokenStorage) {
6161
$this->data = [

Diff for: DependencyInjection/SecurityExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ private function createExpression(ContainerBuilder $container, string $expressio
937937
return $this->expressions[$id] = new Reference($id);
938938
}
939939

940-
private function createRequestMatcher(ContainerBuilder $container, string $path = null, string $host = null, int $port = null, array $methods = [], array $ips = null, array $attributes = []): Reference
940+
private function createRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, ?int $port = null, array $methods = [], ?array $ips = null, array $attributes = []): Reference
941941
{
942942
if ($methods) {
943943
$methods = array_map('strtoupper', $methods);

Diff for: LoginLink/FirewallAwareLoginLinkHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(FirewallMap $firewallMap, ContainerInterface $loginL
3838
$this->requestStack = $requestStack;
3939
}
4040

41-
public function createLoginLink(UserInterface $user, Request $request = null, int $lifetime = null): LoginLinkDetails
41+
public function createLoginLink(UserInterface $user, ?Request $request = null, ?int $lifetime = null): LoginLinkDetails
4242
{
4343
return $this->getForFirewall()->createLoginLink($user, $request, $lifetime);
4444
}

Diff for: Security.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getFirewallConfig(Request $request): ?FirewallConfig
5959
*
6060
* @return Response|null The authenticator success response if any
6161
*/
62-
public function login(UserInterface $user, string $authenticatorName = null, string $firewallName = null): ?Response
62+
public function login(UserInterface $user, ?string $authenticatorName = null, ?string $firewallName = null): ?Response
6363
{
6464
$request = $this->container->get('request_stack')->getCurrentRequest();
6565
if (null === $request) {

Diff for: Security/FirewallContext.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FirewallContext
3030
/**
3131
* @param iterable<mixed, callable> $listeners
3232
*/
33-
public function __construct(iterable $listeners, ExceptionListener $exceptionListener = null, LogoutListener $logoutListener = null, FirewallConfig $config = null)
33+
public function __construct(iterable $listeners, ?ExceptionListener $exceptionListener = null, ?LogoutListener $logoutListener = null, ?FirewallConfig $config = null)
3434
{
3535
$this->listeners = $listeners;
3636
$this->exceptionListener = $exceptionListener;

Diff for: Tests/DataCollector/SecurityDataCollectorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function testCollectCollectsDecisionLogWhenStrategyIsAffirmative()
227227
$voter2 = new DummyVoter();
228228

229229
$decoratedVoter1 = new TraceableVoter($voter1, new class() implements EventDispatcherInterface {
230-
public function dispatch(object $event, string $eventName = null): object
230+
public function dispatch(object $event, ?string $eventName = null): object
231231
{
232232
return new \stdClass();
233233
}
@@ -302,7 +302,7 @@ public function testCollectCollectsDecisionLogWhenStrategyIsUnanimous()
302302
$voter2 = new DummyVoter();
303303

304304
$decoratedVoter1 = new TraceableVoter($voter1, new class() implements EventDispatcherInterface {
305-
public function dispatch(object $event, string $eventName = null): object
305+
public function dispatch(object $event, ?string $eventName = null): object
306306
{
307307
return new \stdClass();
308308
}

Diff for: Tests/DependencyInjection/Compiler/RegisterEntryPointsPassTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
9393
], JsonResponse::HTTP_FORBIDDEN);
9494
}
9595

96-
public function start(Request $request, AuthenticationException $authException = null): Response
96+
public function start(Request $request, ?AuthenticationException $authException = null): Response
9797
{
9898
}
9999
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\Tests\Functional\Bundle\AnonymousBundle;
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\Core\User\UserInterface;
19+
use Symfony\Component\Security\Core\User\UserProviderInterface;
20+
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
21+
22+
class AppCustomAuthenticator extends AbstractGuardAuthenticator
23+
{
24+
public function supports(Request $request): bool
25+
{
26+
return false;
27+
}
28+
29+
public function getCredentials(Request $request)
30+
{
31+
}
32+
33+
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
34+
{
35+
}
36+
37+
public function checkCredentials($credentials, UserInterface $user): bool
38+
{
39+
}
40+
41+
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
42+
{
43+
}
44+
45+
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response
46+
{
47+
}
48+
49+
public function start(Request $request, ?AuthenticationException $authException = null): Response
50+
{
51+
return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED);
52+
}
53+
54+
public function supportsRememberMe(): bool
55+
{
56+
}
57+
}

Diff for: Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class EntryPointStub implements AuthenticationEntryPointInterface
2020
{
2121
public const RESPONSE_TEXT = '2be8e651259189d841a19eecdf37e771e2431741';
2222

23-
public function start(Request $request, AuthenticationException $authException = null): Response
23+
public function start(Request $request, ?AuthenticationException $authException = null): Response
2424
{
2525
return new Response(self::RESPONSE_TEXT);
2626
}

Diff for: Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(ContainerInterface $container)
2929
$this->container = $container;
3030
}
3131

32-
public function loginAction(Request $request, UserInterface $user = null)
32+
public function loginAction(Request $request, ?UserInterface $user = null)
3333
{
3434
// get the login error if there is one
3535
if ($request->attributes->has(SecurityRequestAttributes::AUTHENTICATION_ERROR)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\Tests\Functional\Bundle\GuardedBundle;
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\Core\User\UserInterface;
19+
use Symfony\Component\Security\Core\User\UserProviderInterface;
20+
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
21+
22+
class AppCustomAuthenticator extends AbstractGuardAuthenticator
23+
{
24+
public function supports(Request $request): bool
25+
{
26+
return '/manual_login' !== $request->getPathInfo() && '/profile' !== $request->getPathInfo();
27+
}
28+
29+
public function getCredentials(Request $request)
30+
{
31+
throw new AuthenticationException('This should be hit');
32+
}
33+
34+
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
35+
{
36+
}
37+
38+
public function checkCredentials($credentials, UserInterface $user): bool
39+
{
40+
}
41+
42+
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
43+
{
44+
return new Response('', 418);
45+
}
46+
47+
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response
48+
{
49+
}
50+
51+
public function start(Request $request, ?AuthenticationException $authException = null): Response
52+
{
53+
return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED);
54+
}
55+
56+
public function supportsRememberMe(): bool
57+
{
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\Tests\Functional\Bundle\GuardedBundle;
13+
14+
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\Response;
16+
use Symfony\Component\Security\Core\User\InMemoryUser;
17+
use Symfony\Component\Security\Core\User\UserInterface;
18+
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
19+
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
20+
21+
class AuthenticationController
22+
{
23+
public function manualLoginAction(GuardAuthenticatorHandler $guardAuthenticatorHandler, Request $request)
24+
{
25+
$guardAuthenticatorHandler->authenticateWithToken(new PostAuthenticationGuardToken(new InMemoryUser('Jane', 'test', ['ROLE_USER']), 'secure', ['ROLE_USER']), $request, 'secure');
26+
27+
return new Response('Logged in.');
28+
}
29+
30+
public function profileAction(?UserInterface $user = null)
31+
{
32+
if (null === $user) {
33+
return new Response('Not logged in.');
34+
}
35+
36+
return new Response('Username: '.$user->getUserIdentifier());
37+
}
38+
}

0 commit comments

Comments
 (0)