Conditions | 4 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
24 | public function check(OAuth2Token $token, OAuth2 $configuration): ?string |
||
25 | { |
||
26 | $scope = $configuration->getScope(); |
||
27 | if (null === $scope) { |
||
28 | return null; |
||
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 | return sprintf('Insufficient scope. The scope rule is: %s', $configuration->getScope()); |
||
37 | } |
||
38 | |||
39 | return null; |
||
40 | } |
||
41 | } |
||
42 |