Skip to content

Commit 161b133

Browse files
committed
Add RememberMe Badge to LoginLinkAuthenticator
1 parent 40023b8 commit 161b133

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Authenticator/LoginLinkAuthenticator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1818
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
1919
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
20+
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
2021
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
2122
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
2223
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
@@ -69,7 +70,7 @@ public function authenticate(Request $request): PassportInterface
6970

7071
return $user;
7172
}),
72-
[]
73+
[new RememberMeBadge()]
7374
);
7475
}
7576

Tests/Authenticator/LoginLinkAuthenticatorTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
1818
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
1919
use Symfony\Component\Security\Http\Authenticator\LoginLinkAuthenticator;
20+
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
2021
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
2122
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
2223
use Symfony\Component\Security\Http\HttpUtils;
@@ -105,6 +106,17 @@ public function testMissingUser()
105106
$this->authenticator->authenticate($request);
106107
}
107108

109+
public function testPassportBadges()
110+
{
111+
$this->setUpAuthenticator();
112+
113+
$request = Request::create('/login/link/check?stuff=1&user=weaverryan');
114+
115+
$passport = $this->authenticator->authenticate($request);
116+
117+
$this->assertTrue($passport->hasBadge(RememberMeBadge::class));
118+
}
119+
108120
private function setUpAuthenticator(array $options = [])
109121
{
110122
$this->authenticator = new LoginLinkAuthenticator($this->loginLinkHandler, new HttpUtils(), $this->successHandler, $this->failureHandler, $options);

0 commit comments

Comments
 (0)