You are here

public function Storage::getJti in OAuth2 Server 7

File

lib/Drupal/oauth2_server/Storage.php, line 251

Class

Storage
Provides Drupal storage (through the underlying Entity API) for the library.

Namespace

Drupal\oauth2_server

Code

public function getJti($client_key, $subject, $audience, $expires, $jti) {
  $client = oauth2_server_client_load($client_key);
  if (!$client) {

    // The client_key should be validated prior to this method being called,
    // but the library doesn't do that currently.
    return;
  }
  $data = array(
    ':client_id' => $client->client_id,
    ':subject' => $subject,
    ':jti' => $jti,
    ':expires' => $expires,
  );
  $found = db_query('SELECT 1 FROM {oauth2_server_jti}
                        WHERE client_id = :client_id AND subject = :subject
                          AND jti = :jti AND expires = :expires', $data)
    ->fetchField();
  if ($found) {

    // JTI found, return the data back in the expected format.
    return array(
      'issuer' => $client_key,
      'subject' => $subject,
      'jti' => $jti,
      'expires' => $expires,
    );
  }
}