// Loading SAML library require_once '../openssophp/config/config.php'; require_once '../openssophp/lib/saml-lib.php'; // Needs a function to get the token from the php session require_once '../openssophp/spi/sessionhandling/' . $LIGHTBULB_CONFIG['spi-sessionhandling'] . '.php'; // Needs a function to get the token from the php session require_once '../openssophp/spi/namemapping/' . $LIGHTBULB_CONFIG['spi-namemapping'] . '.php'; // Load functions... require_once "example-lib.php"; // URL to return user to after authentication. Will be this page :D $return_url = selfURL(); // URL initiating SSO with lighbulb, contains some configuration parameters. $ssoinit_url = $LIGHTBULB_CONFIG['baseurl'] . "spSSOInit.php?" . "metaAlias=/sp&" . "RelayState=" . urlencode($return_url); // Logout URL. Also a openssophp service with some parameters and a return url. $logout_url = $LIGHTBULB_CONFIG['baseurl'] . "spSLOInit.php?" . "metaAlias=/sp&" . "RelayState=" . urlencode($return_url); $userid = $_POST["username"]; $password = $_POST["password"]; $username = authenticateLocalUser($userid, $password); if (is_null($username)) { echo "Error login, probably bad credentials. Sorry."; exit; } else { if (!is_null(spi_sessionhandling_getNameID())) { // The user is already authenticated to an IdP so we federate the accounts.. $nameId = getNameID(spi_sessionhandling_getResponse()); spi_namemapping_mapNameIdToLocalId($nameId["NameQualifier"], $nameId["SPNameQualifier"], spi_sessionhandling_getNameID(), $userid); } spi_sessionhandling_setUserId($userid); header("Location: " . urldecode($_POST["goto"])); exit; }
* * Copyright 2006 Sun Microsystems Inc. All Rights Reserved */ error_log("Entering spSingleLogoutInit.php"); // Loading configuration require_once 'config/config.php'; require_once $LIGHTBULB_CONFIG['basedir'] . 'config/saml-metadata-SP.php'; require_once $LIGHTBULB_CONFIG['basedir'] . 'config/saml-metadata-IdP.php'; require_once $LIGHTBULB_CONFIG['basedir'] . 'spi/sessionhandling/' . $LIGHTBULB_CONFIG['spi-sessionhandling'] . '.php'; // Loading libraries require 'lib/saml-lib.php'; // require 'samlSpMetadata.php'; // require 'samlIdpMetadata.php'; // require 'saml-lib.php'; // require 'localUserManagement.php'; $token = spi_sessionhandling_getResponse(); $binding = $_GET["binding"]; $RelayStateURL = $_GET["RelayState"]; error_log("binding = " . $binding); error_log("RelayState = " . $RelayStateURL); $idpEntityID = getIssuer($token); if (!isset($idpMetadata[$idpEntityID])) { $error = "400 No IdP configured for " . $idpEntityID; header($_SERVER["SERVER_PROTOCOL"] . " " . $error); echo $error; exit; } $nameId = getNameId($token); $sessionIndex = getSessionIndex($token); $idpTargetUrl = $idpMetadata[$idpEntityID]["SingleLogOutUrl"]; $id = randomhex(42);