-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestAuthenticator.php
More file actions
46 lines (39 loc) · 1.57 KB
/
Copy pathTestAuthenticator.php
File metadata and controls
46 lines (39 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace ItkDev\OpenIdConnectBundle\Tests\Security;
use ItkDev\OpenIdConnectBundle\Security\OpenIdLoginAuthenticator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
class TestAuthenticator extends OpenIdLoginAuthenticator
{
/**
* Claims returned by the last validateClaims() call, exposed so tests
* can assert on the full claims array (validateClaims is protected).
*
* @var array<string, string>
*/
public array $lastClaims = [];
public function authenticate(Request $request): Passport
{
$claims = $this->validateClaims($request);
$this->lastClaims = $claims;
return new SelfValidatingPassport(
new UserBadge(
$claims['email'],
fn (string $email) => new TestUser($email)
)
);
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
return null;
}
public function start(Request $request, ?AuthenticationException $authException = null): Response
{
throw new \LogicException('Test stub: start() is not implemented for this fixture.');
}
}