Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb7f466

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Security] Deprecate legacy remember me services [Form] Fix return types in form builder
2 parents 98cee18 + b1115f9 commit eb7f466

17 files changed

+65
-8
lines changed

UPGRADE-5.4.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Security
7070
* Deprecate `RetryAuthenticationEntryPoint`, this code is now inlined in the `ChannelListener`
7171
* Deprecate `FormAuthenticationEntryPoint` and `BasicAuthenticationEntryPoint`, in the new system the `FormLoginAuthenticator`
7272
and `HttpBasicAuthenticator` should be used instead
73+
* Deprecate `AbstractRememberMeServices`, `PersistentTokenBasedRememberMeServices`, `RememberMeServicesInterface`,
74+
`TokenBasedRememberMeServices`, use the remember me handler alternatives instead
7375
* Deprecate `AnonymousToken`, as the related authenticator was deprecated in 5.3
7476
* Deprecate `Token::getCredentials()`, tokens should no longer contain credentials (as they represent authenticated sessions)
7577
* Deprecate not returning an `UserInterface` from `Token::getUser()`

UPGRADE-6.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ Security
217217
* Remove the `$authenticationEntryPoint` argument of `ChannelListener`
218218
* Remove `RetryAuthenticationEntryPoint`, this code was inlined in the `ChannelListener`
219219
* Remove `FormAuthenticationEntryPoint` and `BasicAuthenticationEntryPoint`, the `FormLoginAuthenticator` and `HttpBasicAuthenticator` should be used instead.
220+
* Remove `AbstractRememberMeServices`, `PersistentTokenBasedRememberMeServices`, `RememberMeServicesInterface`,
221+
`TokenBasedRememberMeServices`, use the remember me handler alternatives instead
220222
* Remove `AnonymousToken`
221223
* Remove `Token::getCredentials()`, tokens should no longer contain credentials (as they represent authenticated sessions)
222224
* Restrict the return type of `Token::getUser()` to `UserInterface` (removing `string|\Stringable`)

src/Symfony/Component/Form/ButtonBuilder.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,12 @@ public function setIsEmptyCallback(?callable $isEmptyCallback): static
412412

413413
/**
414414
* Unsupported method.
415+
*
416+
* @throws BadMethodCallException
415417
*/
416418
public function getEventDispatcher()
417419
{
418-
return null;
420+
throw new BadMethodCallException('Buttons do not support event dispatching.');
419421
}
420422

421423
/**
@@ -606,26 +608,32 @@ public function getFormFactory()
606608

607609
/**
608610
* Unsupported method.
611+
*
612+
* @throws BadMethodCallException
609613
*/
610614
public function getAction()
611615
{
612-
return null;
616+
throw new BadMethodCallException('Buttons do not support actions.');
613617
}
614618

615619
/**
616620
* Unsupported method.
621+
*
622+
* @throws BadMethodCallException
617623
*/
618624
public function getMethod()
619625
{
620-
return null;
626+
throw new BadMethodCallException('Buttons do not support methods.');
621627
}
622628

623629
/**
624630
* Unsupported method.
631+
*
632+
* @throws BadMethodCallException
625633
*/
626634
public function getRequestHandler()
627635
{
628-
return null;
636+
throw new BadMethodCallException('Buttons do not support request handlers.');
629637
}
630638

631639
/**

src/Symfony/Component/Form/FormConfigBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
5454
private ?string $dataClass;
5555
private bool $dataLocked = false;
5656
private ?FormFactoryInterface $formFactory = null;
57-
private ?string $action = null;
57+
private string $action;
5858
private string $method = 'POST';
5959
private RequestHandlerInterface $requestHandler;
6060
private bool $autoInitialize = false;
@@ -353,6 +353,10 @@ public function getDataLocked()
353353
*/
354354
public function getFormFactory()
355355
{
356+
if (!isset($this->formFactory)) {
357+
throw new BadMethodCallException('The form factory must be set before retrieving it.');
358+
}
359+
356360
return $this->formFactory;
357361
}
358362

