GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Provider   B
last analyzed

Complexity

Total Complexity 50

Size/Duplication

Total Lines 482
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 218
dl 0
loc 482
rs 8.4
c 0
b 0
f 0
wmc 50

10 Methods

Rating   Name   Duplication   Size   Complexity  
A isValidRequest() 0 47 5
A handleToken() 0 23 4
A handleConsumer() 0 26 4
A modelHander() 0 3 1
D __construct() 0 101 16
A getAccessToken() 0 38 4
A getRequestToken() 0 3 1
A revokeToken() 0 10 2
B generateToken() 0 57 9
A handleTimestampNonce() 0 23 4

How to fix   Complexity   

Complex Class

Complex classes like Provider often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Provider, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Security\Authentication\Oauth;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Security\Authentication\Oauth\DataStructures;
0 ignored issues
show
Bug introduced by
The type O2System\Security\Authen...on\Oauth\DataStructures was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use O2System\Security\Authentication\Oauth\Interfaces\ProviderModelInterface;
0 ignored issues
show
Bug introduced by
The type O2System\Security\Authen...\ProviderModelInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use O2System\Spl\Traits\Collectors\ErrorCollectorTrait;
21
22
/**
23
 * Class Provider
24
 * @package O2System\Security\Authentication\Oauth
25
 */
