Skip to content
Open
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
4 changes: 1 addition & 3 deletions src/Bridge/Repository/ClientRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public function validateClient($clientIdentifier, $clientSecret, $grantType)
$conditions = [
$this->table->getPrimaryKey() => $clientIdentifier,
];
if ($clientSecret !== null) {
$conditions[$this->table->aliasField('client_secret')] = $clientSecret;
}
$conditions[$this->table->aliasField('client_secret')] = (string)$clientSecret;

$client = $this->table->find()->where($conditions)->first();
/* @var $client Client|null */
Expand Down
12 changes: 12 additions & 0 deletions tests/Fixture/ClientsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ public function init()
]),
];

$this->records[] = [
'id' => 'Public',
'client_secret' => '',
'name' => 'Public Client',
'redirect_uri' => json_encode(['http://www.example.com']),
'grant_types' => json_encode([
'password',
'authorization_code',
'refresh_token',
]),
];

parent::init();
}
}
10 changes: 7 additions & 3 deletions tests/TestCase/Bridge/Repository/ClientRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ public function testValidateClient($inputs, $expects)
public function dataValidateClient()
{
return [
'valid: Client id only' => [
['TEST', null, null],
'valid: Public Client id only' => [
['Public', null, null],
true,
],
'invalid: Confidential Client id only' => [
['TEST', null, null],
false,
],
'valid: Client id with secret' => [
['TEST', 'TestSecret', null],
true,
],
'invalid: Client id only' => [
'invalid: Unregistered Client id only' => [
['INVALID', null, null],
false,
],
Expand Down