8000 Fixes after testing in Demo application · symfony/symfony@0a7fc78 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a7fc78

Browse files
committed
Fixes after testing in Demo application
1 parent 68f0c2a commit 0a7fc78

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/Symfony/Bundle/SecurityBundle/Resources/config/authenticators.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
class="Symfony\Component\Security\Core\Authentication\Authenticator\AnonymousAuthenticator"
4343
abstract="true">
4444
<argument /> <!-- secret -->
45+
<argument type="service" id="security.token_storage" />
4546
</service>
4647
</services>
4748
</container>

src/Symfony/Component/Security/Core/Authentication/Authenticator/AnonymousAuthenticator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpFoundation\Request;
1515
use Symfony\Component\HttpFoundation\Response;
1616
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
17+
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1718
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1819
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1920
use Symfony\Component\Security\Core\User\User;
@@ -25,15 +26,18 @@
2526
class AnonymousAuthenticator implements AuthenticatorInterface
2627
{
2728
private $secret;
29+
private $tokenStorage;
2830

29-
public function __construct(string $secret)
31+
public function __construct(string $secret, TokenStorageInterface $tokenStorage)
3032
{
3133
$this->secret = $secret;
34+
$this->tokenStorage = $tokenStorage;
3235
}
3336

3437
public function supports(Request $request): ?bool
3538
{
36-
return true;
39+
// do not overwrite already stored tokens (i.e. from the session)
40+
return null === $this->tokenStorage->getToken();
3741
}
3842

3943
public function getCredentials(Request $request)

src/Symfony/Component/Security/Core/Authentication/GuardAuthenticationManager.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ public function authenticate(TokenInterface $token)
8686
$this->handleFailure($exception, $token);
8787
}
8888

89-
if (true === $this->eraseCredentials) {
90-
$result->eraseCredentials();
91-
}
89+
if (null !== $result) {
90+
if (true === $this->eraseCredentials) {
91+
$result->eraseCredentials();
92+
}
9293

93-
if (null !== $this->eventDispatcher) {
94-
$this->eventDispatcher->dispatch(new AuthenticationSuccessEvent($result), AuthenticationEvents::AUTHENTICATION_SUCCESS);
94+
if (null !== $this->eventDispatcher) {
95+
$this->eventDispatcher->dispatch(new AuthenticationSuccessEvent($result), AuthenticationEvents::AUTHENTICATION_SUCCESS);
96+
}
9597
}
9698

9799
return $result;

src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticatorListenerTrait.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ private function triggerRememberMe($guardAuthenticator, Request $request, TokenI
150150
throw new \UnexpectedValueException('Invalid guard authenticator passed to '.__METHOD__.'. Expected AuthenticatorInterface of either Security Core or Security Guard.');
151151
}
152152

153+
// @todo implement remember me functionality
154+
if (!isset($this->rememberMeServices)) {
155+
return;
156+
}
157+
153158
if (null === $this->rememberMeServices) {
154159
if (null !== $this->logger) {
155160
$this->logger->debug('Remember me skipped: it is not configured for the firewall.', ['authenticator' => \get_class($guardAuthenticator)]);

0 commit comments

Comments
 (0)
0