You are here

public static function Utility::siteNeedsKeys in OAuth2 Server 8

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

Returns whether the current site needs to have keys generated.

Return value

bool TRUE if at least one server uses JWT Access Tokens or OpenID Connect, FALSE otherwise.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to Utility::siteNeedsKeys()
oauth2_server_cron in ./oauth2_server.module
Implements hook_cron().

File

src/Utility.php, line 272

Class

Utility
Contains utility methods for the OAuth2 Server.

Namespace

Drupal\oauth2_server

Code

public static function siteNeedsKeys() {

  /** @var \Drupal\oauth2_server\ServerInterface[] $servers */
  $servers = \Drupal::entityTypeManager()
    ->getStorage('oauth2_server')
    ->loadMultiple();
  foreach ($servers as $server) {
    if (!empty($server->settings['use_crypto_tokens'])) {
      return TRUE;
    }
    if (!empty($server->settings['use_openid_connect'])) {
      return TRUE;
    }
  }
  return FALSE;
}