1 | <?php |
||
29 | final class SecurityAuthenticator implements |
||
30 | SimplePreAuthenticatorInterface, |
||
31 | AuthenticationFailureHandlerInterface |
||
32 | { |
||
33 | |||
34 | /** |
||
35 | * Authentication can be required to use any service |
||
36 | * @var bool, |
||
37 | */ |
||
38 | protected $securityRequired; |
||
39 | |||
40 | /** |
||
41 | * Authentication can use a test user if no user found |
||
42 | * @var bool, |
||
43 | */ |
||
44 | protected $testUsername; |
||
45 | |||
46 | /** |
||
47 | * Authentication can allow not identified users to get information |
||
48 | * @var bool, |
||
49 | */ |
||
50 | protected $allowAnonymous; |
||
51 | |||
52 | /** |
||
53 | * @var AuthenticationProvider |
||
54 | */ |
||
55 | protected $userProvider; |
||
56 | |||
57 | /** |
||
58 | * @var StrategyInterface |
||
59 | */ |
||
60 | protected $extractionStrategy; |
||
61 | |||
62 | /** |
||
63 | * @var Logger |
||
64 | */ |
||
65 | protected $logger; |
||
66 | |||
67 | |||
68 | /** |
||
69 | * @param boolean $securityRequired user provider to use |
||
70 | * @param string $securityTestUsername user for testing |
||
71 | * @param boolean $allowAnonymous user provider to use |
||
72 | * @param AuthenticationProvider $userProvider user provider to use |
||
73 | * @param StrategyInterface $extractionStrategy auth strategy to use |
||
74 | * @param Logger $logger logger to user for logging errors |
||
75 | */ |
||
76 | 20 | public function __construct( |
|
93 | |||
94 | /** |
||
95 | * @param Request $request request to authenticate |
||
96 | * @param string $providerKey provider key to auth with |
||
97 | * |
||
98 | * @return PreAuthenticatedToken |
||
99 | */ |
||
100 | 10 | public function createToken(Request $request, $providerKey) |
|
116 | |||
117 | /** |
||
118 | * Tries to authenticate the provided token |
||
119 | * |
||
120 | * @param TokenInterface $token token to authenticate |
||
121 | * @param UserProviderInterface $userProvider provider to auth against |
||
122 | * @param string $providerKey key to auth with |
||
123 | * |
||
124 | * @return PreAuthenticatedToken |
||
125 | */ |
||
126 | 4 | public function authenticateToken( |
|
179 | |||
180 | /** |
||
181 | * Convert object role to string role. |
||
182 | * |
||
183 | * @param RoleInterface $role Object role |
||
184 | * @return null|string |
||
185 | */ |
||
186 | private function objectRolesToArray(RoleInterface $role) |
||
190 | |||
191 | /** |
||
192 | * @param TokenInterface $token token to check |
||
193 | * @param string $providerKey provider to check against |
||
194 | * |
||
195 | * @return bool |
||
196 | */ |
||
197 | 2 | public function supportsToken(TokenInterface $token, $providerKey) |
|
201 | |||
202 | /** |
||
203 | * This is called when an interactive authentication attempt fails. This is |
||
204 | * called by authentication listeners inheriting from |
||
205 | * AbstractAuthenticationListener. |
||
206 | * |
||
207 | * @param Request $request original request |
||
208 | * @param AuthenticationException $exception exception from auth attempt |
||
209 | * |
||
210 | * @return Response|null |
||
211 | */ |
||
212 | 2 | public function onAuthenticationFailure(Request $request, AuthenticationException $exception) |
|
219 | } |
||
220 |