1 | <?php |
||
19 | abstract class AbstractAccessTokenAuthenticator |
||
20 | implements SimplePreAuthenticatorInterface, AuthenticationFailureHandlerInterface |
||
21 | { |
||
22 | const DEFAULT_TOKEN_QUERY_PARAMETER_NAME = 'token'; |
||
23 | const DEFAULT_TOKEN_HEADER_NAME = 'X-Access-Token'; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $tokenQueryParameterName = self::DEFAULT_TOKEN_QUERY_PARAMETER_NAME; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $tokenHeaderName = self::DEFAULT_TOKEN_HEADER_NAME; |
||
34 | |||
35 | /** |
||
36 | * If set to true an AuthenticationException will be thrown if no Access Token was found. Otherwise if will simply |
||
37 | * continue with other authentication methods. |
||
38 | * |
||
39 | * @var bool |
||
40 | */ |
||
41 | protected $tokenRequired = false; |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 48 | public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey) |
|
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 88 | public function supportsToken(TokenInterface $token, $providerKey) |
|
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | 88 | public function createToken(Request $request, $providerKey) |
|
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | 2 | public function onAuthenticationFailure(Request $request, AuthenticationException $exception) |
|
107 | |||
108 | /** |
||
109 | * @return string |
||
110 | */ |
||
111 | 88 | public function getTokenQueryParameterName() |
|
115 | |||
116 | /** |
||
117 | * @param $tokenQueryName |
||
118 | */ |
||
119 | public function setTokenQueryParameterName($tokenQueryName) |
||
123 | |||
124 | /** |
||
125 | * @return string |
||
126 | */ |
||
127 | 88 | public function getTokenHeaderName() |
|
131 | |||
132 | /** |
||
133 | * @param $tokenHeaderName |
||
134 | */ |
||
135 | public function setTokenHeaderName($tokenHeaderName) |
||
139 | |||
140 | /** |
||
141 | * @return bool |
||
142 | */ |
||
143 | public function isTokenRequired() |
||
147 | |||
148 | /** |
||
149 | * @param bool $tokenRequired |
||
150 | */ |
||
151 | 88 | public function setTokenRequired($tokenRequired) |
|
155 | |||
156 | /** |
||
157 | * @return AuthenticationException |
||
158 | */ |
||
159 | protected function createTokenMissingException() |
||
163 | |||
164 | /** |
||
165 | * @param $token |
||
166 | * |
||
167 | * @return UserInterface|null |
||
168 | */ |
||
169 | protected abstract function findUserByToken($token); |
||
170 | } |
||
171 |