1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\Monitor\TestSuite\AuthSource; |
4
|
|
|
|
5
|
|
|
use KRB5NegotiateAuth; |
6
|
|
|
use SimpleSAML\Module\Monitor\TestConfiguration; |
7
|
|
|
use SimpleSAML\Module\Monitor\TestCase; |
8
|
|
|
use SimpleSAML\Module\Monitor\TestData; |
9
|
|
|
use Webmozart\Assert\Assert; |
10
|
|
|
|
11
|
|
|
final class Negotiate extends \SimpleSAML\Module\Monitor\TestSuiteFactory |
12
|
|
|
{ |
13
|
|
|
/** @var string|null */ |
14
|
|
|
private $authorization; |
15
|
|
|
|
16
|
|
|
/** @var \KRB5NegotiateAuth */ |
17
|
|
|
private $handle; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param \SimpleSAML\Module\Monitor\TestConfiguration $configuration |
22
|
|
|
* @param \SimpleSAML\Module\Monitor\TestData $testData |
23
|
|
|
*/ |
24
|
|
|
public function __construct(TestConfiguration $configuration, TestData $testData) |
25
|
|
|
{ |
26
|
|
|
$authSourceData = $testData->getInputItem('authSourceData'); |
27
|
|
|
$serverVars = $configuration->getServerVars(); |
28
|
|
|
|
29
|
|
|
Assert::isArray($authSourceData); |
30
|
|
|
Assert::keyExists($authSourceData, 'keytab'); |
31
|
|
|
$keytab = $authSourceData['keytab']; |
32
|
|
|
|
33
|
|
|
$this->handle = new KRB5NegotiateAuth($keytab); |
|
|
|
|
34
|
|
|
$this->authorization = $serverVars->get('HTTP_AUTHORIZATION'); |
35
|
|
|
$this->setCategory('SPNEGO authentication source'); |
36
|
|
|
|
37
|
|
|
parent::__construct($configuration); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
public function invokeTest(): void |
45
|
|
|
{ |
46
|
|
|
$input = [ |
47
|
|
|
'handle' => $this->handle, |
48
|
|
|
'authorization' => $this->authorization |
49
|
|
|
]; |
50
|
|
|
$testData = new TestData($input); |
51
|
|
|
|
52
|
|
|
$test = new TestCase\AuthSource\Negotiate($testData); |
53
|
|
|
$this->addTestResult($test->getTestResult()); |
54
|
|
|
$this->setTestResult($test->getTestResult()); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has less 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.