1 | <?php |
||
16 | class Authorization implements MiddlewareInterface |
||
17 | { |
||
18 | /** |
||
19 | * OAuth2 Server |
||
20 | * |
||
21 | * @var OAuth2\Server |
||
22 | */ |
||
23 | private $server; |
||
24 | |||
25 | /** |
||
26 | * Array of scopes required for authorization. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | private $scopes; |
||
31 | |||
32 | /** |
||
33 | * Container for token. |
||
34 | * |
||
35 | * @var ArrayAccess |
||
36 | */ |
||
37 | private $container; |
||
38 | |||
39 | /** |
||
40 | * Create a new instance of the Authorization middleware. |
||
41 | * |
||
42 | * @param OAuth2\Server $server The configured OAuth2 server. |
||
43 | * @param DI\Container $container A container object in which to store the token from the request. |
||
44 | * @param array $scopes Scopes required for authorization. $scopes can be given as an array of arrays. OR |
||
45 | * logic will use with each grouping. Example: |
||
46 | * Given ['superUser', ['basicUser', 'aPermission']], the request will be verified |
||
47 | * if the request token has 'superUser' scope OR 'basicUser' and 'aPermission' as |
||
48 | * its scope. |
||
49 | */ |
||
50 | public function __construct(OAuth2\Server $server, DI\Container $container, array $scopes = []) |
||
56 | |||
57 | /** |
||
58 | * Execute this middleware. |
||
59 | * |
||
60 | * @param ServerRequestInterface $request The PSR7 request. |
||
61 | * @param ResponseInterface $response The PSR7 response. |
||
62 | * @param callable $next The Next middleware. |
||
63 | * |
||
64 | * @return ResponseInterface |
||
65 | */ |
||
66 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
84 | |||
85 | /** |
||
86 | * Returns a callable function to be used as a authorization middleware with a specified scope. |
||
87 | * |
||
88 | * @param array $scopes Scopes require for authorization. |
||
89 | * |
||
90 | * @return Authorization |
||
91 | */ |
||
92 | public function withRequiredScope(array $scopes) |
||
98 | |||
99 | /** |
||
100 | * Helper method to ensure given scopes are formatted properly. |
||
101 | * |
||
102 | * @param array $scopes Scopes required for authorization. |
||
103 | * |
||
104 | * @return array The formatted scopes array. |
||
105 | */ |
||
106 | private function formatScopes(array $scopes) |
||
123 | } |
||
124 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..