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__ . '/index-functions.php'; |
7
|
|
|
|
8
|
|
|
use CILogon\Service\Util; |
9
|
|
|
use CILogon\Service\Content; |
10
|
|
|
use CILogon\Service\ShibError; |
11
|
|
|
use CILogon\Service\Loggit; |
12
|
|
|
|
13
|
|
|
Util::startPHPSession(); |
14
|
|
|
|
15
|
|
|
// Util::startTiming(); |
16
|
|
|
// Util::$timeit->printTime('MAIN Program START...'); |
17
|
|
|
|
18
|
|
|
// Check for a Shibboleth error and handle it |
19
|
|
|
$shiberror = new ShibError(); |
20
|
|
|
|
21
|
|
|
// Check the csrf cookie against either a hidden <form> element or a |
22
|
|
|
// PHP session variable, and get the value of the 'submit' element. |
23
|
|
|
// Note: replace CR/LF with space for 'Show/Hide Help' buttons. |
24
|
|
|
$retchars = array("\r\n","\n","\r"); |
25
|
|
|
$submit = str_replace( |
26
|
|
|
$retchars, |
27
|
|
|
" ", |
28
|
|
|
Util::getCsrf()->verifyCookieAndGetSubmit() |
29
|
|
|
); |
30
|
|
|
Util::unsetSessionVar('submit'); |
31
|
|
|
|
32
|
|
|
$log = new Loggit(); |
33
|
|
|
$log->info('submit="' . $submit . '"'); |
34
|
|
|
|
35
|
|
|
// Depending on the value of the clicked 'submit' button or the |
36
|
|
|
// equivalent PHP session variable, take action or print out HTML. |
37
|
|
|
switch ($submit) { |
38
|
|
|
case 'Log On': // Check for OpenID or InCommon usage. |
39
|
|
|
case 'Continue': // For OOI |
40
|
|
|
Content::handleLogOnButtonClicked(); |
41
|
|
|
break; // End case 'Log On' |
42
|
|
|
|
43
|
|
|
case 'Log Off': // Click the 'Log Off' button |
44
|
|
|
printLogonPage(true); |
|
|
|
|
45
|
|
|
break; // End case 'Log Off' |
46
|
|
|
|
47
|
|
|
case 'gotuser': // Return from the getuser script |
48
|
|
|
Content::handleGotUser(); |
49
|
|
|
break; // End case 'gotuser' |
50
|
|
|
|
51
|
|
|
case 'Go Back': // Return to the Main page |
52
|
|
|
case 'Proceed': // Proceed after 'User Changed' or Error page |
53
|
|
|
case 'Done with Two-Factor': |
54
|
|
|
Util::verifySessionAndCall('printMainPage'); |
|
|
|
|
55
|
|
|
break; // End case 'Go Back' / 'Proceed' |
56
|
|
|
|
57
|
|
|
case 'Cancel': // Cancel button on WAYF page - go to Google |
58
|
|
|
header('Location: https://www.google.com/'); |
59
|
|
|
exit; // No further processing necessary |
60
|
|
|
break; |
61
|
|
|
|
62
|
|
|
case 'Get New Certificate': |
63
|
|
|
if (Util::verifySessionAndCall('CILogon\\Service\\Content::generateP12')) { |
|
|
|
|
64
|
|
|
printMainPage(); |
65
|
|
|
} |
66
|
|
|
break; // End case 'Get New Certificate' |
67
|
|
|
|
68
|
|
|
case 'Manage Two-Factor': |
69
|
|
|
Util::verifySessionAndCall( |
70
|
|
|
'CILogon\\Service\\Content::printTwoFactorPage' |
|
|
|
|
71
|
|
|
); |
72
|
|
|
break; // End case 'Manage Two-Factor' |
73
|
|
|
|
74
|
|
|
case 'Enable': // Enable / Disable two-factor authentication |
75
|
|
|
case 'Disable': |
76
|
|
|
case 'Verify': // Log in with Google Authenticator |
77
|
|
|
case 'Disable Two-Factor': |
78
|
|
|
$enable = !preg_match('/^Disable/', $submit); |
79
|
|
|
Util::verifySessionAndCall( |
80
|
|
|
'CILogon\\Service\\Content::handleEnableDisableTwoFactor', |
|
|
|
|
81
|
|
|
array($enable) |
82
|
|
|
); |
83
|
|
|
break; // End case 'Enable' / 'Disable' |
84
|
|
|
|
85
|
|
|
case 'I Lost My Phone': |
86
|
|
|
Util::verifySessionAndCall( |
87
|
|
|
'CILogon\\Service\\Content::handleILostMyPhone' |
|
|
|
|
88
|
|
|
); |
89
|
|
|
break; // End case 'I Lost My Phone' |
90
|
|
|
|
91
|
|
|
case 'Enter': // Verify Google Authenticator one time password |
92
|
|
|
Util::verifySessionAndCall( |
93
|
|
|
'CILogon\\Service\\Content::handleGoogleAuthenticatorLogin' |
|
|
|
|
94
|
|
|
); |
95
|
|
|
break; // End case 'Enter' |
96
|
|
|
|
97
|
|
|
case 'EnterDuo': // Verify Duo Security login |
98
|
|
|
Util::verifySessionAndCall( |
99
|
|
|
'CILogon\\Service\\Content::handleDuoSecurityLogin' |
|
|
|
|
100
|
|
|
); |
101
|
|
|
break; // End case 'EnterDuo' |
102
|
|
|
|
103
|
|
|
case 'Show Help ': // Toggle showing of help text on and off |
104
|
|
|
case 'Hide Help ': |
105
|
|
|
Content::handleHelpButtonClicked(); |
106
|
|
|
break; // End case 'Show Help' / 'Hide Help' |
107
|
|
|
|
108
|
|
|
default: // No submit button clicked nor PHP session submit variable set |
109
|
|
|
Content::handleNoSubmitButtonClicked(); |
110
|
|
|
break; // End default case |
111
|
|
|
} // End switch($submit) |
112
|
|
|
|
113
|
|
|
// Util::$timeit->printTime('MAIN Program END... '); |
114
|
|
|
|
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.