src/Symfony/Component/Security/Http/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ CHANGELOG
1515
* Deprecate `RetryAuthenticationEntryPoint`, this code is now inlined in the `ChannelListener`
1616
* Deprecate `FormAuthenticationEntryPoint` and `BasicAuthenticationEntryPoint`, in the new system the `FormLoginAuthenticator`
1717
and `HttpBasicAuthenticator` should be used instead
18+
* Deprecate `AbstractRememberMeServices`, `PersistentTokenBasedRememberMeServices`, `RememberMeServicesInterface`,
19+
`TokenBasedRememberMeServices`, use the remember me handler alternatives instead
1820
* Deprecate the `$authManager` argument of `AccessListener`
1921
* Deprecate not setting the `$exceptionOnNoToken` argument of `AccessListener` to `false`
2022
* Deprecate `DeauthenticatedEvent`, use `TokenDeauthenticatedEvent` instead

src/Symfony/Component/Security/Http/EventListener/RememberMeLogoutListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
use Symfony\Component\Security\Http\Event\LogoutEvent;
1717
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
1818

19+
trigger_deprecation('symfony/security-http', '5.4', 'The "%s" class is deprecated.', RememberMeLogoutListener::class);
20+
1921
/**
2022
* @author Wouter de Jong <[email protected]>
2123
*
2224
* @final
25+
*
26+
* @deprecated since Symfony 5.4
2327
*/
2428
class RememberMeLogoutListener implements EventSubscriberInterface
2529
{

src/Symfony/Component/Security/Http/Firewall/ContextListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,13 @@ public static function handleUnserializeCallback(string $class)
392392
throw new \ErrorException('Class not found: '.$class, 0x37313bc);
393393
}
394394

395+
/**
396+
* @deprecated since Symfony 5.4
397+
*/
395398
public function setRememberMeServices(RememberMeServicesInterface $rememberMeServices)
396399
{
400+
trigger_deprecation('symfony/security-http', '5.4', 'Method "%s()" is deprecated, use the new remember me handlers instead.', __METHOD__);
401+
397402
$this->rememberMeServices = $rememberMeServices;
398403
}
399404
}

src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@
2525
use Symfony\Component\Security\Core\User\UserProviderInterface;
2626
use Symfony\Component\Security\Http\ParameterBagUtils;
2727

