mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-23 05:29:52 +05:30
Updated examples
This commit is contained in:
parent
fb8f47e868
commit
2a6f900323
@ -29,7 +29,7 @@ $app = new App([
|
|||||||
],
|
],
|
||||||
AuthorizationServer::class => function () {
|
AuthorizationServer::class => function () {
|
||||||
// Init our repositories
|
// Init our repositories
|
||||||
$clientRepository = new ClientRepository();
|
$clientRepository = new ClientReptository();
|
||||||
$scopeRepository = new ScopeRepository();
|
$scopeRepository = new ScopeRepository();
|
||||||
$accessTokenRepository = new AccessTokenRepository();
|
$accessTokenRepository = new AccessTokenRepository();
|
||||||
$authCodeRepository = new AuthCodeRepository();
|
$authCodeRepository = new AuthCodeRepository();
|
||||||
|
@ -30,9 +30,9 @@ $app = new App([
|
|||||||
$accessTokenRepository = new AccessTokenRepository(); // instance of AccessTokenRepositoryInterface
|
$accessTokenRepository = new AccessTokenRepository(); // instance of AccessTokenRepositoryInterface
|
||||||
|
|
||||||
// Path to public and private keys
|
// Path to public and private keys
|
||||||
$privateKey = 'file://path/to/private.key';
|
$privateKey = 'file://'.__DIR__.'/../private.key';
|
||||||
//$privateKey = new CryptKey('file://path/to/private.key', 'passphrase'); // if private key has a pass phrase
|
//$privateKey = new CryptKey('file://path/to/private.key', 'passphrase'); // if private key has a pass phrase
|
||||||
$publicKey = 'file://path/to/public.key';
|
$publicKey = 'file://'.__DIR__.'/../public.key';
|
||||||
|
|
||||||
// Setup the authorization server
|
// Setup the authorization server
|
||||||
$server = new AuthorizationServer(
|
$server = new AuthorizationServer(
|
||||||
|
@ -17,13 +17,14 @@ class ClientRepository implements ClientRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getClientEntity($clientIdentifier, $clientSecret = null, $redirectUri = null, $grantType = null)
|
public function getClientEntity($clientIdentifier, $grantType, $clientSecret = null, $mustValidateSecret = true)
|
||||||
{
|
{
|
||||||
$clients = [
|
$clients = [
|
||||||
'myawesomeapp' => [
|
'myawesomeapp' => [
|
||||||
'secret' => password_hash('abc123', PASSWORD_BCRYPT),
|
'secret' => password_hash('abc123', PASSWORD_BCRYPT),
|
||||||
'name' => 'My Awesome App',
|
'name' => 'My Awesome App',
|
||||||
'redirect_uri' => 'http://foo/bar',
|
'redirect_uri' => 'http://foo/bar',
|
||||||
|
'is_confidential' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -32,6 +33,14 @@ class ClientRepository implements ClientRepositoryInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
$mustValidateSecret === true
|
||||||
|
&& $clients[$clientIdentifier]['is_confidential'] === true
|
||||||
|
&& password_verify($clientSecret, $clients[$clientIdentifier]['secret']) === false
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$client = new ClientEntity();
|
$client = new ClientEntity();
|
||||||
$client->setIdentifier($clientIdentifier);
|
$client->setIdentifier($clientIdentifier);
|
||||||
$client->setName($clients[$clientIdentifier]['name']);
|
$client->setName($clients[$clientIdentifier]['name']);
|
||||||
|
Loading…
Reference in New Issue
Block a user