Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 5807c4e

Browse files
author
Tsvetomir Lazarov
committed
Implement validateClient in the ClientRepository
1 parent 7454bc0 commit 5807c4e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Repository/Pdo/ClientRepository.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Zend\Expressive\Authentication\OAuth2\Repository\Pdo;
1212

13+
use League\OAuth2\Server\Entities\ClientEntityInterface;
1314
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
1415
use Zend\Expressive\Authentication\OAuth2\Entity\ClientEntity;
1516

@@ -32,17 +33,17 @@ public function getClientEntity(
3233
$sth->bindParam(':clientIdentifier', $clientIdentifier);
3334

3435
if (false === $sth->execute()) {
35-
return;
36+
return null;
3637
}
3738
$row = $sth->fetch();
3839
if (empty($row) || ! $this->isGranted($row, $grantType)) {
39-
return;
40+
return null;
4041
}
4142

4243
if ($mustValidateSecret
4344
&& (empty($row['secret']) || ! password_verify((string) $clientSecret, $row['secret']))
4445
) {
45-
return;
46+
return null;
4647
}
4748

4849
return new ClientEntity($clientIdentifier, $row['name'], $row['redirect']);
@@ -68,4 +69,18 @@ protected function isGranted(array $row, string $grantType = null) : bool
6869
return true;
6970
}
7071
}
72+
73+
/**
74+
* {@inheritDoc}
75+
*/
76+
public function validateClient($clientIdentifier, $clientSecret, $grantType) : bool
77+
{
78+
$client = $this->getClientEntity(
79+
$clientIdentifier,
80+
$grantType,
81+
$clientSecret
82+
);
83+
84+
return $client instanceof ClientEntityInterface;
85+
}
7186
}

0 commit comments

Comments
 (0)