1 | <?php |
||
14 | class LegacyAuthenticator extends AbstractGuardAuthenticator |
||
15 | { |
||
16 | /** |
||
17 | * Called on every request. Return whatever credentials you want, |
||
18 | * or null to stop authentication. |
||
19 | * |
||
20 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
21 | * |
||
22 | * @return array |
||
23 | */ |
||
24 | public function getCredentials(Request $request) |
||
38 | |||
39 | /** |
||
40 | * @param mixed $credentials |
||
41 | * @param \Symfony\Component\Security\Core\User\UserProviderInterface $userProvider |
||
42 | * |
||
43 | * @return \AppBundle\Legacy\User\LegacyUser|null |
||
44 | */ |
||
45 | public function getUser($credentials, UserProviderInterface $userProvider) |
||
53 | |||
54 | /** |
||
55 | * @param mixed $credentials |
||
56 | * @param \Symfony\Component\Security\Core\User\UserInterface $user |
||
57 | * |
||
58 | * @return bool |
||
59 | */ |
||
60 | public function checkCredentials($credentials, UserInterface $user) |
||
68 | |||
69 | /** |
||
70 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
71 | * @param \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token |
||
72 | * @param string $providerKey |
||
73 | * |
||
74 | * @return null |
||
75 | */ |
||
76 | public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) |
||
81 | |||
82 | /** |
||
83 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
84 | * @param \Symfony\Component\Security\Core\Exception\AuthenticationException $exception |
||
85 | * |
||
86 | * @return null |
||
87 | */ |
||
88 | public function onAuthenticationFailure(Request $request, AuthenticationException $exception) |
||
92 | |||
93 | /** |
||
94 | * Called when authentication is needed, but it's not sent |
||
95 | * |
||
96 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
97 | * @param \Symfony\Component\Security\Core\Exception\AuthenticationException|null $authException |
||
98 | * |
||
99 | * @return \Symfony\Component\HttpFoundation\RedirectResponse |
||
100 | */ |
||
101 | public function start(Request $request, AuthenticationException $authException = null) |
||
108 | |||
109 | /** |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function supportsRememberMe() |
||
116 | } |
||
117 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: