|
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\Loggit; |
|
11
|
|
|
|
|
12
|
|
|
Util::startPHPSession(); |
|
13
|
|
|
|
|
14
|
|
|
// Check the csrf cookie against either a hidden <form> element or a |
|
15
|
|
|
// PHP session variable, and get the value of the 'submit' element. |
|
16
|
|
|
// Note: replace CR/LF with space for 'Show/Hide Help' buttons. |
|
17
|
|
|
$retchars = array("\r\n","\n","\r"); |
|
18
|
|
|
$submit = str_replace( |
|
19
|
|
|
$retchars, |
|
20
|
|
|
" ", |
|
21
|
|
|
Util::getCsrf()->verifyCookieAndGetSubmit() |
|
22
|
|
|
); |
|
23
|
|
|
Util::unsetSessionVar('submit'); |
|
24
|
|
|
|
|
25
|
|
|
$log = new Loggit(); |
|
26
|
|
|
$log->info('submit="' . $submit . '"'); |
|
27
|
|
|
|
|
28
|
|
|
// First, check to see if the info related to the 'oauth_token' passed |
|
29
|
|
|
// from the Community Portal exists in the current PHP session. If |
|
30
|
|
|
// so, then continue processing based on 'submit' value. Otherwise, |
|
31
|
|
|
// print out error message about bad or missing oauth_token info. |
|
32
|
|
|
if (verifyOAuthToken(Util::getGetVar('oauth_token'))) { |
|
33
|
|
|
// Depending on the value of the clicked 'submit' button or the |
|
34
|
|
|
// equivalent PHP session variable, take action or print out HTML. |
|
35
|
|
|
switch ($submit) { |
|
36
|
|
|
case 'Log On': // Check for OpenID or InCommon usage. |
|
37
|
|
|
case 'Continue': // For OOI |
|
38
|
|
|
Content::handleLogOnButtonClicked(); |
|
39
|
|
|
break; // End case 'Log On' |
|
40
|
|
|
|
|
41
|
|
|
case 'gotuser': // Return from the getuser script |
|
42
|
|
|
Content::handleGotUser(); |
|
43
|
|
|
break; // End case 'gotuser' |
|
44
|
|
|
|
|
45
|
|
|
case 'Proceed': // Proceed after 'User Changed' or Error page |
|
46
|
|
|
case 'Done with Two-Factor': |
|
47
|
|
|
Util::verifySessionAndCall('printMainPage'); |
|
|
|
|
|
|
48
|
|
|
break; // End case 'Proceed' |
|
49
|
|
|
|
|
50
|
|
|
case 'OK': // User allows delegation of certificate |
|
51
|
|
|
handleAllowDelegation(strlen(Util::getPostVar('rememberok')) > 0); |
|
52
|
|
|
break; // End case 'OK' |
|
53
|
|
|
|
|
54
|
|
|
case 'Cancel': // User denies delegation of certificate |
|
55
|
|
|
// If user clicked 'Cancel' on the WAYF page, return to the |
|
56
|
|
|
// portal's failure URL (or Google if failure URL not set). |
|
57
|
|
|
if (Util::getPostVar('previouspage') == 'WAYF') { |
|
58
|
|
|
$failureuri = Util::getSessionVar('failureuri'); |
|
59
|
|
|
$location = 'https://www.google.com/'; |
|
60
|
|
|
if (strlen($failureuri) > 0) { |
|
61
|
|
|
$location = $failureuri . "?reason=cancel"; |
|
62
|
|
|
} |
|
63
|
|
|
Util::unsetAllUserSessionVars(); |
|
64
|
|
|
header('Location: ' . $location); |
|
65
|
|
|
exit; // No further processing necessary |
|
66
|
|
|
} else { // 'Cancel' button on certificate delegate page clicked |
|
67
|
|
|
printCancelPage(); |
|
68
|
|
|
} |
|
69
|
|
|
break; // End case 'Cancel' |
|
70
|
|
|
|
|
71
|
|
|
case 'Manage Two-Factor': |
|
72
|
|
|
Util::verifySessionAndCall( |
|
73
|
|
|
'CILogon\\Service\\Content::printTwoFactorPage' |
|
|
|
|
|
|
74
|
|
|
); |
|
75
|
|
|
break; // End case 'Manage Two-Factor' |
|
76
|
|
|
|
|
77
|
|
|
case 'Enable': // Enable / Disable two-factor authentication |
|
78
|
|
|
case 'Disable': |
|
79
|
|
|
case 'Verify': // Log in with Google Authenticator |
|
80
|
|
|
case 'Disable Two-Factor': |
|
81
|
|
|
$enable = !preg_match('/^Disable/', $submit); |
|
82
|
|
|
Util::verifySessionAndCall( |
|
83
|
|
|
'CILogon\\Service\\Content::handleEnableDisableTwoFactor', |
|
|
|
|
|
|
84
|
|
|
array($enable) |
|
85
|
|
|
); |
|
86
|
|
|
break; // End case 'Enable' / 'Disable' |
|
87
|
|
|
|
|
88
|
|
|
case 'I Lost My Phone': |
|
89
|
|
|
Util::verifySessionAndCall( |
|
90
|
|
|
'CILogon\\Service\\Content::handleILostMyPhone' |
|
|
|
|
|
|
91
|
|
|
); |
|
92
|
|
|
break; // End case 'I Lost My Phone' |
|
93
|
|
|
|
|
94
|
|
|
case 'Enter': // Verify Google Authenticator one time password |
|
95
|
|
|
Util::verifySessionAndCall( |
|
96
|
|
|
'CILogon\\Service\\Content::handleGoogleAuthenticatorLogin' |
|
|
|
|
|
|
97
|
|
|
); |
|
98
|
|
|
break; // End case 'Enter' |
|
99
|
|
|
|
|
100
|
|
|
case 'EnterDuo': // Verify Duo Security login |
|
101
|
|
|
Util::verifySessionAndCall( |
|
102
|
|
|
'CILogon\\Service\\Content::handleDuoSecurityLogin' |
|
|
|
|
|
|
103
|
|
|
); |
|
104
|
|
|
break; // End case 'EnterDuo' |
|
105
|
|
|
|
|
106
|
|
|
case 'Show Help ': // Toggle showing of help text on and off |
|
107
|
|
|
case 'Hide Help ': |
|
108
|
|
|
Content::handleHelpButtonClicked(); |
|
109
|
|
|
break; // End case 'Show Help' / 'Hide Help' |
|
110
|
|
|
|
|
111
|
|
|
default: // No submit button clicked nor PHP session submit variable set |
|
112
|
|
|
Content::handleNoSubmitButtonClicked(); |
|
113
|
|
|
break; // End default case |
|
114
|
|
|
} // End switch ($submit) |
|
115
|
|
|
} else { // Failed to verify oauth_token info in PHP session |
|
116
|
|
|
printBadOAuthTokenPage(); |
|
117
|
|
|
} |
|
118
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: