You are here

public function OAuth2Storage::getJti in OAuth2 Server 8

Same name and namespace in other branches
  1. 2.0.x src/OAuth2Storage.php \Drupal\oauth2_server\OAuth2Storage::getJti()

Get Jti.

Parameters

string $client_id: The client id string.

string $subject: The subject string.

string $audience: The audience string.

int $expires: The expiration timestamp.

string $jti: The jti string.

Return value

array|void An Jti array.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

src/OAuth2Storage.php, line 612

Class

OAuth2Storage
Provides Drupal OAuth2 storage for the library.

Namespace

Drupal\oauth2_server

Code

public function getJti($client_id, $subject, $audience, $expires, $jti) {
  $client = $this
    ->getStorageClient($client_id);
  if (!$client) {

    // The client_id should be validated prior to this method being called,
    // but the library doesn't do that currently.
    // phpcs:ignore Drupal.Commenting.FunctionComment.InvalidReturnNotVoid
    return;
  }
  $found = $this->entityTypeManager
    ->getStorage('oauth2_server_jti')
    ->loadByProperties([
    'client_id' => $client
      ->id(),
    'subject' => $subject,
    'jti' => $jti,
    'expires' => $expires,
  ]);
  if ($found) {

    // JTI found, return the data back in the expected format.
    return [
      'issuer' => $client_id,
      'subject' => $subject,
      'jti' => $jti,
      'expires' => $expires,
    ];
  }
}