limoncello-php-dist /
oauth-server
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\Exceptions; |
||
| 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 Exception; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @package Limoncello\OAuthServer |
||
| 25 | */ |
||
| 26 | class OAuthTokenBodyException extends OAuthServerException |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * Error code. |
||
| 30 | * |
||
| 31 | * @link https://tools.ietf.org/html/rfc6749#section-5.2 |
||
| 32 | */ |
||
| 33 | const ERROR_INVALID_REQUEST = 'invalid_request'; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Error code. |
||
| 37 | * |
||
| 38 | * @link https://tools.ietf.org/html/rfc6749#section-5.2 |
||
| 39 | */ |
||
| 40 | const ERROR_INVALID_CLIENT = 'invalid_client'; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Error code. |
||
| 44 | * |
||
| 45 | * @link https://tools.ietf.org/html/rfc6749#section-5.2 |
||
| 46 | */ |
||
| 47 | const ERROR_INVALID_GRANT = 'invalid_grant'; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Error code. |
||
| 51 | * |
||
| 52 | * @link https://tools.ietf.org/html/rfc6749#section-5.2 |
||
| 53 | */ |
||
| 54 | const ERROR_UNAUTHORIZED_CLIENT = 'unauthorized_client'; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Error code. |
||
| 58 | * |
||
| 59 | * @link https://tools.ietf.org/html/rfc6749#section-5.2 |
||
| 60 | */ |
||
| 61 | const ERROR_UNSUPPORTED_GRANT_TYPE = 'unsupported_grant_type'; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Error code. |
||
| 65 | * |
||
| 66 | * @link https://tools.ietf.org/html/rfc6749#section-5.2 |
||
| 67 | */ |
||
| 68 | const ERROR_INVALID_SCOPE = 'invalid_scope'; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Default error messages. |
||
| 72 | * |
||
| 73 | * @link https://tools.ietf.org/html/rfc6749#section-5.2 |
||
| 74 | */ |
||
| 75 | const DEFAULT_MESSAGES = [ |
||
| 76 | self::ERROR_INVALID_REQUEST => 'The request is missing a required parameter, includes an unsupported ' . |
||
| 77 | 'parameter value (other than grant type), repeats a parameter, includes multiple credentials, utilizes ' . |
||
| 78 | 'more than one mechanism for authenticating the client, or is otherwise malformed.', |
||
| 79 | |||
| 80 | self::ERROR_INVALID_CLIENT => 'Client authentication failed (e.g., unknown client, no client ' . |
||
| 81 | 'authentication included, or unsupported authentication method).', |
||
| 82 | |||
| 83 | self::ERROR_INVALID_GRANT => 'The provided authorization grant (e.g., authorization code, resource owner ' . |
||
| 84 | 'credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in ' . |
||
| 85 | 'the authorization request, or was issued to another client.', |
||
| 86 | |||
| 87 | self::ERROR_UNAUTHORIZED_CLIENT => 'The authenticated client is not authorized to use this ' . |
||
| 88 | 'authorization grant type.', |
||
| 89 | |||
| 90 | self::ERROR_UNSUPPORTED_GRANT_TYPE => 'The authorization grant type is not supported by the ' . |
||
| 91 | 'authorization server.', |
||
| 92 | |||
| 93 | self::ERROR_INVALID_SCOPE => 'The requested scope is invalid, unknown, malformed, or exceeds the scope ' . |
||
| 94 | 'granted by the resource owner.', |
||
| 95 | ]; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @var string |
||
| 99 | */ |
||
| 100 | private $errorCode; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @var int |
||
| 104 | */ |
||
| 105 | private $httpCode; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @var string[] |
||
| 109 | */ |
||
| 110 | private $httpHeaders; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @var string|null |
||
| 114 | */ |
||
| 115 | private $errorUri; |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @param string $errorCode |
||
| 119 | * @param string|null $errorUri |
||
| 120 | * @param int $httpCode |
||
| 121 | * @param string[] $httpHeaders |
||
| 122 | * @param string[]|null $descriptions |
||
| 123 | 19 | * @param Exception|null $previous |
|
| 124 | */ |
||
| 125 | public function __construct( |
||
| 126 | string $errorCode, |
||
| 127 | string $errorUri = null, |
||
| 128 | int $httpCode = 400, |
||
| 129 | array $httpHeaders = [], |
||
| 130 | array $descriptions = null, |
||
| 131 | 19 | Exception $previous = null |
|
| 132 | ) { |
||
| 133 | 19 | $descriptions = $descriptions === null ? self::DEFAULT_MESSAGES : $descriptions; |
|
| 134 | |||
| 135 | parent::__construct($descriptions[$errorCode], 0, $previous); |
||
| 136 | |||
| 137 | // @link https://tools.ietf.org/html/rfc6749#section-5.2 |
||
| 138 | // |
||
| 139 | // The authorization server includes the HTTP "Cache-Control" response header field with a value of "no-store" |
||
| 140 | 19 | // in response as well as the "Pragma" response header field with a value of "no-cache". |
|
| 141 | $cacheHeaders = [ |
||
| 142 | 'Cache-Control' => 'no-store', |
||
| 143 | 'Pragma' => 'no-cache' |
||
| 144 | 19 | ]; |
|
| 145 | 19 | ||
| 146 | 19 | $this->errorCode = $errorCode; |
|
| 147 | 19 | $this->errorUri = $errorUri; |
|
| 148 | $this->httpCode = $httpCode; |
||
| 149 | $this->httpHeaders = $httpHeaders + $cacheHeaders; |
||
|
0 ignored issues
–
show
|
|||
| 150 | } |
||
| 151 | |||
| 152 | /** |
||
| 153 | 19 | * @return string |
|
| 154 | */ |
||
| 155 | 19 | public function getErrorCode(): string |
|
| 156 | { |
||
| 157 | return $this->errorCode; |
||
| 158 | } |
||
| 159 | |||
| 160 | /** |
||
| 161 | 19 | * @return string |
|
| 162 | */ |
||
| 163 | 19 | public function getErrorDescription(): string |
|
| 164 | { |
||
| 165 | return $this->getMessage(); |
||
| 166 | } |
||
| 167 | |||
| 168 | /** |
||
| 169 | 19 | * @return string|null |
|
| 170 | */ |
||
| 171 | 19 | public function getErrorUri(): ?string |
|
| 172 | { |
||
| 173 | return $this->errorUri; |
||
| 174 | } |
||
| 175 | |||
| 176 | /** |
||
| 177 | 19 | * @return int |
|
| 178 | */ |
||
| 179 | 19 | public function getHttpCode(): int |
|
| 180 | { |
||
| 181 | return $this->httpCode; |
||
| 182 | } |
||
| 183 | |||
| 184 | /** |
||
| 185 | 19 | * @return string[] |
|
| 186 | */ |
||
| 187 | 19 | public function getHttpHeaders(): array |
|
| 188 | { |
||
| 189 | return $this->httpHeaders; |
||
| 190 | } |
||
| 191 | } |
||
| 192 |
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..