コード例 #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
ファイル: 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.