Conditions | 7 |
Paths | 9 |
Total Lines | 73 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
149 | public function getAccessToken($grant, array $options = []) |
||
150 | { |
||
151 | /** @var AccessToken $token */ |
||
152 | $accessToken = parent::getAccessToken($grant, $options); |
||
153 | |||
154 | if (null === $accessToken) { |
||
155 | throw new InvalidTokenException('Invalid access token.'); |
||
156 | } |
||
157 | |||
158 | $token = $accessToken->getIdToken(); |
||
159 | // id_token is empty. |
||
160 | if (null === $token) { |
||
161 | throw new InvalidTokenException('Expected an id_token but did not receive one from the authorization server.'); |
||
162 | } |
||
163 | |||
164 | // If the ID Token is received via direct communication between the Client and the Token Endpoint |
||
165 | // (which it is in this flow), the TLS server validation MAY be used to validate the issuer in place of checking |
||
166 | // the token signature. The Client MUST validate the signature of all other ID Tokens according to JWS [JWS] |
||
167 | // using the algorithm specified in the JWT alg Header Parameter. The Client MUST use the keys provided by |
||
168 | // the Issuer. |
||
169 | // |
||
170 | // The alg value SHOULD be the default of RS256 or the algorithm sent by the Client in the |
||
171 | // id_token_signed_response_alg parameter during Registration. |
||
172 | if (false === $token->verify($this->signer, $this->getPublicKey())) { |
||
173 | throw new InvalidTokenException('Received an invalid id_token from authorization server.'); |
||
174 | } |
||
175 | |||
176 | // validations |
||
177 | // @see http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation |
||
178 | // validate the iss (issuer) |
||
179 | // - The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery) |
||
180 | // MUST exactly match the value of the iss (issuer) Claim. |
||
181 | // validate the aud |
||
182 | // - The Client MUST validate that the aud (audience) Claim contains its client_id value registered at the Issuer |
||
183 | // identified by the iss (issuer) Claim as an audience. The aud (audience) Claim MAY contain an array with more |
||
184 | // than one element. The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, |
||
185 | // or if it contains additional audiences not trusted by the Client. |
||
186 | // - If a nonce value was sent in the Authentication Request, a nonce Claim MUST be present and its value checked |
||
187 | // to verify that it is the same value as the one that was sent in the Authentication Request. The Client SHOULD |
||
188 | // check the nonce value for replay attacks. The precise method for detecting replay attacks is Client specific. |
||
189 | // - If the auth_time Claim was requested, either through a specific request for this Claim or by using |
||
190 | // the max_age parameter, the Client SHOULD check the auth_time Claim value and request re-authentication if it |
||
191 | // determines too much time has elapsed since the last End-User authentication. |
||
192 | // TODO |
||
193 | // If the acr Claim was requested, the Client SHOULD check that the asserted Claim Value is appropriate. |
||
194 | // The meaning and processing of acr Claim Values is out of scope for this specification. |
||
195 | $currentTime = time(); |
||
196 | $data = [ |
||
197 | 'iss' => $this->getIdTokenIssuer(), |
||
198 | 'exp' => $currentTime, |
||
199 | 'auth_time' => $currentTime, |
||
200 | 'iat' => $currentTime, |
||
201 | 'nbf' => $currentTime, |
||
202 | 'aud' => $this->clientId, |
||
203 | ]; |
||
204 | |||
205 | // If the ID Token contains multiple audiences, the Client SHOULD verify that an azp Claim is present. |
||
206 | // If an azp (authorized party) Claim is present, the Client SHOULD verify that its client_id is the Claim Value. |
||
207 | if ($token->hasClaim('azp')) { |
||
208 | $data['azp'] = $this->clientId; |
||
209 | } |
||
210 | |||
211 | if (false === $this->validatorChain->validate($data, $token)) { |
||
212 | throw new InvalidTokenException('The id_token did not pass validation.'); |
||
213 | } |
||
214 | |||
215 | if ($this->useSession) { |
||
216 | $this->session->set('access_token', $accessToken->getToken()); |
||
217 | $this->session->set('refresh_token', $accessToken->getRefreshToken()); |
||
218 | $this->session->set('id_token', $accessToken->getIdTokenHint()); |
||
219 | } |
||
220 | |||
221 | return $accessToken; |
||
222 | } |
||
326 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths