/**
  * Register a new client and generate a strong secret
  *
  * Please note that the secret must be really kept secret, as it is used for some grant type to
  * authorize the client. It is returned as a result of this method, as it's already encrypted
  * in the client object
  *
  * @param  Client $client
  * @return array
  */
 public function registerClient(Client $client) : array
 {
     // Finally, we must generate a strong, unique secret, and crypt it before storing it
     $secret = bin2hex(random_bytes(20));
     $client->setSecret(password_hash($secret, PASSWORD_DEFAULT));
     $client = $this->clientRepository->save($client);
     return [$client, $secret];
 }
Esempio n. 2
0
 /**
  * Register a new client and generate a strong secret
  *
  * Please note that the secret must be really kept secret, as it is used for some grant type to
  * authorize the client. It is returned as a result of this method, as it's already encrypted
  * in the client object
  *
  * @param string $name
  * @param array  $redirectUris
  * @return array [$client, $secret]
  */
 public function registerClient(string $name, array $redirectUris) : array
 {
     do {
         $client = Client::createNewClient($name, $redirectUris);
     } while ($this->clientRepository->idExists($client->getId()));
     $secret = $client->generateSecret();
     $client = $this->clientRepository->save($client);
     return [$client, $secret];
 }