コード例 #1
0
<?php

// SSO client support functions.
// (C) 2015 CubicleSoft.  All Rights Reserved.
if (!class_exists("SSO_Client")) {
    echo "The base class must be loaded first.";
    exit;
}
$sso__client = new SSO_Client();
$sso__client->Init(isset($sso_removekeys) ? $sso_removekeys : array());
function SSO_SendRequest($action, $options = array(), $endpoint = SSO_SERVER_ENDPOINT_URL, $apikey = SSO_SERVER_APIKEY, $secretkey = SSO_SERVER_SECRETKEY)
{
    global $sso__client;
    return $sso__client->SendRequest($action, $options, $endpoint, $apikey, $secretkey);
}
function SSO_GetFullRequestURLBase()
{
    global $sso__client;
    return $sso__client->GetFullRequestURLBase();
}
function SSO_LoggedIn()
{
    global $sso__client;
    return $sso__client->LoggedIn();
}
function SSO_CanAutoLogin()
{
    global $sso__client;
    return $sso__client->CanAutoLogin();
}
function SSO_FromSSOServer()
コード例 #2
0
    $functions = array("fsockopen" => "Web functions", "json_decode" => "JSON decoding support functions", "mcrypt_module_open" => "Mcrypt cryptographic support functions", "openssl_open" => "OpenSSL extension support");
    $x = 0;
    foreach ($functions as $function => $info) {
        echo "<tr class=\"row" . ($x % 2 ? " altrow" : "") . "\"><td>" . htmlspecialchars($function) . "</td><td align=\"right\">" . (function_exists($function) ? "<span class=\"success\">Yes</span>" : "<span class=\"error\">No</span><br /><br />Single Sign-On Client will be unable to use " . $info . ".  The installation might succeed but the product will not function at all or have terrible performance.") . "</td></tr>\n";
        $x++;
    }
    ?>
	</table>
<?php 
} else {
    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "baseoptstest") {
        // Test connectivity to the SSO server.
        define("SSO_CLIENT_ROOT_PATH", str_replace("\\", "/", dirname(__FILE__)));
        define("SSO_CLIENT_SUPPORT_PATH", "support");
        define("SSO_CLIENT_LANG_PATH", "lang");
        $sso_client = new SSO_Client();
        if ($_REQUEST["default_lang"] == "") {
            $result = array("success" => true);
        } else {
            $result = $sso_client->SetLanguage(SSO_CLIENT_ROOT_PATH . "/" . SSO_CLIENT_LANG_PATH . "/", $_REQUEST["default_lang"]);
        }
        if ($result["success"]) {
            echo "<span class=\"success\">Default language selection looks okay.</span><br />";
        } else {
            echo "<span class=\"error\">Default language selection has a problem:  " . htmlspecialchars($result["error"]) . "</span><br />";
        }
        define("SSO_CLIENT_PROXY_X_FORWARDED_FOR", $_REQUEST["sso_proxy_x_forwarded_for"]);
        define("SSO_CLIENT_PROXY_CLIENT_IP", $_REQUEST["sso_proxy_client_ip"]);
        define("SSO_CLIENT_PROXY_URL", $_REQUEST["sso_proxy_url"]);
        define("SSO_CLIENT_PROXY_CONNECT", (bool) (int) $_REQUEST["sso_proxy_connect"]);
        define("SSO_SERVER_ENDPOINT_URL", $_REQUEST["url"]);
コード例 #3
0
ファイル: test_oo.php プロジェクト: marks2016/sso
<?php

// These two lines should be executed as soon as possible.
require_once "client/config.php";
require_once SSO_CLIENT_ROOT_PATH . "/index.php";
$sso_client = new SSO_Client();
$sso_client->Init(array("sso_impersonate", "sso_remote_id"));
// The rest of this code can be executed whenever.
$extra = array();
if (isset($_REQUEST["sso_impersonate"]) && is_string($_REQUEST["sso_impersonate"])) {
    $extra["sso_impersonate"] = $_REQUEST["sso_impersonate"];
} else {
    if (isset($_REQUEST["sso_remote_id"]) && is_string($_REQUEST["sso_remote_id"])) {
        $extra["sso_provider"] = "sso_remote";
        $extra["sso_remote_id"] = $_REQUEST["sso_remote_id"];
    }
}
if (!$sso_client->LoggedIn()) {
    $sso_client->Login("", "You must login to use this system.", $extra);
}
// Fields names from the SSO server API key mapping.
$fields = array("username", "firstname");
// Reads user information from the browser cookie, session,
// and/or the SSO server into a more convenient user object.
$user = $sso_client->GetMappedUserInfo($fields);
// Test permissions for the user.
//if (!$sso_client->IsSiteAdmin())  $sso_client->Login("", "insufficient_permissions");
// Get the internal token for use with XSRF defenses.
// Not used in this example.
$bb_usertoken = $sso_client->GetSecretToken();
// A simple example.