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:----E7/8sU9WUJeJLqE3rg7tgwdsVmTVUVTB3jYRto0bk9O0G9h7ZZ3wyPxu7bk/1yWXkXbdZtkOIqhE9/RTgU56X5FOXHYsw6kkEJ7z/Mp9dpT/MfAYmcVeu7KrMJ3pw26eayISxqLQ8janSuxQG8QN76sa7m0Uu3hUOTbzIf2K9hS6btUyr4UkFPcUNB4rZU8cu7VBOlN/OW7yKa/HDL2CTK160V1tCSPMbSPdgXn+SF6BIdHFLKQFVRDbEJxY0kgSMWm92L4BLU5oj73bJs89diYUtc7S3m22CISn9uNPNXHXDk5FpLmL3wp0Mnym3Hl55NodvxKXiExxO7FIvr28BOBjYtRdAQud+7vLv4VvRIYMAg9hZl14zZY30kX1TCLk3onfYcmMXle/sUZN5OuJ/1NpQ2sepxDo+Ud3Ddq6jIxZtXQA4bgcB282CPBL8q4o50juHpv8GOptaaxTToch3zHI1Y8EThQfTxCbZ7UrJqWr4BRYnM2ah9CJZnafllPo6Qt2jL3SlMQ76fPfXmuEcL8zRxja8lJJeNMHrLaoWzZ8XcfRUK3RYvYSOMN+dd6CclC1vDgVbalaEmQTifScXKGdXZUBKfZRtlmfOEfgf6/nwLZuDIOnfoz19u8vI3vjs7KuGGx75JUF3XKKgZSyokI+XJyAPeoNvXEbQWeeyn4=----ATTACHMENT:----NTgxNTc4NjgyODE2NzU4NSA5NTU0NDg4NTYxNTg2NDUyIDI4OTYwMDgxMTQ1ODg3MjY=