mirror of
https://github.com/bitinflow/accounts.git
synced 2026-03-14 22:15:52 +00:00
change namespace and cleanup code
This commit is contained in:
32
src/Accounts/Http/Middleware/CheckClientCredentials.php
Normal file
32
src/Accounts/Http/Middleware/CheckClientCredentials.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Bitinflow\Accounts\Http\Middleware;
|
||||
|
||||
use Bitinflow\Accounts\Exceptions\MissingScopeException;
|
||||
use stdClass;
|
||||
|
||||
class CheckClientCredentials extends CheckCredentials
|
||||
{
|
||||
/**
|
||||
* Validate token credentials.
|
||||
*
|
||||
* @param stdClass $token
|
||||
* @param array $scopes
|
||||
*
|
||||
* @return void
|
||||
* @throws MissingScopeException
|
||||
*
|
||||
*/
|
||||
protected function validateScopes(stdClass $token, array $scopes)
|
||||
{
|
||||
if (in_array('*', $token->scopes)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($scopes as $scope) {
|
||||
if (!in_array($scope, $token->scopes)) {
|
||||
throw new MissingScopeException($scopes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user