File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
plugins/api-authentication/token/src/Extension Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,11 @@ public function onUserAuthenticate(AuthenticationEvent $event): void
168168 */
169169 $ allowedAlgo = \in_array ($ algo , $ this ->allowedAlgos );
170170
171+ // If the algorithm is not allowed, fail authentication gracefully.
172+ if (!$ allowedAlgo ) {
173+ return ;
174+ }
175+
171176 /**
172177 * Make sure the user ID is an integer
173178 */
@@ -190,6 +195,12 @@ public function onUserAuthenticate(AuthenticationEvent $event): void
190195 $ referenceTokenData = $ this ->getTokenSeedForUser ($ userId );
191196 $ referenceTokenData = empty ($ referenceTokenData ) ? '' : $ referenceTokenData ;
192197 $ referenceTokenData = base64_decode ($ referenceTokenData );
198+
199+ // If the reference token data is empty, user has no token configured.
200+ if (empty ($ referenceTokenData )) {
201+ return ;
202+ }
203+
193204 $ referenceHMAC = hash_hmac ($ algo , $ referenceTokenData , $ siteSecret );
194205
195206 // Is the token enabled?
You can’t perform that action at this time.
0 commit comments