Conditions | 4 |
Paths | 5 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
24 | public function check(OAuth2Token $token, OAuth2 $configuration): void |
||
25 | { |
||
26 | $scope = $configuration->getScope(); |
||
27 | if (null === $scope) { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | $scopes = explode(' ', $scope); |
||
32 | $tokenScope = $token->getAccessToken()->hasParameter('scope') ? explode(' ', $token->getAccessToken()->getParameter('scope')) : []; |
||
33 | $diff = array_diff($scopes, $tokenScope); |
||
34 | |||
35 | if (!empty($diff)) { |
||
36 | throw new \Exception(sprintf('Insufficient scope. The required scope is "%s"', $configuration->getScope())); |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 |