You are here

public function ResourceServer::validateAuthenticatedRequest in Simple OAuth (OAuth2) & OpenID Connect 5.x

Same name and namespace in other branches
  1. 8.4 src/Server/ResourceServer.php \Drupal\simple_oauth\Server\ResourceServer::validateAuthenticatedRequest()
  2. 8.2 src/Server/ResourceServer.php \Drupal\simple_oauth\Server\ResourceServer::validateAuthenticatedRequest()
  3. 8.3 src/Server/ResourceServer.php \Drupal\simple_oauth\Server\ResourceServer::validateAuthenticatedRequest()

Determine the access token validity.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

Return value

\Symfony\Component\HttpFoundation\Request The request object augmented with the token information.

Throws

\League\OAuth2\Server\Exception\OAuthServerException

Overrides ResourceServerInterface::validateAuthenticatedRequest

File

src/Server/ResourceServer.php, line 88

Class

ResourceServer
The resource server.

Namespace

Drupal\simple_oauth\Server

Code

public function validateAuthenticatedRequest(Request $request) {
  if (!$this->subject) {
    throw new \LogicException('Unable to create resource server. Make sure public and private keys are correctly configured.');
  }

  // Create a PSR-7 message from the request that is compatible with the OAuth
  // library.
  $psr7_request = $this->messageFactory
    ->createRequest($request);

  // Augment the request with the access token's decoded data or throw an
  // exception if authentication is unsuccessful.
  $output_psr7_request = $this->subject
    ->validateAuthenticatedRequest($psr7_request);

  // Convert back to the Drupal/Symfony HttpFoundation objects.
  return $this->foundationFactory
    ->createRequest($output_psr7_request);
}