8000 feature #40838 [SecurityBundle] Deprecate public services to private … · symfony/symfony@1a87c72 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a87c72

Browse files
committed
feature #40838 [SecurityBundle] Deprecate public services to private (fancyweb)
This PR was merged into the 5.3-dev branch. Discussion ---------- [SecurityBundle] Deprecate public services to private | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | - | License | MIT | Doc PR | - Follow up of #36691 on the SecurityBundle Commits ------- 56be86a [SecurityBundle] Deprecate public services to private
2 parents d8e4af2 + 56be86a commit 1a87c72

File tree

8 files changed

+36
-5
lines changed

8 files changed

+36
-5
lines changed

UPGRADE-5.3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ SecurityBundle
214214
use `security.password_hasher_factory` and `Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface` instead
215215
* Deprecate the `security.user_password_encoder.generic` service, the `security.password_encoder` and the `Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface` aliases,
216216
use `security.user_password_hasher`, `security.password_hasher` and `Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface` instead
217+
* Deprecate the public `security.authorization_checker` and `security.token_storage` services to private
217218

218219
Serializer
219220
----------

UPGRADE-6.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ SecurityBundle
300300
use `security.password_hasher_factory` and `Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface` instead
301301
* Remove the `security.user_password_encoder.generic` service, the `security.password_encoder` and the `Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface` aliases,
302302
use `security.user_password_hasher`, `security.password_hasher` and `Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface` instead
303+
* The `security.authorization_checker` and `security.token_storage` services are now private
303304

304305
Serializer
305306
----------

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SecurityController.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,32 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
1313

14-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
15-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
14+
use Psr\Container\ContainerInterface;
1615
use Symfony\Component\HttpFoundation\Response;
16+
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
17+
use Symfony\Contracts\Service\ServiceSubscriberInterface;
1718

18-
class SecurityController implements ContainerAwareInterface
19+
class SecurityController implements ServiceSubscriberInterface
1920
{
20-
use ContainerAwareTrait;
21+
private $container;
22+
23+
public function __construct(ContainerInterface $container)
24+
{
25+
$this->container = $container;
26+
}
2127

2228
public function profileAction()
2329
{
2430
return new Response('Welcome '.$this->container->get('security.token_storage')->getToken()->getUserIdentifier().'!');
2531
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
public static function getSubscribedServices(): array
37+
{
38+
return [
39+
'security.token_storage' => TokenStorageInterface::class,
40+
];
41+
}
2642
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Security/config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
imports:
22
- { resource: ./../config/default.yml }
33

4+
services:
5+
Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SecurityController:
6+
public: true
7+
tags:
8+
- container.service_subscriber
9+
410
security:
511
providers:
612
main:

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ CHANGELOG
1616
use `security.password_hasher_factory` and `Symfony\Component\ 9E88 PasswordHasher\Hasher\PasswordHasherFactoryInterface` instead
1717
* Deprecate the `security.user_password_encoder.generic` service, the `security.password_encoder` and the `Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface` aliases,
1818
use `security.user_password_hasher`, `security.password_hasher` and `Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface` instead
19+
* Deprecate the public `security.authorization_checker` and `security.token_storage` services to private
1920

2021
5.2.0
2122
-----

src/Symfony/Bundle/SecurityBundle/Resources/config/security.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
service('security.access.decision_manager'),
6969
param('security.access.always_authenticate_before_granting'),
7070
])
71+
->tag('container.private', ['package' => 'symfony/security-bundle', 'version' => '5.3'])
7172
->alias(AuthorizationCheckerInterface::class, 'security.authorization_checker')
7273

7374
->set('security.token_storage', UsageTrackingTokenStorage::class)
@@ -80,6 +81,7 @@
8081
])
8182
->tag('kernel.reset', ['method' => 'disableUsageTracking'])
8283
->tag('kernel.reset', ['method' => 'setToken'])
84+
->tag('container.private', ['package' => 'symfony/security-bundle', 'version' => '5.3'])
8385
->alias(TokenStorageInterface::class, 'security.token_storage')
8486

8587
->set('security.untracked_token_storage', TokenStorage::class)

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testServiceIsFunctional()
2828
// put a token into the storage so the final calls can function
2929
$user = new InMemoryUser('foo', 'pass');
3030
$token = new UsernamePasswordToken($user, '', 'provider', ['ROLE_USER']);
31-
$container->get('security.token_storage')->setToken($token);
31+
$container->get('security.token_storage.alias')->setToken($token);
3232

3333
$security = $container->get('functional_test.security.helper');
3434
$this->assertTrue($security->isGranted('ROLE_USER'));

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ services:
77
alias: security.helper
88
public: true
99

10+
functional.test.security.token_storage:
11+
alias: security.token_storage
12+
public: true
13+
1014
security:
1115
providers:
1216
in_memory:

0 commit comments

Comments
 (0)
0