Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Bridge/ClientRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function validateClient($clientIdentifier, $clientSecret, $grantType)
return false;
}

return ! $record->confidential() || $this->verifySecret((string) $clientSecret, $record->secret);
return ! $record->confidential() || $this->verifySecret((string) $clientSecret, $record->secret, $grantType);
}

/**
Expand Down Expand Up @@ -95,11 +95,12 @@ protected function handlesGrant($record, $grantType)
*
* @param string $clientSecret
* @param string $storedHash
* @param string $grantType
* @return bool
*/
protected function verifySecret($clientSecret, $storedHash)
protected function verifySecret($clientSecret, $storedHash, $grantType)
{
return Passport::$hashesClientSecrets
return Passport::$hashesClientSecrets && $grantType !== 'personal_access'
? password_verify($clientSecret, $storedHash)
: hash_equals($storedHash, $clientSecret);
}
Expand Down
8 changes: 8 additions & 0 deletions tests/BridgeClientRepositoryHashedSecretsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ protected function setUp(): void
$this->clientModelRepository = $clientModelRepository;
$this->repository = new BridgeClientRepository($clientModelRepository);
}

public function test_personal_access_grant_is_permitted()
{
$client = $this->clientModelRepository->findActive(1);
$client->personal_access_client = true;

$this->assertTrue($this->repository->validateClient(1, $client->secret, 'personal_access'));
}
}

class BridgeClientRepositoryHashedTestClientStub extends BridgeClientRepositoryTestClientStub
Expand Down