Exemplo n.º 1
0
    }
    BB_DeleteExpiredUserSessions();
    if (isset($_REQUEST["login_reset"]) && $_REQUEST["login_reset"] == "yes") {
        BB_SetUserPassword($user, $pass);
    }
    require_once ROOT_PATH . "/" . SUPPORT_PATH . "/cookie.php";
    $id = BB_NewUserSession($user, isset($_REQUEST["bbl"]) ? $_REQUEST["bbl"] : "");
    if ($id === false) {
        $id = BB_NewUserSession($user, "");
    }
    if ($id === false) {
        echo "<span class=\"error\">Unable to create session.</span>";
        exit;
    }
    SetCookieFixDomain("bbl", $id, $bb_accounts["sessions"][$id]["expire"], ROOT_URL . "/", "", USE_HTTPS, true);
    SetCookieFixDomain("bbq", "1", $bb_accounts["sessions"][$id]["expire"], ROOT_URL . "/", "");
    ?>
<span class="success">Successfully logged in.</span><br />
<a href="<?php 
    echo htmlspecialchars(BB_GetFullRootURLBase("http"));
    ?>
/">Click here to continue</a>
<script type="text/javascript">
window.location = '<?php 
    echo BB_JSSafe(BB_GetFullRootURLBase("http"));
    ?>
