mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-09 15:02:09 +05:30
Add validateClient() function to ClientRepository
This commit is contained in:
parent
7f0879b8b4
commit
aba5353257
@ -14,16 +14,33 @@ use OAuth2ServerExamples\Entities\ClientEntity;
|
|||||||
|
|
||||||
class ClientRepository implements ClientRepositoryInterface
|
class ClientRepository implements ClientRepositoryInterface
|
||||||
{
|
{
|
||||||
|
const CLIENT_NAME = 'My Awesome App';
|
||||||
|
const REDIRECT_URI = 'http://foo/bar';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getClientEntity($clientIdentifier, $grantType = null, $clientSecret = null, $mustValidateSecret = true)
|
public function getClientEntity($clientIdentifier, $grantType = null, $clientSecret = null, $mustValidateSecret = true)
|
||||||
|
{
|
||||||
|
$client = new ClientEntity();
|
||||||
|
|
||||||
|
$client->setIdentifier($clientIdentifier);
|
||||||
|
$client->setName(self::CLIENT_NAME);
|
||||||
|
$client->setRedirectUri(self::REDIRECT_URI);
|
||||||
|
|
||||||
|
return $client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function validateClient($clientIdentifier, $clientSecret, $grantType)
|
||||||
{
|
{
|
||||||
$clients = [
|
$clients = [
|
||||||
'myawesomeapp' => [
|
'myawesomeapp' => [
|
||||||
'secret' => password_hash('abc123', PASSWORD_BCRYPT),
|
'secret' => password_hash('abc123', PASSWORD_BCRYPT),
|
||||||
'name' => 'My Awesome App',
|
'name' => self::CLIENT_NAME,
|
||||||
'redirect_uri' => 'http://foo/bar',
|
'redirect_uri' => self::REDIRECT_URI,
|
||||||
'is_confidential' => true,
|
'is_confidential' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -40,12 +57,5 @@ class ClientRepository implements ClientRepositoryInterface
|
|||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$client = new ClientEntity();
|
|
||||||
$client->setIdentifier($clientIdentifier);
|
|
||||||
$client->setName($clients[$clientIdentifier]['name']);
|
|
||||||
$client->setRedirectUri($clients[$clientIdentifier]['redirect_uri']);
|
|
||||||
|
|
||||||
return $client;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user