Skip to content

Commit ae71a15

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: (31 commits) fix test Clarify goals of AbstractController cs fix [Security][Validator] Add missing translations for Indonesian (id) [Security] Deprecate legacy signatures [Notifier] fix typo firebase [SecurityBundle] Create a smooth upgrade path for security factories Add trailing Line return if last line is non empty Add trailing Line return if last line is non empty [Security] Deprecate `PassportInterface` Report mismatches between trans-unit id and source text via status script Do not add namespace argument to NullAdapter in CachePoolPass [FrameworkBundle] Update cache:clear help [HttpFoundation] Add `litespeed_finish_request` to `Response` Fix markup (minor) remove author tags from test classes [Notifier] add `SentMessageEvent` and `FailedMessageEvent` [HttpFoundation] Mark Request::get() internal Add missing to semi-colon to exception.js [FrameworkBundle] remove dead conditions in Translation Commands ...
2 parents 6317ca4 + 0b11b63 commit ae71a15

File tree

6 files changed

+34
-18
lines changed

6 files changed

+34
-18
lines changed

Authorization/AuthorizationChecker.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,29 @@ class AuthorizationChecker implements AuthorizationCheckerInterface
3232
private $alwaysAuthenticate;
3333
private $exceptionOnNoToken;
3434

35-
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, AccessDecisionManagerInterface $accessDecisionManager, bool $alwaysAuthenticate = false, bool $exceptionOnNoToken = true)
35+
public function __construct(TokenStorageInterface $tokenStorage, /*AccessDecisionManagerInterface*/ $accessDecisionManager, /*bool*/ $alwaysAuthenticate = false, /*bool*/ $exceptionOnNoToken = true)
3636
{
37+
if ($accessDecisionManager instanceof AuthenticationManagerInterface) {
38+
trigger_deprecation('symfony/security-core', '5.4', 'The $autenticationManager argument of "%s" is deprecated.', __METHOD__);
39+
40+
$this->authenticationManager = $accessDecisionManager;
41+
$accessDecisionManager = $alwaysAuthenticate;
42+
$alwaysAuthenticate = $exceptionOnNoToken;
43+
$exceptionOnNoToken = \func_num_args() > 4 ? func_get_arg(4) : true;
44+
}
45+
3746
if (false !== $alwaysAuthenticate) {
3847
trigger_deprecation('symfony/security-core', '5.4', 'Not setting the 4th argument of "%s" to "false" is deprecated.', __METHOD__);
3948
}
4049
if (false !== $exceptionOnNoToken) {
4150
trigger_deprecation('symfony/security-core', '5.4', 'Not setting the 5th argument of "%s" to "false" is deprecated.', __METHOD__);
4251
}
4352

53+
if (!$accessDecisionManager instanceof AccessDecisionManagerInterface) {
54+
throw new \TypeError(sprintf('Argument 2 of "%s" must be instance of "%s", "%s" given.', __METHOD__, AccessDecisionManagerInterface::class, get_debug_type($accessDecisionManager)));
55+
}
56+
4457
$this->tokenStorage = $tokenStorage;
45-
$this->authenticationManager = $authenticationManager;
4658
$this->accessDecisionManager = $accessDecisionManager;
4759
$this->alwaysAuthenticate = $alwaysAuthenticate;
4860
$this->exceptionOnNoToken = $exceptionOnNoToken;

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ CHANGELOG
1212
5.4
1313
---
1414

15-
* Deprecate setting the 4th argument (`$alwaysAuthenticate`) to `true` and not setting the
16-
5th argument (`$exceptionOnNoToken`) to `false` of `AuthorizationChecker`
15+
* Deprecate the `$authenticationManager` argument of the `AuthorizationChecker` constructor
16+
* Deprecate setting the `$alwaysAuthenticate` argument to `true` and not setting the
17+
`$exceptionOnNoToken` argument to `false` of `AuthorizationChecker`
1718
* Deprecate methods `TokenInterface::isAuthenticated()` and `setAuthenticated`,
1819
tokens will always be considered authenticated in 6.0
1920

Exception/AuthenticationExpiredException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Security\Core\Exception;
1313

1414
/**
15-
* AuthenticationExpiredException is thrown when an authenticated token becomes un-authenticated between requests.
15+
* AuthenticationExpiredException is thrown when an authentication token becomes un-authenticated between requests.
1616
*
1717
* In practice, this is due to the User changing between requests (e.g. password changes),
1818
* causes the token to become un-authenticated.

Resources/translations/security.id.xlf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,19 @@
6464
</trans-unit>
6565
<trans-unit id="17">
6666
<source>Too many failed login attempts, please try again later.</source>
67-
<target>Terlalu banyak percobaan login yang salah, Silahkan coba lagi nanti.</target>
67+
<target>Terlalu banyak percobaan login yang salah, silahkan coba lagi nanti.</target>
6868
</trans-unit>
6969
<trans-unit id="18">
7070
<source>Invalid or expired login link.</source>
71-
<target>Link login salah atau sudah kadaluwarsa.</target>
71+
<target>Link login salah atau sudah kedaluwarsa.</target>
72+
</trans-unit>
73+
<trans-unit id="19">
74+
<source>Too many failed login attempts, please try again in %minutes% minute.</source>
75+
<target>Terlalu banyak percobaan login yang salah, silahkan coba lagi dalam %minutes% menit.</target>
76+
</trans-unit>
77+
<trans-unit id="20">
78+
<source>Too many failed login attempts, please try again in %minutes% minutes.</source>
79+
<target>Terlalu banyak percobaan login yang salah, silahkan coba lagi dalam %minutes% menit.</target>
7280
</trans-unit>
7381
</body>
7482
</file>

Tests/Authorization/AuthorizationCheckerTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ class AuthorizationCheckerTest extends TestCase
2929

3030
protected function setUp(): void
3131
{
32-
$this->authenticationManager = $this->createMock(AuthenticationManagerInterface::class);
3332
$this->accessDecisionManager = $this->createMock(AccessDecisionManagerInterface::class);
3433
$this->tokenStorage = new TokenStorage();
3534

3635
$this->authorizationChecker = new AuthorizationChecker(
3736
$this->tokenStorage,
38-
$this->authenticationManager,
3937
$this->accessDecisionManager,
4038
false,
4139
false
@@ -52,7 +50,9 @@ public function testVoteAuthenticatesTokenIfNecessary()
5250

5351
$newToken = new UsernamePasswordToken('username', 'password', 'provider');
5452

55-
$this->authenticationManager
53+
$authenticationManager = $this->createMock(AuthenticationManagerInterface::class);
54+
$this->authorizationChecker = new AuthorizationChecker($this->tokenStorage, $authenticationManager, $this->accessDecisionManager, false, false);
55+
$authenticationManager
5656
->expects($this->once())
5757
->method('authenticate')
5858
->with($this->equalTo($token))
@@ -81,11 +81,7 @@ public function testVoteAuthenticatesTokenIfNecessary()
8181
*/
8282
public function testLegacyVoteWithoutAuthenticationToken()
8383
{
84-
$authorizationChecker = new AuthorizationChecker(
85-
$this->tokenStorage,
86-
$this->authenticationManager,
87-
$this->accessDecisionManager
88-
);
84+
$authorizationChecker = new AuthorizationChecker($this->tokenStorage, $this->accessDecisionManager);
8985

9086
$this->expectException(AuthenticationCredentialsNotFoundException::class);
9187

@@ -94,7 +90,7 @@ public function testLegacyVoteWithoutAuthenticationToken()
9490

9591
public function testVoteWithoutAuthenticationToken()
9692
{
97-
$authorizationChecker = new AuthorizationChecker($this->tokenStorage, $this->authenticationManager, $this->accessDecisionManager, false, false);
93+
$authorizationChecker = new AuthorizationChecker($this->tokenStorage, $this->accessDecisionManager, false, false);
9894

9995
$this->accessDecisionManager
10096
->expects($this->once())

Tests/Authorization/ExpressionLanguageTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Security\Core\Tests\Authorization;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1615
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver;
1716
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
1817
use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken;
@@ -37,7 +36,7 @@ public function testIsAuthenticated($token, $expression, $result)
3736
$tokenStorage = new TokenStorage();
3837
$tokenStorage->setToken($token);
3938
$accessDecisionManager = new AccessDecisionManager([new RoleVoter(), new AuthenticatedVoter($trustResolver)]);
40-
$authChecker = new AuthorizationChecker($tokenStorage, $this->createMock(AuthenticationManagerInterface::class), $accessDecisionManager, false, false);
39+
$authChecker = new AuthorizationChecker($tokenStorage, $accessDecisionManager, false, false);
4140

4241
$context = [];
4342
$context['auth_checker'] = $authChecker;

0 commit comments

Comments
 (0)