if (isset($_SESSION) && isset($_SESSION['AuthNRequestID'])) { $requestID = $_SESSION['AuthNRequestID']; } else { $requestID = null; } $auth->processResponse($requestID); $errors = $auth->getErrors(); if (!empty($errors)) { print_r('<p>' . implode(', ', $errors) . '</p>'); } if (!$auth->isAuthenticated()) { echo "<p>Not authenticated</p>"; exit; } $_SESSION['samlUserdata'] = $auth->getAttributes(); $_SESSION['samlNameId'] = $auth->getNameId(); $_SESSION['samlSessionIndex'] = $auth->getSessionIndex(); unset($_SESSION['AuthNRequestID']); if (isset($_POST['RelayState']) && OneLogin_Saml2_Utils::getSelfURL() != $_POST['RelayState']) { $auth->redirectTo($_POST['RelayState']); } } else { if (isset($_GET['sls'])) { if (isset($_SESSION) && isset($_SESSION['LogoutRequestID'])) { $requestID = $_SESSION['LogoutRequestID']; } else { $requestID = null; } $auth->processSLO(false, $requestID); $errors = $auth->getErrors(); if (empty($errors)) {
header('Location: ' . $ssoBuiltUrl); exit; } else { //process the authentication response if (isset($_SESSION) && isset($_SESSION['AuthNRequestID'])) { $requestID = $_SESSION['AuthNRequestID']; } else { $requestID = null; } // process errors and check for errors $auth->processResponse($requestID); $errors = $auth->getErrors(); // check if errors are present if (!empty($errors)) { $Result->show("danger", implode('<br>', $errors), true); exit; } // is user authenticated if (!$auth->isAuthenticated()) { $Result->show("danger", "Not authenticated", true); exit; } // try to authenticate in phpipam $User->authenticate($auth->getNameId(), '', true); // Redirect user where he came from, if unknown go to dashboard. if (isset($_COOKIE['phpipamredirect'])) { header("Location: " . $_COOKIE['phpipamredirect']); } else { header("Location: " . create_link("dashboard")); } }