if ($saml_user == false) { error_log('auth_onelogin_saml: auth failed due to missing username/email saml attribute: ' . $pluginconfig->saml_username_map); session_write_close(); $USER = new object(); $USER->id = 0; require_once '../../config.php'; print_error('auth_onelogin_saml: auth failed due to missing username/email saml attribute: ' . $pluginconfig->saml_username_map . "<br />" . get_string("auth_onelogin_saml_username_email_error", "auth_onelogin_saml") . "\r\n"); } if ($_POST['SAMLResponse']) { $saml_account_matcher = $pluginconfig->saml_account_matcher; if (empty($saml_account_matcher)) { $saml_account_matcher = 'username'; } $saml_create = $pluginconfig->saml_auto_create_users == 'on' ? true : false; $saml_update = $pluginconfig->saml_auto_update_users == 'on' ? true : false; $USER = auth_onelogin_saml_authenticate_user_login($saml_account_matcher, $saml_user, $saml_create, $saml_update); } else { print_error("Info received. Finishing authentication process through regular method hook because no SAML response detected."); display_object($_POST); $USER = authenticate_user_login($saml_user[$saml_account_matcher], time()); } // check that the signin worked if ($USER == false) { print_error("You could not be identified or created. <br />Login result: FAILURE<br />I have...<br />" . htmlspecialchars(print_r($USER, true))); session_write_close(); $USER = new object(); $USER->id = 0; require_once '../../config.php'; print_error('pluginauthfailed', 'auth_onelogin_saml', '', !empty($saml_user['username']) ? $saml_user['username'] : $saml_user['email']); } // complete the user login sequence
// Valid session. Register or update user in Moodle, log him on, and redirect to Moodle front // we require the plugin to know that we are now doing a saml login in hook puser_login $GLOBALS['onelogin_saml_login'] = TRUE; // check user name attribute actually passed if (!isset($onelogin_saml_nameId)) { error_log('auth_onelogin_saml: auth failed due to missing username saml attribute: ' . $pluginconfig->username); session_write_close(); $USER = new object(); $USER->id = 0; require_once '../../config.php'; print_error('auth_onelogin_saml: auth failed due to missing username saml attribute: ' . $pluginconfig->username . "<br />" . get_string("auth_onelogin_saml_username_error", "auth_onelogin_saml") . "\r\n\r\nonelogin_saml_nameId=" . $onelogin_saml_nameId); } # myDebugger('auth_onelogin_saml: authenticating username: '******'SAMLResponse']) { // isset($pluginconfig->duallogin) && $pluginconfig->duallogin && $USER = auth_onelogin_saml_authenticate_user_login($username, time()); // added the following if ($USER == false && ($pluginconfig->duallogin == "on" || $pluginconfig->duallogin == "checked" || $pluginconfig->duallogin === true)) { print_error("Attempted SAML authentication process and failed; deferring to regular methods..."); $USER = authenticate_user_login($username, time()); } } else { print_error("Info received. Finishing authentication process through regular method hook because no SAML response detected."); display_object($_POST); $USER = authenticate_user_login($username, time()); } // check that the signin worked if ($USER == false) { print_error("You could not be identified or created. <br />Login result: FAILURE<br />I have...<br />" . htmlspecialchars(print_r($USER, true))); session_write_close(); $USER = new object();