|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the TheAlternativeZurich/events project. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Florian Moser <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace App\Security; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse; |
|
15
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
16
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
17
|
|
|
use Symfony\Component\Intl\Exception\MethodNotImplementedException; |
|
18
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
|
19
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
|
20
|
|
|
use Symfony\Component\Security\Core\Exception\AuthenticationException; |
|
21
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
|
22
|
|
|
use Symfony\Component\Security\Core\User\UserProviderInterface; |
|
23
|
|
|
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; |
|
24
|
|
|
|
|
25
|
|
|
class TokenAuthenticator extends AbstractGuardAuthenticator |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var UrlGeneratorInterface |
|
29
|
|
|
*/ |
|
30
|
|
|
private $generator; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* TokenAuthenticator constructor. |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct(UrlGeneratorInterface $generator) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->generator = $generator; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function supports(Request $request): ?bool |
|
41
|
|
|
{ |
|
42
|
|
|
return false; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response |
|
46
|
|
|
{ |
|
47
|
|
|
throw new MethodNotImplementedException(__FUNCTION__); |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response |
|
51
|
|
|
{ |
|
52
|
|
|
throw new MethodNotImplementedException(__FUNCTION__); |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function start(Request $request, AuthenticationException $authException = null) |
|
56
|
|
|
{ |
|
57
|
|
|
return new RedirectResponse($this->generator->generate('authenticate')); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function getCredentials(Request $request) |
|
61
|
|
|
{ |
|
62
|
|
|
throw new MethodNotImplementedException(__FUNCTION__); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function getUser($credentials, UserProviderInterface $userProvider) |
|
66
|
|
|
{ |
|
67
|
|
|
throw new MethodNotImplementedException(__FUNCTION__); |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function checkCredentials($credentials, UserInterface $user) |
|
71
|
|
|
{ |
|
72
|
|
|
throw new MethodNotImplementedException(__FUNCTION__); |
|
|
|
|
|
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function supportsRememberMe() |
|
76
|
|
|
{ |
|
77
|
|
|
return true; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|