8000 feature #61011 [Security] Remove deprecated `RememberMeToken::getSecr… · symfony/security-core@5c1b149 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5c1b149

Browse files
feature #61011 [Security] Remove deprecated RememberMeToken::getSecret() (ktherage)
This PR was merged into the 8.0 branch. Discussion ---------- [Security] Remove deprecated `RememberMeToken::getSecret()` | Q | A | ------------- | --- | Branch? | 8.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | -- | License | MIT Commits ------- 2fea866a374 [Security] Remove deprecated `RememberMeToken::getSecret()`
2 parents 6d3c210 + 4e32ac1 commit 5c1b149

File tree

4 files changed

+3
-32
lines changed

4 files changed

+3
-32
lines changed

Authentication/Token/RememberMeToken.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
*/
2222
class RememberMeToken extends AbstractToken
2323
{
24-
private ?string $secret = null;
25-
2624
/**
2725
* @throws \InvalidArg 8000 umentException
2826
*/
@@ -32,11 +30,6 @@ public function __construct(
3230
) {
3331
parent::__construct($user->getRoles());
3432

35-
if (\func_num_args() > 2) {
36-
trigger_deprecation('symfony/security-core', '7.2', 'The "$secret" argument of "%s()" is deprecated.', __METHOD__);
37-
$this->secret = func_get_arg(2);
38-
}
39-
4033
if (!$firewallName) {
4134
throw new InvalidArgumentException('$firewallName must not be empty.');
4235
}
@@ -49,25 +42,14 @@ public function getFirewallName(): string
4942
return $this->firewallName;
5043
}
5144

52-
/**
53-
* @deprecated since Symfony 7.2
54-
*/
55-
public function getSecret(): string
56-
{
57-
trigger_deprecation('symfony/security-core', '7.2', 'The "%s()" method is deprecated.', __METHOD__);
58-
59-
return $this->secret ??= base64_encode(random_bytes(8));
60-
}
61-
6245
public function __serialize(): array
6346
{
64-
// $this->firewallName should be kept at index 1 for compatibility with payloads generated before Symfony 8
65-
return [$this->secret, $this->firewallName, parent::__serialize()];
47+
return [null, $this->firewallName, parent::__serialize()];
6648
}
6749

6850
public function __unserialize(array $data): void
6951
{
70-
[$this->secret, $this->firewallName, $parentData] = $data;
52+
[, $this->firewallName, $parentData] = $data;
7153
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
7254
parent::__unserialize($parentData);
7355
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
8.0
55
---
66

7+
* Remove `RememberMeToken::getSecret()`
78
* Remove `UserInterface::eraseCredentials()` and `TokenInterface::eraseCredentials()`,
89
erase credentials e.g. using `__serialize()` instead
910

Tests/Authentication/Token/RememberMeTokenTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ public function testConstructor()
2727
$this->assertSame($user, $token->getUser());
2828
}
2929

30-
/**
31-
* @group legacy
32-
*/
33-
public function testSecret()
34-
{
35-
$user = $this->getUser();
36-
$token = new RememberMeToken($user, 'fookey', 'foo');
37-
38-
$this->assertEquals('foo', $token->getSecret());
39-
}
40-
4130
protected function getUser($roles = ['ROLE_FOO'])
4231
{
4332
$user = $this->createMock(UserInterface::class);

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
],
1818
"require": {
1919
"php": ">=8.4",
20-
"symfony/deprecation-contracts": "^2.5|^3",
2120
"symfony/event-dispatcher-contracts": "^2.5|^3",
2221
"symfony/password-hasher": "^7.4|^8.0",
2322
"symfony/service-contracts": "^2.5|^3"

0 commit comments

Comments
 (0)
0