Пример #1
0
 public function IsEnabled()
 {
     global $sso_settings;
     if (!$sso_settings["sso_google"]["enabled"]) {
         return false;
     }
     if ($sso_settings["sso_google"]["client_id"] == "" || $sso_settings["sso_google"]["client_secret"] == "") {
         return false;
     }
     if (!SSO_IsIPAllowed($sso_settings["sso_google"]["iprestrict"]) || SSO_IsSpammer($sso_settings["sso_google"]["iprestrict"])) {
         return false;
     }
     return true;
 }
Пример #2
0
 public function IsEnabled()
 {
     global $sso_settings, $g_sso_login_modules;
     if (!$sso_settings["sso_login"]["enabled"]) {
         return false;
     }
     if (($sso_settings["sso_login"]["install_type"] == "email_username" || $sso_settings["sso_login"]["install_type"] == "username") && $sso_settings["sso_login"]["map_username"] == "") {
         return false;
     }
     if (($sso_settings["sso_login"]["install_type"] == "email_username" || $sso_settings["sso_login"]["install_type"] == "email") && $sso_settings["sso_login"]["map_email"] == "") {
         return false;
     }
     if (!SSO_IsIPAllowed($sso_settings["sso_login"]["iprestrict"]) || SSO_IsSpammer($sso_settings["sso_login"]["iprestrict"])) {
         return false;
     }
     foreach ($g_sso_login_modules as $key => $info) {
         if ($sso_settings["sso_login"]["modules"][$key]["_a"]) {
             $module = "sso_login_module_" . $key;
             $instance = new $module();
             if (!$instance->IsAllowed()) {
                 return false;
             }
         }
     }
     return true;
 }
Пример #3
0
 public function IsEnabled()
 {
     global $sso_settings;
     if (!function_exists("ldap_connect") || !$sso_settings["sso_ldap"]["enabled"]) {
         return false;
     }
     if ($sso_settings["sso_ldap"]["server"] == "" || $sso_settings["sso_ldap"]["dn"] == "" || $sso_settings["sso_ldap"]["map_username"] == "") {
         return false;
     }
     if (!SSO_IsIPAllowed($sso_settings["sso_ldap"]["iprestrict"]) || SSO_IsSpammer($sso_settings["sso_ldap"]["iprestrict"])) {
         return false;
     }
     return true;
 }
Пример #4
0
 public function IsEnabled()
 {
     global $sso_settings, $sso_db, $sso_db_apikeys;
     if (!$sso_settings["sso_remote"]["enabled"]) {
         return false;
     }
     if (!SSO_IsIPAllowed($sso_settings["sso_remote"]["iprestrict"])) {
         return false;
     }
     if (!isset($_REQUEST["sso_remote_id"]) || !is_string($_REQUEST["sso_remote_id"])) {
         return false;
     }
     $remoteid = explode("-", $_REQUEST["sso_remote_id"]);
     if (count($remoteid) != 2) {
         return false;
     }
     $sso_db_sso_remote = SSO_DB_PREFIX . "p_sso_remote";
     try {
         $row = $sso_db->GetRow("SELECT", array("*", "FROM" => "?", "WHERE" => "id = ? AND remotekey = ?"), $sso_db_sso_remote, $remoteid[1], $remoteid[0]);
         if ($row === false) {
             return false;
         }
         $this->info["row"] = $row;
         $this->info["display_name"] = BB_Translate("%s Login", $row->name);
         $info = unserialize($row->info);
         if (!isset($info["iprestrict"]) || !SSO_IsIPAllowed($info["iprestrict"]) || SSO_IsSpammer($info["iprestrict"])) {
             return false;
         }
         $this->info["row_info"] = $info;
         $apirow = $sso_db->GetRow("SELECT", array("*", "FROM" => "?", "WHERE" => "id = ?"), $sso_db_apikeys, $row->apikey_id);
         if ($apirow === false) {
             return false;
         }
         $this->info["apirow"] = $apirow;
     } catch (Exception $e) {
         SSO_DisplayError("A database error has occurred.  Most likely cause:  Bad SQL query.");
     }
     // Set a cookie so future requests succeed.
     if (!isset($_COOKIE["sso_remote_id"])) {
         SetCookieFixDomain("sso_remote_id", $_REQUEST["sso_remote_id"], 0, "", "", SSO_IsSSLRequest(), true);
     }
     return true;
 }
Пример #5
0
SSO_LoadFields(false);
// Load in $sso_settings and initialize it.
SSO_LoadSettings();
// Simply bail with a generic message if a SQL query fails.
try {
    // Load the API key information.
    $sso_apirow = $sso_db->GetRow("SELECT", array("*", "FROM" => "?", "WHERE" => "id = ? AND apikey = ?"), $sso_db_apikeys, $apikey[1], $apikey[0]);
    if ($sso_apirow === false) {
        SSO_EndpointError("Invalid API key specified.");
    }
    $sso_apikey_info = unserialize($sso_apirow->info);
    if (!isset($sso_apikey_info["type"])) {
        $sso_apikey_info["type"] = "normal";
    }
    // Check the IP address against API key patterns.
    if (!SSO_IsIPAllowed($sso_apikey_info)) {
        SSO_EndpointError("Invalid API key IP address.");
    }
    // Decrypt the data packet using the secret key.
    $sso_data = @base64_decode(str_replace(array("-", "_"), array("+", "/"), $_REQUEST["data"]));
    if ($sso_data === false) {
        SSO_EndpointError("Unable to decode data packet.");
    }
    $sso_apikey_info["keyinfo"] = array("mode" => "", "key" => "", "opts" => array("mode" => "CBC"));
    if (strpos($sso_apikey_info["key"], ":") === false) {
        $sso_apikey_info["keyinfo"]["mode"] = "blowfish";
        $sso_apikey_info["keyinfo"]["key"] = pack("H*", substr($sso_apikey_info["key"], 0, -16));
        $sso_apikey_info["keyinfo"]["opts"]["iv"] = pack("H*", substr($sso_apikey_info["key"], -16));
    } else {
        $info = explode(":", $sso_apikey_info["key"]);
        if (count($info) < 3) {