28+
trigger_deprecation('symfony/security-http', '5.4', 'The "%s" class is deprecated, use "%s" instead.', AbstractRememberMeServices::class, AbstractRememberMeHandler::class);
29+
2830
/**
2931
* Base class implementing the RememberMeServicesInterface.
3032
*
3133
* @author Johannes M. Schmitt <[email protected]>
34+
*
35+
* @deprecated since Symfony 5.4, use {@see AbstractRememberMeHandler} instead
3236
*/
3337
abstract class AbstractRememberMeServices implements RememberMeServicesInterface
3438
{

src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2222
use Symfony\Component\Security\Core\Exception\CookieTheftException;
2323

24+
trigger_deprecation('symfony/security-http', '5.4', 'The "%s" class is deprecated, use "%s" instead.', PersistentTokenBasedRememberMeServices::class, PersistentRememberMeHandler::class);
25+
2426
/**
2527
* Concrete implementation of the RememberMeServicesInterface which needs
2628
* an implementation of TokenProviderInterface for providing remember-me
2729
* capabilities.
2830
*
2931
* @author Johannes M. Schmitt <[email protected]>
32+
*
33+
* @deprecated since Symfony 5.4, use {@see PersistentRememberMeHandler} instead
3034
*/
3135
class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices
3236
{

src/Symfony/Component/Security/Http/RememberMe/RememberMeServicesInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\HttpFoundation\Response;
1616
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1717

18+
trigger_deprecation('symfony/security-http', '5.4', 'The "%s" interface is deprecated, use "%s" instead.', RememberMeServicesInterface::class, RememberMeHandlerInterface::class);
19+
1820
/**
1921
* Interface that needs to be implemented by classes which provide remember-me
2022
* capabilities.
@@ -24,6 +26,8 @@
2426
* - PersistentTokenBasedRememberMeServices (requires a TokenProvider)
2527
*
2628
* @author Johannes M. Schmitt <[email protected]>
29+
*
30+
* @deprecated since Symfony 5.4, use {@see RememberMeHandlerInterface} instead
2731
*/
2832
interface RememberMeServicesInterface
2933
{

src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@
1919
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
2020
use Symfony\Component\Security\Core\User\UserInterface;
2121

22+
trigger_deprecation('symfony/security-http', '5.4', 'The "%s" class is deprecated, use "%s" instead.', TokenBasedRememberMeServices::class, SignatureRememberMeHandler::class);
23+
2224
/**
2325
* Concrete implementation of the RememberMeServicesInterface providing
2426
* remember-me capabilities without requiring a TokenProvider.
2527
*
2628
* @author Johannes M. Schmitt <[email protected]>
29+
*
30+
* @deprecated since Symfony 5.4, use {@see SignatureRememberMeHandler} instead
2731
*/
2832
class TokenBasedRememberMeServices extends AbstractRememberMeServices
2933
{

src/Symfony/Component/Security/Http/Tests/EventListener/RememberMeLogoutListenerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use Symfony\Component\Security\Http\EventListener\RememberMeLogoutListener;
1818
use Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices;
1919

20+
/**
21+
* @group legacy
22+
*/
2023
class RememberMeLogoutListenerTest extends TestCase
2124
{
2225
public function testOnLogoutDoesNothingIfNoToken()

src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ public function testIfTokenIsNotDeauthenticated()
242242
$this->assertSame($goodRefreshedUser, $tokenStorage->getToken()->getUser());
243243
}
244244

245+
/**
246+
* @group legacy
247+
*/
245248
public function testRememberMeGetsCanceledIfTokenIsDeauthenticated()
246249
{
247250
$tokenStorage = new TokenStorage();

src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
use Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices;
2222
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
2323

24+
/**
25+
* @group legacy
26+
*/
2427
class AbstractRememberMeServicesTest extends TestCase
2528
{
2629
public function testGetRememberMeParameter()

src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
use Symfony\Component\Security\Http\RememberMe\PersistentTokenBasedRememberMeServices;
2929
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
3030

31+
/**
32+
* @group legacy
33+
*/
3134
class PersistentTokenBasedRememberMeServicesTest extends TestCase
3235
{
3336
public static function setUpBeforeClass(): void

src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Component\HttpKernel\Event\ResponseEvent;
2020
use Symfony\Component\HttpKernel\HttpKernelInterface;
2121
use Symfony\Component\HttpKernel\KernelEvents;
22-
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
2322
use Symfony\Component\Security\Http\RememberMe\ResponseListener;
2423

2524
class ResponseListenerTest extends TestCase
@@ -29,7 +28,7 @@ public function testRememberMeCookieIsSentWithResponse()
2928
$cookie = new Cookie('rememberme', null, 0, '/', null, false, true, false, null);
3029

3130
$request = $this->getRequest([
32-
RememberMeServicesInterface::COOKIE_ATTR_NAME => $cookie,
31+
ResponseListener::COOKIE_ATTR_NAME => $cookie,
3332
]);
3433

3534
$response = $this->getResponse();
@@ -44,7 +43,7 @@ public function testRememberMeCookieIsNotSendWithResponseForSubRequests()
4443
$cookie = new Cookie('rememberme', null, 0, '/', null, false, true, false, null);
4544

4645
$request = $this->getRequest([
47-
RememberMeServicesInterface::COOKIE_ATTR_NAME => $cookie,
46+
ResponseListener::COOKIE_ATTR_NAME => $cookie,
4847
]);
4948

5049
$response = $this->getResponse();

src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
2424
use Symfony\Component\Security\Http\RememberMe\TokenBasedRememberMeServices;
2525

26+
/**
27+
* @group legacy
28+
*/
2629
class TokenBasedRememberMeServicesTest extends TestCase
2730
{
2831
public function testAutoLoginReturnsNullWhenNoCookie()

0 commit comments

Comments
 (0)