This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php declare(strict_types=1); |
||
2 | |||
3 | namespace Limoncello\OAuthServer; |
||
4 | |||
5 | /** |
||
6 | * Copyright 2015-2019 [email protected] |
||
7 | * |
||
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
9 | * you may not use this file except in compliance with the License. |
||
10 | * You may obtain a copy of the License at |
||
11 | * |
||
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
13 | * |
||
14 | * Unless required by applicable law or agreed to in writing, software |
||
15 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
17 | * See the License for the specific language governing permissions and |
||
18 | * limitations under the License. |
||
19 | */ |
||
20 | |||
21 | use Limoncello\OAuthServer\Contracts\AuthorizationServerInterface; |
||
22 | use Limoncello\OAuthServer\Contracts\ClientInterface; |
||
23 | use Limoncello\OAuthServer\Contracts\Integration\ClientIntegrationInterface as CII; |
||
24 | use Limoncello\OAuthServer\Contracts\Integration\CodeIntegrationInterface as AII; |
||
25 | use Limoncello\OAuthServer\Contracts\Integration\ImplicitIntegrationInterface as III; |
||
26 | use Limoncello\OAuthServer\Contracts\Integration\PasswordIntegrationInterface as PII; |
||
27 | use Limoncello\OAuthServer\Contracts\Integration\RefreshIntegrationInterface as RII; |
||
28 | use Limoncello\OAuthServer\GrantTraits\ClientGrantTrait; |
||
29 | use Limoncello\OAuthServer\GrantTraits\CodeGrantTrait; |
||
30 | use Limoncello\OAuthServer\GrantTraits\ImplicitGrantTrait; |
||
31 | use Limoncello\OAuthServer\GrantTraits\PasswordGrantTrait; |
||
32 | use Limoncello\OAuthServer\GrantTraits\RefreshGrantTrait; |
||
33 | use Limoncello\OAuthServer\ServerTraits\OAuthServerTrait; |
||
34 | use Psr\Http\Message\ResponseInterface; |
||
35 | use Psr\Http\Message\ServerRequestInterface; |
||
36 | use function assert; |
||
37 | use function http_build_query; |
||
38 | |||
39 | /** |
||
40 | * @package Limoncello\OAuthServer |
||
41 | */ |
||
42 | abstract class BaseAuthorizationServer implements AuthorizationServerInterface, AII, III, PII, CII, RII |
||
43 | { |
||
44 | use OAuthServerTrait, |
||
45 | CodeGrantTrait, ImplicitGrantTrait, PasswordGrantTrait, ClientGrantTrait, RefreshGrantTrait; |
||
46 | |||
47 | /** |
||
48 | * Implements Authorization Endpoint. |
||
49 | * |
||
50 | * @param array $parameters |
||
51 | * |
||
52 | * @return ResponseInterface |
||
53 | * |
||
54 | * @link https://tools.ietf.org/html/rfc6749#section-3.1 |
||
55 | * @link https://tools.ietf.org/html/rfc6749#section-4.2.1 |
||
56 | */ |
||
57 | abstract protected function createAuthorization(array $parameters): ResponseInterface; |
||
58 | |||
59 | /** |
||
60 | * @var null|int |
||
61 | */ |
||
62 | private $maxStateLength = null; |
||
63 | 44 | ||
64 | /** |
||
65 | 44 | * Constructor. |
|
66 | 44 | */ |
|
67 | 44 | public function __construct() |
|
68 | 44 | { |
|
69 | 44 | $this->codeSetIntegration($this); |
|
70 | $this->implicitSetIntegration($this); |
||
71 | $this->passSetIntegration($this); |
||
72 | $this->clientSetIntegration($this); |
||
73 | $this->refreshSetIntegration($this); |
||
74 | } |
||
75 | 13 | ||
76 | /** |
||
77 | 13 | * @inheritdoc |
|
78 | */ |
||
79 | public function getCreateAuthorization(ServerRequestInterface $request): ResponseInterface |
||
80 | { |
||
81 | return $this->createAuthorization($request->getQueryParams()); |
||
82 | } |
||
83 | 2 | ||
84 | /** |
||
85 | 2 | * @inheritdoc |
|
86 | */ |
||
87 | public function postCreateAuthorization(ServerRequestInterface $request): ResponseInterface |
||
88 | { |
||
89 | return $this->createAuthorization($request->getParsedBody()); |
||
0 ignored issues
–
show
|
|||
90 | } |
||
91 | 4 | ||
92 | /** |
||
93 | 4 | * @inheritdoc |
|
94 | */ |
||
95 | public function codeValidateScope(ClientInterface $client, array $scopes = null): array |
||
96 | { |
||
97 | return $this->validateScope($client, $scopes); |
||
98 | } |
||
99 | 4 | ||
100 | /** |
||
101 | 4 | * @inheritdoc |
|
102 | */ |
||
103 | public function implicitValidateScope(ClientInterface $client, array $scopes = null): array |
||
104 | { |
||
105 | return $this->validateScope($client, $scopes); |
||
106 | } |
||
107 | 5 | ||
108 | /** |
||
109 | 5 | * @inheritdoc |
|
110 | */ |
||
111 | public function passValidateScope(ClientInterface $client = null, array $scopes = null): array |
||
112 | { |
||
113 | return $this->validateScope($client, $scopes); |
||
0 ignored issues
–
show
It seems like
$client defined by parameter $client on line 111 can be null ; however, Limoncello\OAuthServer\S...rTrait::validateScope() does not accept null , maybe add an additional type check?
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null. We recommend to add an additional type check (or disallow null for the parameter): function notNullable(stdClass $x) { }
// Unsafe
function withoutCheck(stdClass $x = null) {
notNullable($x);
}
// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
if ($x instanceof stdClass) {
notNullable($x);
}
}
// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
notNullable($x);
}
![]() |
|||
114 | } |
||
115 | 3 | ||
116 | /** |
||
117 | 3 | * @inheritdoc |
|
118 | */ |
||
119 | public function clientValidateScope(ClientInterface $client, array $scopes = null): array |
||
120 | { |
||
121 | return $this->validateScope($client, $scopes); |
||
122 | } |
||
123 | 12 | ||
124 | /** |
||
125 | 12 | * @return int|null |
|
126 | */ |
||
127 | public function getMaxStateLength(): ?int |
||
128 | { |
||
129 | return $this->maxStateLength; |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | 2 | * @param int|null $maxStateLength |
|
134 | * |
||
135 | 2 | * @return self |
|
136 | */ |
||
137 | 2 | public function setMaxStateLength(int $maxStateLength = null): self |
|
138 | { |
||
139 | 2 | assert($maxStateLength === null || $maxStateLength > 0); |
|
140 | |||
141 | $this->maxStateLength = $maxStateLength; |
||
142 | |||
143 | return $this; |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | 12 | * @param array $parameters |
|
148 | * |
||
149 | 12 | * @return string |
|
150 | */ |
||
151 | protected function encodeAsXWwwFormUrlencoded(array $parameters): string |
||
152 | { |
||
153 | return http_build_query($parameters, '', '&', PHP_QUERY_RFC3986); |
||
154 | } |
||
155 | } |
||
156 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.