mirror of
https://github.com/bitinflow/accounts.git
synced 2026-03-14 14:05:52 +00:00
32 lines
701 B
PHP
32 lines
701 B
PHP
<?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);
|
|
}
|
|
}
|
|
}
|
|
} |