/';
</script>
<?php 
} else {
    ?>
Exemplo n.º 2
0
     echo "OK";
 } else {
     if (isset($_REQUEST["sso_action"]) && $_REQUEST["sso_action"] == "sso_iframe_error") {
         SSO_DisplayError("You have been redirected to this page in order to prevent your web browser from giving away your sign in information to an untrusted third party.  Please contact this web server's admin about this issue as it is possible that this web server has been compromised.  Most likely cause:  An SSO server page was loaded via an embedded iframe.");
     } else {
         if (isset($_REQUEST["sso_action"]) && $_REQUEST["sso_action"] == "sso_redirect") {
             if (!isset($_COOKIE["sso_server_er"]) || !isset($_COOKIE["sso_server_ern"]) || $_COOKIE["sso_server_ern"] !== md5(SSO_FrontendField("external_redirect") . ":" . base64_decode($_COOKIE["sso_server_er"]))) {
                 SSO_DisplayError("Valid redirect expected.  Most likely cause:  Invalid cookies.");
             }
             header("Location: " . base64_decode($_COOKIE["sso_server_er"]));
             SetCookieFixDomain("sso_server_er", "", 0, "", "", SSO_IsSSLRequest(), true);
             SetCookieFixDomain("sso_server_ern", "", 0, "", "", SSO_IsSSLRequest(), true);
             if (isset($_REQUEST["sso_final"]) && $_REQUEST["sso_final"] > 0) {
                 // Delete the temporary session cookies.
                 SetCookieFixDomain("sso_server_id", "", 1, "", "", SSO_IsSSLRequest(), true);
                 SetCookieFixDomain("sso_server_id2", "", 1, "", "", SSO_IsSSLRequest(), true);
             }
         } else {
             if (isset($_REQUEST["sso_action"]) && $_REQUEST["sso_action"] == "sso_validate") {
                 // Load the user account.
                 if (!isset($_COOKIE["sso_server_id2"])) {
                     SSO_DisplayError("New session ID expected.  Most likely cause:  Cookies are disabled or bad provider.");
                 }
                 $sso_session_id2 = explode("-", $_COOKIE["sso_server_id2"]);
                 if (count($sso_session_id2) != 2) {
                     SSO_DisplayError("Invalid session ID specified.");
                 }
                 if (!isset($sso_session_info["new_id"]) || $sso_session_info["new_id"] !== $_COOKIE["sso_server_id2"]) {
                     SSO_DisplayError("The new session ID maps to a different session.  Most likely cause:  Bad provider.");
                 }
                 $sso_sessionrow2 = $sso_db->GetRow("SELECT", array("*", "FROM" => "?", "WHERE" => "id = ? AND session_id = ?"), $sso_db_user_sessions, $sso_session_id2[1], $sso_session_id2[0]);
Exemplo n.º 3
0
 public function LoginAddMap(&$mapinfo, $userrow, &$userinfo, $admin)
 {
     global $sso_rng;
     $info = $this->GetInfo();
     if ($info["cookiekey"] != "" && $info["cookieiv"] != "" && $info["cookiekey2"] != "" && $info["cookieiv2"] != "" && isset($userinfo["sso_antiphish"])) {
         // Set the anti-phishing cookie here.
         $data = base64_encode(Blowfish::CreateDataPacket($userinfo["sso_antiphish"], pack("H*", $info["cookiekey"]), array("prefix" => $sso_rng->GenerateString(), "mode" => "CBC", "iv" => pack("H*", $info["cookieiv"]), "key2" => pack("H*", $info["cookiekey2"]), "iv2" => pack("H*", $info["cookieiv2"]), "lightweight" => true)));
         SetCookieFixDomain("sso_l_ap", $data, time() + 365 * 24 * 60 * 60, "", "", BB_IsSSLRequest(), true);
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 5
0
                                                                                                                                                                                                                                                                BB_PropertyFormLoadError("Unable to flush the cache.", true);
                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                            BB_LoadExtensionsCache();
                                                                                                                                                                                                                                                            $bb_extensions_info["nextcheck"] = 0;
                                                                                                                                                                                                                                                            BB_SaveExtensionsCache();
                                                                                                                                                                                                                                                            BB_PropertyFormLoadError("Successfully flushed the cache.", true);
                                                                                                                                                                                                                                                            BB_RunPluginAction("post_bb_main_edit_site_opt_flush_cache");
                                                                                                                                                                                                                                                        } else {
                                                                                                                                                                                                                                                            if ($_REQUEST["bb_action"] == "bb_main_edit_site_opt_logout") {
                                                                                                                                                                                                                                                                BB_RunPluginAction("pre_bb_main_edit_site_opt_logout");
                                                                                                                                                                                                                                                                if (!BB_LogoutUserSession($bb_account["user"], $_REQUEST["bbl"])) {
                                                                                                                                                                                                                                                                    BB_PropertyFormLoadError("Unable to logout.  Token mismatch.");
                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                require_once ROOT_PATH . "/" . SUPPORT_PATH . "/cookie.php";
                                                                                                                                                                                                                                                                SetCookieFixDomain("bbl", "", 1, ROOT_URL . "/", "", USE_HTTPS, true);
                                                                                                                                                                                                                                                                SetCookieFixDomain("bbq", "", 1, ROOT_URL . "/", "", USE_HTTPS, true);
                                                                                                                                                                                                                                                                ?>
<div class="success"><?php 
                                                                                                                                                                                                                                                                echo htmlspecialchars(BB_Translate("Successfully Logged Out."));
                                                                                                                                                                                                                                                                ?>
</div>
<script type="text/javascript">
window.location.href = Gx__FullURLBaseHTTP;
</script>
<?php 
                                                                                                                                                                                                                                                                BB_RunPluginAction("post_bb_main_edit_site_opt_logout");
                                                                                                                                                                                                                                                            } else {
                                                                                                                                                                                                                                                                if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_main_edit_widgets_attach_widget") {
                                                                                                                                                                                                                                                                    BB_RunPluginAction("pre_bb_main_edit_widgets_attach_widget");
                                                                                                                                                                                                                                                                    if (!isset($_REQUEST["wid"])) {
                                                                                                                                                                                                                                                                        BB_PropertyFormLoadError("Widget ID not specified.");
Exemplo n.º 6
0
function SSO_ValidateUser()
{
    global $sso_rng, $sso_db, $sso_db_user_sessions, $sso_db_temp_sessions, $sso_session_info, $sso_apirow, $sso_sessionrow, $sso_sessionrow2, $sso_ipaddr, $sso_settings;
    try {
        // Browser gets a token representing the new session in the temporary session.
        $sso_session_info["new_id2"] = $sso_rng->GenerateString();
        $sso_db->Query("UPDATE", array($sso_db_temp_sessions, array("info" => serialize($sso_session_info)), "WHERE" => "id = ?"), $sso_sessionrow->id);
        // Validate the session.
        $sso_db->Query("UPDATE", array($sso_db_user_sessions, array("updated" => CSDB::ConvertToDBTime(time()), "info" => serialize(array("validated" => true, "ipaddr" => $sso_ipaddr["ipv6"]))), "WHERE" => "id = ?"), $sso_sessionrow2->id);
        // Build the redirect.
        $redirect = str_replace(array("\r", "\n"), "", base64_decode($sso_session_info["url"]));
        $redirect .= (strpos($redirect, "?") === false ? "?" : "&") . "from_sso_server=1&sso_id=" . urlencode($sso_session_info["new_id2"]) . "&sso_id2=" . urlencode($_REQUEST["sso_id"]);
        // Set the namespace cookie.
        if (isset($sso_settings[""]["namespacekey2"])) {
            $namespaces = SSO_LoadNamespaces(true);
            $namespaces[$sso_apirow->namespace] = $_COOKIE["sso_server_id2"];
            $data = serialize($namespaces);
            $data = base64_encode(Blowfish::CreateDataPacket($data, pack("H*", $sso_settings[""]["namespacekey"]), array("prefix" => $sso_rng->GenerateString(), "mode" => "CBC", "iv" => pack("H*", $sso_settings[""]["namespaceiv"]), "key2" => pack("H*", $sso_settings[""]["namespacekey2"]), "iv2" => pack("H*", $sso_settings[""]["namespaceiv2"]), "lightweight" => true)));
            SetCookieFixDomain("sso_server_ns", $data, 0, "", "", SSO_IsSSLRequest(), true);
        }
        // Set the exposed namespace cookie if the option is enabled.
        if (isset($sso_settings[""]["expose_namespaces"]) && $sso_settings[""]["expose_namespaces"] && isset($sso_settings[""]["namespacekey4"])) {
            $namespaces = SSO_LoadNamespaces(false);
            $namespaces[$sso_apirow->namespace] = $sso_sessionrow2->id;
            $data = serialize($namespaces);
            $data = base64_encode(Blowfish::CreateDataPacket($data, pack("H*", $sso_settings[""]["namespacekey3"]), array("prefix" => $sso_rng->GenerateString(), "mode" => "CBC", "iv" => pack("H*", $sso_settings[""]["namespaceiv3"]), "key2" => pack("H*", $sso_settings[""]["namespacekey4"]), "iv2" => pack("H*", $sso_settings[""]["namespaceiv4"]), "lightweight" => true)));
            $host = str_replace(array("http://", "https://"), "", BB_GetRequestHost());
            SetCookieFixDomain("sso_server_ns2", $data, 0, "/", $host, false, true);
        }
        // Redirect back to the client.
        SSO_ExternalRedirect($redirect, true);
    } catch (Exception $e) {
        // Don't do anything here.  Just catch the database exception and let the code fall through.
        // It should be nearly impossible to get here in the first place.
    }
    return false;
}
Exemplo n.º 7
0
 public function LoginAddMap(&$mapinfo, $userrow, &$userinfo, $admin)
 {
     global $sso_rng, $sso_session_info;
     $info = $this->GetInfo();
     if (!$admin && $info["cookiekey"] != "" && $info["cookieiv"] != "" && $info["cookiekey2"] != "" && $info["cookieiv2"] != "" && isset($sso_session_info["sso_login_remember_me"])) {
         if (!isset($userinfo["sso_remember_me"])) {
             $userinfo["sso_remember_me"] = array();
         }
         if ($sso_session_info["sso_login_remember_me"]["reset"]) {
             $userinfo["sso_remember_me"] = array();
         }
         // Remove expired tokens.
         foreach ($userinfo["sso_remember_me"] as $token => $info2) {
             if (CSDB::ConvertFromDBTime($info2["expires"]) < time()) {
                 unset($userinfo["sso_remember_me"][$token]);
             }
         }
         if ($sso_session_info["sso_login_remember_me"]["numdays"] > 0) {
             $token = $sso_rng->GenerateString();
             $token2 = $sso_rng->GenerateString();
             $salt = $sso_rng->GenerateString();
             $data = $salt . ":" . $token2;
             $passwordinfo = sso_login::HashPasswordInfo($data);
             if ($passwordinfo["success"]) {
                 // Add temporary session data to user information.
                 $userinfo["sso_remember_me"][$token] = array("salt" => $salt, "rounds" => (int) $passwordinfo["rounds"], "hash" => bin2hex($passwordinfo["hash"]), "expires" => CSDB::ConvertToDBTime(time() + $sso_session_info["sso_login_remember_me"]["numdays"] * 24 * 60 * 60), "bypass" => $sso_session_info["sso_login_remember_me"]["bypass"]);
                 // Append user ID and token to the cookie.
                 $info2 = false;
                 if (isset($_COOKIE["sso_l_rme"])) {
                     // Decrypt existing data.
                     $info2 = @base64_decode($_COOKIE["sso_l_rme"]);
                     if ($info2 !== false) {
                         $info2 = Blowfish::ExtractDataPacket($info2, pack("H*", $info["cookiekey"]), array("mode" => "CBC", "iv" => pack("H*", $info["cookieiv"]), "key2" => pack("H*", $info["cookiekey2"]), "iv2" => pack("H*", $info["cookieiv2"]), "lightweight" => true));
                     }
                     if ($info2 !== false) {
                         $info2 = @unserialize($info2);
                     }
                 }
                 if ($info2 === false) {
                     $info2 = array();
                 }
                 $info2[$userrow->id] = array($token, $token2);
                 // Set the Remember Me cookie.
                 $data = base64_encode(Blowfish::CreateDataPacket(serialize($info2), pack("H*", $info["cookiekey"]), array("prefix" => $sso_rng->GenerateString(), "mode" => "CBC", "iv" => pack("H*", $info["cookieiv"]), "key2" => pack("H*", $info["cookiekey2"]), "iv2" => pack("H*", $info["cookieiv2"]), "lightweight" => true)));
                 SetCookieFixDomain("sso_l_rme", $data, time() + $info["maxdays"] * 24 * 60 * 60, "", "", BB_IsSSLRequest(), true);
             }
         }
     }
 }