You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: UPGRADE-5.3.md
+82Lines changed: 82 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,88 @@ Routing
80
80
Security
81
81
--------
82
82
83
+
* Deprecate `UserInterface::getPassword()`
84
+
If your `getPassword()` method does not return `null` (i.e. you are using password-based authentication),
85
+
you should implement `PasswordAuthenticatedUserInterface`.
86
+
87
+
Before:
88
+
```php
89
+
use Symfony\Component\Security\Core\User\UserInterface;
90
+
91
+
class User implements UserInterface
92
+
{
93
+
// ...
94
+
95
+
public function getPassword()
96
+
{
97
+
return $this->password;
98
+
}
99
+
}
100
+
```
101
+
102
+
After:
103
+
```php
104
+
use Symfony\Component\Security\Core\User\UserInterface;
105
+
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
106
+
107
+
class User implements UserInterface, PasswordAuthenticatedUserInterface
108
+
{
109
+
// ...
110
+
111
+
public function getPassword(): ?string
112
+
{
113
+
return $this->password;
114
+
}
115
+
}
116
+
```
117
+
118
+
* Deprecate `UserInterface::getSalt()`
119
+
If your `getSalt()` method does not return `null` (i.e. you are using password-based authentication with an old password hash algorithm that requires user-provided salts),
use Symfony\Component\Security\Core\User\UserInterface;
125
+
126
+
class User implements UserInterface
127
+
{
128
+
// ...
129
+
130
+
public function getPassword()
131
+
{
132
+
return $this->password;
133
+
}
134
+
135
+
public function getSalt()
136
+
{
137
+
return $this->salt;
138
+
}
139
+
}
140
+
```
141
+
142
+
After:
143
+
```php
144
+
use Symfony\Component\Security\Core\User\UserInterface;
145
+
use Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface;
146
+
147
+
class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
148
+
{
149
+
// ...
150
+
151
+
public function getPassword(): ?string
152
+
{
153
+
return $this->password;
154
+
}
155
+
156
+
public function getSalt(): ?string
157
+
{
158
+
return $this->salt;
159
+
}
160
+
}
161
+
```
162
+
163
+
* Deprecate calling `PasswordUpgraderInterface::upgradePassword()` with a `UserInterface` instance that does not implement `PasswordAuthenticatedUserInterface`
164
+
* Deprecate calling methods `hashPassword()`, `isPasswordValid()` and `needsRehash()` on `UserPasswordHasherInterface` with a `UserInterface` instance that does not implement `PasswordAuthenticatedUserInterface`
83
165
* Deprecate all classes in the `Core\Encoder\` sub-namespace, use the `PasswordHasher` component instead
84
166
* Deprecated voters that do not return a valid decision when calling the `vote` method
Copy file name to clipboardExpand all lines: UPGRADE-6.0.md
+84Lines changed: 84 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -172,6 +172,90 @@ Routing
172
172
Security
173
173
--------
174
174
175
+
* Remove `UserInterface::getPassword()`
176
+
If your `getPassword()` method does not return `null` (i.e. you are using password-based authentication),
177
+
you should implement `PasswordAuthenticatedUserInterface`.
178
+
179
+
Before:
180
+
```php
181
+
use Symfony\Component\Security\Core\User\UserInterface;
182
+
183
+
class User implements UserInterface
184
+
{
185
+
// ...
186
+
187
+
public function getPassword()
188
+
{
189
+
return $this->password;
190
+
}
191
+
}
192
+
```
193
+
194
+
After:
195
+
```php
196
+
use Symfony\Component\Security\Core\User\UserInterface;
197
+
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
198
+
199
+
class User implements UserInterface, PasswordAuthenticatedUserInterface
200
+
{
201
+
// ...
202
+
203
+
public function getPassword(): ?string
204
+
{
205
+
return $this->password;
206
+
}
207
+
}
208
+
```
209
+
210
+
* Remove `UserInterface::getSalt()`
211
+
If your `getSalt()` method does not return `null` (i.e. you are using password-based authentication with an old password hash algorithm that requires user-provided salts),
use Symfony\Component\Security\Core\User\UserInterface;
217
+
218
+
class User implements UserInterface
219
+
{
220
+
// ...
221
+
222
+
public function getPassword()
223
+
{
224
+
return $this->password;
225
+
}
226
+
227
+
public function getSalt()
228
+
{
229
+
return $this->salt;
230
+
}
231
+
}
232
+
```
233
+
234
+
After:
235
+
```php
236
+
use Symfony\Component\Security\Core\User\UserInterface;
237
+
use Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface;
238
+
239
+
class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
240
+
{
241
+
// ...
242
+
243
+
public function getPassword(): ?string
244
+
{
245
+
return $this->password;
246
+
}
247
+
248
+
public function getSalt(): ?string
249
+
{
250
+
return $this->salt;
251
+
}
252
+
}
253
+
```
254
+
255
+
* Calling `PasswordUpgraderInterface::upgradePassword()` with a `UserInterface` instance that
256
+
does not implement `PasswordAuthenticatedUserInterface` now throws a `\TypeError`.
257
+
* Calling methods `hashPassword()`, `isPasswordValid()` and `needsRehash()` on `UserPasswordHasherInterface`
258
+
with a `UserInterface` instance that does not implement `PasswordAuthenticatedUserInterface` now throws a `\TypeError`
175
259
* Drop all classes in the `Core\Encoder\` sub-namespace, use the `PasswordHasher` component instead
176
260
* Drop support for `SessionInterface $session` as constructor argument of `SessionTokenStorage`, inject a `\Symfony\Component\HttpFoundation\RequestStack $requestStack` instead
177
261
* Drop support for `session` provided by the ServiceLocator injected in `UsageTrackingTokenStorage`, provide a `request_stack` service instead
if (!$userinstanceof PasswordAuthenticatedUserInterface) {
125
+
trigger_deprecation('symfony/doctrine-bridge', '5.3', 'The "%s::upgradePassword()" method expects an instance of "%s" as first argument, the "%s" class should implement it.', PasswordUpgraderInterface::class, PasswordAuthenticatedUserInterface::class, get_debug_type($user));
126
+
}
127
+
121
128
$class = $this->getClass();
122
129
if (!$userinstanceof$class) {
123
130
thrownewUnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
@@ -664,6 +665,9 @@ private function createEncoders(array $encoders, ContainerBuilder $container)
664
665
{
665
666
$encoderMap = [];
666
667
foreach ($encodersas$class => $encoder) {
668
+
if (class_exists($class) && !is_a($class, PasswordAuthenticatedUserInterface::class, true)) {
669
+
trigger_deprecation('symfony/security-bundle', '5.3', 'Configuring an encoder for a user class that does not implement "%s" is deprecated, class "%s" should implement it.', PasswordAuthenticatedUserInterface::class, $class);
@@ -775,6 +779,10 @@ private function createHashers(array $hashers, ContainerBuilder $container)
775
779
{
776
780
$hasherMap = [];
777
781
foreach ($hashersas$class => $hasher) {
782
+
// @deprecated since Symfony 5.3, remove the check in 6.0
783
+
if (class_exists($class) && !is_a($class, PasswordAuthenticatedUserInterface::class, true)) {
784
+
trigger_deprecation('symfony/security-bundle', '5.3', 'Configuring a password hasher for a user class that does not implement "%s" is deprecated, class "%s" should implement it.', PasswordAuthenticatedUserInterface::class, $class);
@@ -68,6 +69,11 @@ public function onCheckPassport(CheckPassportEvent $event)
68
69
thrownewBadCredentialsException('The presented password cannot be empty.');
69
70
}
70
71
72
+
$user = $passport->getUser();
73
+
if (!$userinstanceof PasswordAuthenticatedUserInterface) {
74
+
trigger_deprecation('symfony/ldap', '5.3', 'Not implementing the "%s" interface in class "%s" while using password-based authenticators is deprecated.', PasswordAuthenticatedUserInterface::class, get_debug_type($user));
0 commit comments