/** * @param AccessToken $access_token * @throws \oauth2\exceptions\InvalidAccessTokenException */ public function storesAccessTokenOnCache(AccessToken $access_token) { //stores in REDIS $value = $access_token->getValue(); $hashed_value = Hash::compute('sha256', $value); if ($this->cache_service->exists($hashed_value)) { throw new InvalidAccessTokenException(); } $auth_code = !is_null($access_token->getAuthCode()) ? Hash::compute('sha256', $access_token->getAuthCode()) : ''; $refresh_token_value = !is_null($access_token->getRefreshToken()) ? Hash::compute('sha256', $access_token->getRefreshToken()->getValue()) : ''; $user_id = !is_null($access_token->getUserId()) ? $access_token->getUserId() : 0; $this->cache_service->storeHash($hashed_value, array('user_id' => $user_id, 'client_id' => $access_token->getClientId(), 'scope' => $access_token->getScope(), 'auth_code' => $auth_code, 'issued' => $access_token->getIssued(), 'lifetime' => $access_token->getLifetime(), 'audience' => $access_token->getAudience(), 'from_ip' => IPHelper::getUserIp(), 'refresh_token' => $refresh_token_value), intval($access_token->getLifetime())); }