26
class Provider
27
{
28
    use ErrorCollectorTrait;
29
30
    /**
31
     * Provider::$oauth
32
     *
33
     * @var \OAuthProvider
34
     */
35
    protected $oauth;
36
37
    /**
38
     * Provider::$consumer
39
     *
40
     * @var \O2System\Security\Authentication\Oauth\DataStructures\Consumer
0 ignored issues
show
Bug introduced by
The type O2System\Security\Authen...DataStructures\Consumer was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
41
     */
42
    protected $consumer;
43
44
    /**
45
     * Provider::$token
46
     *
47
     * @var \O2System\Security\Authentication\Oauth\DataStructures\Token
0 ignored issues
show
Bug introduced by
The type O2System\Security\Authen...th\DataStructures\Token was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
48
     */
49
    protected $token;
50
51
    /**
52
     * Provider::$model
53
     *
54
     * @var \O2System\Security\Authentication\Oauth\Interfaces\ProviderModelInterface
55
     */
56
    protected $model;
57
58
    // ------------------------------------------------------------------------
59
60
    /**
61
     * Provider::__construct
62
     */
63
    public function __construct()
64
    {
65
        language()
66
            ->addFilePath(str_replace('Authentication' . DIRECTORY_SEPARATOR . 'Oauth', '',
67
                    __DIR__) . DIRECTORY_SEPARATOR)
68
            ->loadFile('oauth');
69
70
        $this->oauth = new \OAuthProvider([
71
            'signature_method' => 'HMAC-SHA1',
72
        ]);
73
74
        $this->oauth->consumerHandler([$this, 'handleConsumer']);
75
        $this->oauth->timestampNonceHandler([$this, 'handleTimestampNonce']);
76
        $this->oauth->tokenHandler([$this, 'handleToken']);
77
78
        if (models()->has('oauth')) {
0 ignored issues
show
Bug introduced by
The function models was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

78
        if (/** @scrutinizer ignore-call */ models()->has('oauth')) {
Loading history...
79
            $this->modelHander(models()->get('oauth'));
80
        }
81
82
        $this->oauth->signature_method = OAUTH_SIG_METHOD_HMACSHA1;
0 ignored issues
show
Bug introduced by
The property signature_method does not seem to exist on OAuthProvider.
Loading history...
83
        $this->oauth->consumer_key = input()->get('consumer_key');
0 ignored issues
show
Bug introduced by
The property consumer_key does not seem to exist on OAuthProvider.
Loading history...
84
        $this->oauth->consumer_secret = input()->get('consumer_secret');
0 ignored issues
show
Bug introduced by
The property consumer_secret does not seem to exist on OAuthProvider.
Loading history...
85
        $this->oauth->token = input()->get('oauth_token');
0 ignored issues
show
Bug introduced by
The property token does not seem to exist on OAuthProvider.
Loading history...
86
        $this->oauth->token_secret = input()->get('oauth_token_secret');
0 ignored issues
show
Bug introduced by
The property token_secret does not seem to exist on OAuthProvider.
Loading history...
87
        $this->oauth->token_type = null;
0 ignored issues
show
Bug introduced by
The property token_type does not seem to exist on OAuthProvider.
Loading history...
88
89
        // Get HTTP_AUTHORIZATION
90
        if ($httpAuthorization = input()->server('HTTP_AUTHORIZATION')) {
91
            $httpAuthorization = explode(' ', $httpAuthorization);
92
            $httpAuthorization = array_map('trim', $httpAuthorization);
93
94
            switch (strtoupper($httpAuthorization[ 0 ])) {
95
                default:
96
                case 'OAUTH':
97
                    array_shift($httpAuthorization);
98
                    $httpAuthorization = array_map(function ($string) {
99
                        $string = str_replace(['"', ','], '', $string);
100
                        $string = explode('=', $string);
101
102
                        return [
103
                            'key'   => str_replace('oauth_', '', $string[ 0 ]),
104
                            'value' => $string[ 1 ],
105
                        ];
106
                    }, $httpAuthorization);
107
108
                    $oauthParams = [];
109
                    foreach ($httpAuthorization as $param) {
110
                        $oauthParams[ $param[ 'key' ] ] = $param[ 'value' ];
111
                    }
112
113
                    $this->oauth->signature_method = $oauthParams[ 'signature_method' ];
114
                    $this->oauth->nonce = $oauthParams[ 'nonce' ];
0 ignored issues
show
Bug introduced by
The property nonce does not seem to exist on OAuthProvider.
Loading history...
115
                    $this->oauth->timestamp = $oauthParams[ 'timestamp' ];
0 ignored issues
show
Bug introduced by
The property timestamp does not seem to exist on OAuthProvider.
Loading history...
116
                    $this->oauth->consumer_key = $oauthParams[ 'consumer_key' ];
117
                    $this->oauth->version = $oauthParams[ 'version' ];
0 ignored issues
show
Bug introduced by
The property version does not seem to exist on OAuthProvider.
Loading history...
118
119
                    if (isset($oauthParams[ 'callback' ])) {
120
                        $this->oauth->callback = urldecode($oauthParams[ 'callback' ]);
0 ignored issues
show
Bug introduced by
The property callback does not seem to exist on OAuthProvider.
Loading history...
121
                    }
122
123
                    if (isset($oauthParams[ 'signature' ])) {
124
                        $this->oauth->signature = $oauthParams[ 'signature' ];
0 ignored issues
show
Bug introduced by
The property signature does not seem to exist on OAuthProvider.
Loading history...
125
                    }
126
127
                    $this->oauth->callconsumerHandler();
128
                    break;
129
                case 'BASIC':
130
                case 'BEARER':
131
                    $this->oauth->bearer = $httpAuthorization[ 1 ];
0 ignored issues
show
Bug introduced by
The property bearer does not seem to exist on OAuthProvider.
Loading history...
132
                    $bearer = base64_decode($this->oauth->bearer);
133
                    $bearer = explode(':', $bearer);
134
                    $bearer = array_map('trim', $bearer);
135
136
                    if (count($bearer) == 2) {
137
                        $this->oauth->consumer_key = $bearer[ 0 ];
138
                        $this->oauth->consumer_secret = $bearer[ 1 ];
139
140
                        $this->oauth->callconsumerHandler();
141
                    }
142
143
                    break;
144
            }
145
        } elseif ($oauthVerifier = input()->post('oauth_verifier')) {
146
            $this->oauth->verifier = $oauthVerifier;
0 ignored issues
show
Bug introduced by
The property verifier does not seem to exist on OAuthProvider.
Loading history...
147
            $verifier = base64_decode($this->oauth->verifier);
148
            $verifier = explode(':', $verifier);
149
            $verifier = array_map('trim', $verifier);
150
151
            if (count($verifier) == 2) {
152
                $this->oauth->token = $verifier[ 0 ];
153
                $this->oauth->token_secret = $verifier[ 1 ];
154
            }
155
        }
156
157
        if ( ! empty($this->oauth->token)) {
158
            $this->oauth->calltokenHandler();
159
        }
160
161
        if ( ! $this->hasErrors()) {
162
            if ( ! empty($this->oauth->timestamp) && ! empty($this->oauth->nonce)) {
163
                $this->oauth->callTimestampNonceHandler();
164
            }
165
        }
166
    }
167
168
    // ------------------------------------------------------------------------
169
170
    /**
171
     * Provider::modelHandler
172
     *
173
     * Sets OAuth Provider model handler.
174
     *
175
     * @param $model
176
     *
177
     * @return void
178
     */
179
    public function modelHander(ProviderModelInterface $model)
180
    {
181
        $this->model = $model;
182
    }
183
184
    // ------------------------------------------------------------------------
185
186
    /**
187
     * Provider::getAccessToken
188
     *
189
     * Gets OAuth Access Token.
190
     *
191
     * @return array|bool|\O2System\Security\Authentication\Oauth\DataStructures\Token
192
     */
193
    public function getAccessToken()
194
    {
195
        if ( ! empty($this->token)) {
196
            if ($this->model->insertTokenNonce([
197
                'id_consumer_token' => $this->token->id,
198
                'nonce'             => $token[ 'nonce' ] = Oauth::generateNonce(),
0 ignored issues
show
Bug introduced by
The type O2System\Security\Authentication\Oauth\Oauth was not found. Did you mean Oauth? If so, make sure to prefix the type with \.
Loading history...
Comprehensibility Best Practice introduced by
$token was never initialized. Although not strictly required by PHP, it is generally a good practice to add $token = array(); before regardless.
Loading history...
199
                'timestamp'         => $token[ 'timestamp' ] = date('Y-m-d H:m:s'),
200
                'expires'           => $token[ 'expires' ] = time() + 3600,
201
            ])) {
202
                return new DataStructures\Token([
203
                    'key'       => $this->token->key,
204
                    'secret'    => $this->token->secret,
205
                    'nonce'     => $token[ 'nonce' ],
206
                    'timestamp' => $token[ 'timestamp' ],
207
                    'expires'   => $token[ 'expires' ],
208
                    'verifier'  => (new Token($this->token->key, $this->token->secret))->getVerifier(),
0 ignored issues
show
Unused Code introduced by
The call to O2System\Security\Authen...th\Token::__construct() has too many arguments starting with $this->token->secret. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

208
                    'verifier'  => (/** @scrutinizer ignore-call */ new Token($this->token->key, $this->token->secret))->getVerifier(),

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
209
                ]);
210
            }
211
        }
212
213
        $token = $this->generateToken('ACCESS');
214
        $token = new DataStructures\Token([
215
            'id'       => $token[ 'id' ],
216
            'key'      => $token[ 'key' ],
217
            'secret'   => $token[ 'secret' ],
218
            'verifier' => (new Token($token[ 'key' ], $token[ 'secret' ]))->getVerifier(),
0 ignored issues
show
Bug introduced by
$token['key'] of type string is incompatible with the type O2System\Security\Authentication\Oauth\Consumer expected by parameter $consumer of O2System\Security\Authen...th\Token::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

218
            'verifier' => (new Token(/** @scrutinizer ignore-type */ $token[ 'key' ], $token[ 'secret' ]))->getVerifier(),
Loading history...
219
        ]);
220
221
        if ($this->model->insertTokenNonce([
222
            'id_consumer_token' => $token[ 'id' ],
223
            'nonce'             => $token[ 'nonce' ] = Oauth::generateNonce(),
224
            'timestamp'         => $token[ 'timestamp' ] = date('Y-m-d H:m:s'),
225
            'expires'           => $token[ 'expires' ] = time() + 3600,
226
        ])) {
227
            return $token;
228
        }
229
230
        return false;
231
    }
232
233
    // ------------------------------------------------------------------------
234
235
    /**
236
     * Provider::generateToken
237
     *
238
     * @param string $type
239
     * @param int    $length
240
     * @param bool   $strong
241
     *
242
     * @return array|bool Returns FALSE if failed.
243
     */
244
    protected function generateToken($type = 'ACCESS', $length = 32, $strong = true)
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

244
    protected function generateToken(/** @scrutinizer ignore-unused */ $type = 'ACCESS', $length = 32, $strong = true)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
245
    {
246
        if ( ! empty($this->consumer->secret)) {
247
            return [
248
                'oauth_token'        => hash_hmac('sha1', \OAuthProvider::generateToken($length, $strong),
249
                    $this->consumer->secret),
250
                'oauth_token_secret' => hash_hmac('sha1', \OAuthProvider::generateToken($length, $strong),
251
                    $this->consumer->secret),
252
            ];
253
            switch ($this->oauth->signature_method) {
0 ignored issues
show
Unused Code introduced by
SwitchNode is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
254
                default:
255
                case OAUTH_SIG_METHOD_HMACSHA1:
256
                case OAUTH_SIG_METHOD_RSASHA1:
257
258
                    $token = [
259
                        'key'    => hash_hmac('sha1', \OAuthProvider::generateToken($length, $strong),
260
                            $this->consumer->secret),
261
                        'secret' => hash_hmac('sha1', \OAuthProvider::generateToken($length, $strong),
262
                            $this->consumer->secret),
263
                    ];
264
                    break;
265
266
                case OAUTH_SIG_METHOD_HMACSHA256:
267
268
                    $token = [
269
                        'key'    => hash_hmac('sha256', \OAuthProvider::generateToken($length, $strong),
270
                            $this->consumer->secret),
271
                        'secret' => hash_hmac('sha256', \OAuthProvider::generateToken($length, $strong),
272
                            $this->consumer->secret),
273
                    ];
274
                    break;
275
            }
276
277
            $nonce = (empty($this->oauth->nonce) ? Oauth::generateNonce() : $this->oauth->nonce);
278
            $callback = (empty($this->oauth->callback) ? null : $this->oauth->callback);
279
280
            if ($this->model->insertToken([
281
                'id_consumer' => $this->consumer->id,
282
                'key'         => $token[ 'key' ],
283
                'secret'      => $token[ 'secret' ],
284
                'type'        => $type,
285
                'callback'    => $callback,
286
            ])) {
287
                $token[ 'id' ] = $this->model->db->getLastInsertId();
288
289
                if ($this->model->insertTokenNonce([
290
                    'id_consumer_token' => $token[ 'id' ],
291
                    'nonce'             => $nonce,
292
                    'timestamp'         => date('Y-m-d H:m:s'),
293
                    'expires'           => time() + 3600,
294
                ])) {
295
                    return $token;
296
                }
297
            }
298
        }
299
300
        return false;
301
    }
302
303
    // ------------------------------------------------------------------------
304
305
    /**
306
     * Provider::getRequestToken
307
     *
308
     * Gets OAuth Request Token.
309
     *
310
     * @return array|bool Returns FALSE if failed.
311
     */
312
    public function getRequestToken()
313
    {
314
        return $this->generateToken('REQUEST');
315
    }
316
317
    // ------------------------------------------------------------------------
318
319
    /**
320
     * Provider::handleConsumer
321
     *
322
     * OAuth Consumer Handler.
323
     *
324
     * @param \OAuth $provider
325
     *
326
     * @return int
327
     */
328
    public function handleConsumer($provider)
329
    {
330
        $this->consumer = new DataStructures\Consumer();
331
332
        if (false !== ($consumer = $this->model->findConsumer(['key' => $provider->consumer_key]))) {
0 ignored issues
show
Bug introduced by
The property consumer_key does not seem to exist on OAuth.
Loading history...
333
            $this->consumer->id = $consumer->id;
334
            $this->consumer->key = $consumer->key;
335
            $this->consumer->secret = $provider->consumer_secret = $consumer->secret;
0 ignored issues
show
Bug introduced by
The property consumer_secret does not seem to exist on OAuth.
Loading history...
336
            $this->consumer->status = $consumer->status;
337
338
            if ($consumer->status === 'ENABLED') {
339
                return OAUTH_OK;
340
            }
341
342
            $this->addError(OAUTH_CONSUMER_KEY_REFUSED, language()->getLine('OAUTH_CONSUMER_KEY_REFUSED'));
343
344
            return OAUTH_CONSUMER_KEY_REFUSED;
345
        }
346
347
        if (empty($this->oauth->bearer)) {
348
            $this->addError(OAUTH_CONSUMER_KEY_UNKNOWN, language()->getLine('OAUTH_CONSUMER_KEY_UNKNOWN'));
349
        } else {
350
            $this->addError(OAUTH_CONSUMER_KEY_UNKNOWN, language()->getLine('OAUTH_AUTHORIZATION_UNKNOWN'));
351
        }
352
353
        return OAUTH_CONSUMER_KEY_UNKNOWN;
354
    }
355
356
    // ------------------------------------------------------------------------
357
358
    /**
359
     * Provider::revokeToken
360
     *
361
     * Revoke OAuth Consumer Token.
362
     *
363
     * @param string $token oauth_token
364
     *
365
     * @return bool
366
     */
367
    public function revokeToken($token)
368
    {
369
        $this->oauth->token = $token;
0 ignored issues
show
Bug introduced by
The property token does not seem to exist on OAuthProvider.
Loading history...
370
        $this->oauth->calltokenHandler();
371
372
        if ( ! $this->hasErrors()) {
373
            return $this->model->deleteToken(['key' => $token]);
374
        }
375
376
        return false;
377
    }
378
379
    // ------------------------------------------------------------------------
380
381
    /**
382
     * Provider::handleToken
383
     *
384
     * OAuth Token Handler.
385
     *
386
     * @param \OAuth $provider
387
     *
388
     * @return int
389
     */
390
    public function handleToken($provider)
391
    {
392
        if (false !== ($token = $this->model->findToken(['key' => $provider->token]))) {
0 ignored issues
show
Bug introduced by
The property token does not seem to exist on OAuth.
Loading history...
393
            if (isset($token->consumer)) {
394
                $this->token = $token;
395
396
                $this->consumer = $token->consumer;
397
                $provider->consumer_key = $this->consumer->key;
0 ignored issues
show
Bug introduced by
The property consumer_key does not seem to exist on OAuth.
Loading history...
398
                $provider->consumer_secret = $this->consumer->secret;
0 ignored issues
show
Bug introduced by
The property consumer_secret does not seem to exist on OAuth.
Loading history...
399
                $provider->token_secret = $token->secret;
0 ignored issues
show
Bug introduced by
The property token_secret does not seem to exist on OAuth.
Loading history...
400
            }
401
402
            return OAUTH_OK;
403
        }
404
405
        if (empty($this->oauth->verifier)) {
406
            $this->addError(OAUTH_TOKEN_REJECTED, language()->getLine('OAUTH_TOKEN_REJECTED'));
407
408
            return OAUTH_TOKEN_REJECTED;
409
        } else {
410
            $this->addError(OAUTH_VERIFIER_INVALID, language()->getLine('OAUTH_TOKEN_VERIFIER_REJECTED'));
411
412
            return OAUTH_VERIFIER_INVALID;
413
        }
414
    }
415
416
    // ------------------------------------------------------------------------
417
418
    /**
419
     * Provider::handleTimestampNonce
420
     *
421
     * OAuth Timestamp and Nonce Handler.
422
     *
423
     * @param \OAuth $provider
424
     *
425
     * @return int
426
     */
427
    public function handleTimestampNonce($provider)
428
    {
429
        if (empty($provider->timestamp)) {
430
            $this->addError(OAUTH_BAD_TIMESTAMP, language()->getLine('OAUTH_BAD_TIMESTAMP'));
431
432
            return OAUTH_BAD_TIMESTAMP;
433
        }
434
435
        if (false !== ($token = $this->model->findTokenNonce([
436
                'nonce' => $provider->nonce,
0 ignored issues
show
Bug introduced by
The property nonce does not seem to exist on OAuth.
Loading history...
437
            ]))) {
438
            if (time() > $token->expires) {
439
                $this->addError(OAUTH_TOKEN_EXPIRED, language()->getLine('OAUTH_TOKEN_EXPIRED'));
440
441
                return OAUTH_TOKEN_EXPIRED;
442
            }
443
444
            return OAUTH_OK;
445
        }
446
447
        $this->addError(OAUTH_BAD_NONCE, language()->getLine('OAUTH_BAD_NONCE'));
448
449
        return OAUTH_BAD_NONCE;
450
    }
451
452
    // ------------------------------------------------------------------------
453
454
    /**
455
     * Provider::isValidRequest
456
     *
457
     * Determine if the OAuth Request is valid.
458
     *
459
     * @return bool
460
     */
461
    public function isValidRequest()
462
    {
463
        $message = language()->getLine('OAUTH_SIGNATURE_METHOD_REJECTED');
464
465
        if (empty($this->oauth->callback)) {
466
            $consumer = new Consumer($this->oauth->consumer_key, $this->oauth->consumer_secret);
0 ignored issues
show
Bug introduced by
The property consumer_key does not seem to exist on OAuthProvider.
Loading history...
Bug introduced by
The property consumer_secret does not seem to exist on OAuthProvider.
Loading history...
467
468
            $signature = $consumer->getSignature(
0 ignored issues
show
Bug introduced by
The method getSignature() does not exist on O2System\Security\Authentication\Oauth\Consumer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

468
            /** @scrutinizer ignore-call */ 
469
            $signature = $consumer->getSignature(

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
469
                $this->oauth->signature_method,
0 ignored issues
show
Bug introduced by
The property signature_method does not seem to exist on OAuthProvider.
Loading history...
470
                null,
471
                null,
472
                [
473
                    'oauth_nonce'            => $this->oauth->nonce,
0 ignored issues
show
Bug introduced by
The property nonce does not seem to exist on OAuthProvider.
Loading history...
474
                    'oauth_signature_method' => $this->oauth->signature_method,
475
                    'oauth_timestamp'        => $this->oauth->timestamp,
0 ignored issues
show
Bug introduced by
The property timestamp does not seem to exist on OAuthProvider.
Loading history...
476
                    'oauth_consumer_key'     => $this->oauth->consumer_key,
477
                    'oauth_version'          => $this->oauth->version,
0 ignored issues
show
Bug introduced by
The property version does not seem to exist on OAuthProvider.
Loading history...
478
                ]);
479
480
            if ($signature === $this->oauth->signature) {
0 ignored issues
show
Bug introduced by
The property signature does not seem to exist on OAuthProvider.
Loading history...
481
                return true;
482
            }
483
        } elseif (empty($this->oauth->signature)) {
484
            $message = language()->getLine('OAUTH_SIGNATURE_MISSING');
485
        } else {
486
            $consumer = new Consumer($this->oauth->consumer_key, $this->oauth->consumer_secret);
487
488
            $signature = $consumer->getSignature(
489
                $this->oauth->signature_method,
490
                $this->oauth->callback,
0 ignored issues
show
Bug introduced by
The property callback does not seem to exist on OAuthProvider.
Loading history...
491
                input()->server('REQUEST_METHOD'),
492
                [
493
                    'oauth_nonce'            => $this->oauth->nonce,
494
                    'oauth_signature_method' => $this->oauth->signature_method,
495
                    'oauth_timestamp'        => $this->oauth->timestamp,
496
                    'oauth_consumer_key'     => $this->oauth->consumer_key,
497
                    'oauth_version'          => $this->oauth->version,
498
                ]);
499
500
            if ($signature === $this->oauth->signature) {
501
                return true;
502
            }
503
        }
504
505
        $this->addError(OAUTH_SIGNATURE_METHOD_REJECTED, $message);
506
507
        return false;
508
    }
509
}