1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
// error_reporting(E_ALL); ini_set('display_errors',1); |
4
|
|
|
|
5
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php'; |
6
|
|
|
require_once __DIR__ . '/../../config.php'; |
7
|
|
|
include_once __DIR__ . '/../../config.secrets.php'; |
8
|
|
|
require_once __DIR__ . '/index-functions.php'; |
9
|
|
|
|
10
|
|
|
use CILogon\Service\Util; |
11
|
|
|
use CILogon\Service\Loggit; |
12
|
|
|
|
13
|
|
|
Util::startPHPSession(); |
14
|
|
|
|
15
|
|
|
// Check the csrf cookie against either a hidden <form> element or a |
16
|
|
|
// PHP session variable, and get the value of the 'submit' element. |
17
|
|
|
$submit = Util::getCsrf()->verifyCookieAndGetSubmit(); |
18
|
|
|
Util::unsetSessionVar('submit'); |
19
|
|
|
|
20
|
|
|
// Get the URL to reply to after database query. |
21
|
|
|
$responseurl = Util::getSessionVar('responseurl'); |
22
|
|
|
|
23
|
|
|
if (($submit == 'getuser') && (strlen($responseurl) > 0)) { |
24
|
|
|
getUserAndRespond($responseurl); |
|
|
|
|
25
|
|
|
} elseif ($submit == 'pkcs12') { |
26
|
|
|
getPKCS12(); |
27
|
|
|
} elseif ($submit == 'certreq') { |
28
|
|
|
getCert(); |
29
|
|
|
} else { |
30
|
|
|
// If the REQUEST_URI was '/secure/getcert' then it was ECP. |
31
|
|
|
// Respond with an error message rather than a redirect. |
32
|
|
|
if (preg_match('%/secure/getcert%', Util::getServerVar('REQUEST_URI'))) { |
33
|
|
|
$log = new Loggit(); |
34
|
|
|
$log->info('"/secure/getcert" error: Either CSRF check ' . |
35
|
|
|
'failed, or invalid "submit" command issued.'); |
36
|
|
|
outputError('Unable to complete ECP transaction. Either CSRF ' . |
37
|
|
|
'check failed, or invalid "submit" command issued.'); |
38
|
|
|
} else { // Redirect to $responseurl or main homepage |
39
|
|
|
if (strlen($responseurl) == 0) { |
40
|
|
|
$responseurl = 'https://' . Util::getHN(); |
41
|
|
|
} |
42
|
|
|
header('Location: ' . $responseurl); |
43
|
|
|
exit; // No further processing necessary |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
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.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.