Skip to content

Commit 06f4663

Browse files
committed
[Security] Remove annoying deprecation in UsageTrackingTokenStorage
1 parent 9c2a9c8 commit 06f4663

File tree

4 files changed

+1
-14
lines changed

4 files changed

+1
-14
lines changed

UPGRADE-5.3.md

-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ Routing
106106
Security
107107
--------
108108

109-
* Deprecate using `UsageTrackingTokenStorage` with tracking enabled without a main request. Use the untracked token
110-
storage (service ID: `security.untracked_token_storage`) instead, or disable usage tracking
111-
completely using `UsageTrackingTokenStorage::disableUsageTracking()`.
112109
* [BC BREAK] Remove method `checkIfCompletelyResolved()` from `PassportInterface`, checking that passport badges are
113110
resolved is up to `AuthenticatorManager`
114111
* Deprecate class `User`, use `InMemoryUser` or your own implementation instead.

src/Symfony/Component/Security/CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ The CHANGELOG for version 5.4 and newer can be found in the security sub-package
3838
* Add `LegacyPasswordAuthenticatedUserInterface` for user classes that use user-provided salts in addition to passwords
3939
* Deprecate all classes in the `Core\Encoder\` sub-namespace, use the `PasswordHasher` component instead
4040
* Deprecate the `SessionInterface $session` constructor argument of `SessionTokenStorage`, inject a `\Symfony\Component\HttpFoundation\RequestStack $requestStack` instead
41-
* Deprecate using `UsageTrackingTokenStorage` without a main request
4241
* Deprecate the `session` service provided by the ServiceLocator injected in `UsageTrackingTokenStorage`, provide a `request_stack` service instead
4342
* Deprecate using `SessionTokenStorage` outside a request context, it will throw a `SessionNotFoundException` in Symfony 6.0
4443
* Randomize CSRF tokens to harden BREACH attacks

src/Symfony/Component/Security/Core/Authentication/Token/Storage/UsageTrackingTokenStorage.php

-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ private function shouldTrackUsage(): bool
101101
}
102102

103103
if (!$this->container->get('request_stack')->getMainRequest()) {
104-
trigger_deprecation('symfony/security-core', '5.3', 'Using "%s" (service ID: "security.token_storage") outside the request-response cycle is deprecated, use the "%s" class (service ID: "security.untracked_token_storage") instead or disable usage tracking using "disableUsageTracking()".', __CLASS__, TokenStorage::class);
105-
106104
return false;
107105
}
108106

src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/UsageTrackingTokenStorageTest.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Container\ContainerInterface;
16-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1716
use Symfony\Component\HttpFoundation\Request;
1817
use Symfony\Component\HttpFoundation\RequestStack;
1918
use Symfony\Component\HttpFoundation\Session\SessionInterface;
@@ -24,8 +23,6 @@
2423

2524
class UsageTrackingTokenStorageTest extends TestCase
2625
{
27-
use ExpectDeprecationTrait;
28-
2926
public function testGetSetToken()
3027
{
3128
$sessionAccess = 0;
@@ -69,9 +66,6 @@ public function testGetSetToken()
6966
$this->assertSame(1, $sessionAccess);
7067
}
7168

72-
/**
73-
* @group legacy
74-
*/
7569
public function testWithoutMainRequest()
7670
{
7771
$locator = new class(['request_stack' => function () {
@@ -83,7 +77,6 @@ public function testWithoutMainRequest()
8377
$trackingStorage = new UsageTrackingTokenStorage($tokenStorage, $locator);
8478
$trackingStorage->enableUsageTracking();
8579

86-
$this->expectDeprecation('Since symfony/security-core 5.3: Using "%s" (service ID: "security.token_storage") outside the request-response cycle is deprecated, use the "%s" class (service ID: "security.untracked_token_storage") instead or disable usage tracking using "disableUsageTracking()".');
87-
$trackingStorage->getToken();
80+
$this->assertNull($trackingStorage->getToken());
8881
}
8982
}

0 commit comments

Comments
 (0)