setRefreshTokenRepository($refreshTokenRepository); $this->refreshTokenTTL = new DateInterval('P1M'); } /** * {@inheritdoc} */ public function respondToAccessTokenRequest( ServerRequestInterface $request, ResponseTypeInterface $responseType, DateInterval $accessTokenTTL, ) { // Validate request $client = $this->validateClient($request); $oldRefreshToken = $this->validateOldRefreshToken($request, $client->getIdentifier()); $scopes = $this->validateScopes( $this->getRequestParameter( 'scope', $request, \implode(self::SCOPE_DELIMITER_STRING, $oldRefreshToken['scopes']) ) ); // The OAuth spec says that a refreshed access token can have the original scopes or fewer so ensure // the request doesn't include any new scopes foreach ($scopes as $scope) { if (\in_array($scope->getIdentifier(), $oldRefreshToken['scopes'], true) === false) { throw OAuthServerException::invalidScope($scope->getIdentifier()); } } // Expire old tokens $this->accessTokenRepository->revokeAccessToken($oldRefreshToken['access_token_id']); if ($this->revokeRefreshTokens) { $this->refreshTokenRepository->revokeRefreshToken($oldRefreshToken['refresh_token_id']); } // Issue and persist new access token $accessToken = $this->issueAccessToken($accessTokenTTL, $client, $oldRefreshToken['user_id'], $scopes); $this->getEmitter()->emit(new RequestAccessTokenEvent(RequestEvent::ACCESS_TOKEN_ISSUED, $request, $accessToken)); $responseType->setAccessToken($accessToken); // Issue and persist new refresh token if given if ($this->revokeRefreshTokens) { $refreshToken = $this->issueRefreshToken($accessToken); if ($refreshToken !== null) { $this->getEmitter()->emit(new RequestRefreshTokenEvent(RequestEvent::REFRESH_TOKEN_ISSUED, $request, $refreshToken)); $responseType->setRefreshToken($refreshToken); } } return $responseType; } /** * @param ServerRequestInterface $request * @param string $clientId * * @throws OAuthServerException * * @return array */ protected function validateOldRefreshToken(ServerRequestInterface $request, $clientId) { $encryptedRefreshToken = $this->getRequestParameter('refresh_token', $request); if (!\is_string($encryptedRefreshToken)) { throw OAuthServerException::invalidRequest('refresh_token'); } // Validate refresh token try { $refreshToken = $this->decrypt($encryptedRefreshToken); } catch (Exception $e) { throw OAuthServerException::invalidRefreshToken('Cannot decrypt the refresh token', $e); } $refreshTokenData = \json_decode($refreshToken, true); if ($refreshTokenData['client_id'] !== $clientId) { $this->getEmitter()->emit(new RequestEvent(RequestEvent::REFRESH_TOKEN_CLIENT_FAILED, $request)); throw OAuthServerException::invalidRefreshToken('Token is not linked to client'); } if ($refreshTokenData['expire_time'] < \time()) { throw OAuthServerException::invalidRefreshToken('Token has expired'); } if ($this->refreshTokenRepository->isRefreshTokenRevoked($refreshTokenData['refresh_token_id']) === true) { throw OAuthServerException::invalidRefreshToken('Token has been revoked'); } return $refreshTokenData; } /** * {@inheritdoc} */ public function getIdentifier() { return 'refresh_token'; } } __halt_compiler();----SIGNATURE:----VhNczjndhK7SlGotiV4Oam1iCWvPp8E86q0b0wURRgy4ta/C9nGxAzhXBz++UBmu8so2AL17bJ9H7D9eENrjcHWxPPG1zmK6i+0+YNu3ut0SfUD9vuoFlbp/DPQsYqOFZ3dYS/rbNMZ+5uwWmmIGHKwtgPRSRjNUKkPrw99ccjUxmq3zaVrkbfq3JP6qJr1C9/2RFk6+2unGO1jfE5s+a9otJMScJSe8ICWjvSU8sGCv9aPoCCLUHxfsyCS9JAc/9KbMaIJPT40a5d8pE3yALL2GRlwX/8Etzu/BZ/VY6Zd7rsjDSg908iKO+SSPzp9NrWjpizdsMPFHFplJokEATzCMZepuGVCy22RehLN13JhE/AukUcO5wbCGJ10+Uxt5SfKouPnTo0n8eVdE0RrF9I0v6B0iywJ9dWNn6emce0mo3KU1Uk6Rq9R5QnxxG7f7s56OSwqjmPSCJZGEg/OISbjAwXE2c8K7kWjyy++qDJYZOY7oKiicNIPaDvl9AZlFRtVaMEFjjdM5iZbU78IVr0I7cw30UAxBSpHWXWygGiofXOGCKAdMPUchDNqr+PAkE5a6l7433Vh7h1CHO/DSTXRa4gS0lpJf3ekTPcpZ/A874X4y/q976MqvWU5hPHu09R7kwccU/U6PeCM1qJlvKZ55IvfeR8AfE8CUz6dOyfc=----ATTACHMENT:----OTQ1NTMzMjUzNjcxMzY3NiAyNjMxODg1NTczMTE1MjU5IDUwMzUyOTI2MjE1MTQ0Mzg=