You are here

public function Client::hashClientSecret in OAuth2 Server 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/Client.php \Drupal\oauth2_server\Entity\Client::hashClientSecret()

Hash a client secret for storage.

Make sure this uses the same algorithm as checkClientCredentials form the \OAuth2\StorageInterface.

Parameters

string $client_secret: The raw secret.

Return value

string The hashed secret.

Overrides ClientInterface::hashClientSecret

1 call to Client::hashClientSecret()
Client::__construct in src/Entity/Client.php
Constructs an Entity object.

File

src/Entity/Client.php, line 143

Class

Client
Defines the OAuth2 client entity.

Namespace

Drupal\oauth2_server\Entity

Code

public function hashClientSecret($client_secret) {
  if ($client_secret === '') {
    return $client_secret;
  }

  /** @var \Drupal\Core\Password\PasswordInterface $password_hasher */
  $password_hasher = \Drupal::service('password');
  return $password_hasher
    ->hash($client_secret);
}