getEntityManager()->getRepository('User')->findOne([ 'whereClause' => [ 'type' => 'api', 'apiKey' => $apiKey, 'authMethod' => 'Hmac', ] ]); if (!$user) return; if ($user) { $apiKeyUtil = new ApiKey($this->getConfig()); $secretKey = $apiKeyUtil->getSecretKeyForUserId($user->id); if (!$secretKey) return; $string = $request->getMethod() . ' ' . $request->getResourcePath(); if ($hash === ApiKey::hash($secretKey, $string)) { return $user; } return; } return $user; } }