isSessionAuthenticated() public static method

Checks whether authenticated based on $_SESSION. Useful to avoid server calls.
Since: 0.4.22 by Brendan Arnold
public static isSessionAuthenticated ( ) : boolean
return boolean true if authenticated, false otherwise.
Esempio n. 1
0
function authCAS($config)
{
    require_once dirname(__FILE__) . '/CAS/CAS.php';
    // get module configuration
    $cas_validate = true;
    $cas_version = CAS_VERSION_2_0;
    $cas_language = 'english';
    //    phpCAS::setDebug();
    phpCAS::client($cas_version, $config->cashostname, (int) $config->casport, $config->casbaseuri, false);
    phpCAS::setLang($cas_language);
    error_log("CAS: Entering");
    $check = phpCAS::isSessionAuthenticated();
    phpCAS::forceAuthentication();
    $NetUsername = phpCAS::getUser();
    //this stores their network user id
    error_log("CAS: Exiting {$NetUsername}");
    return $NetUsername;
}
function RWSPLICas($r_usrn, $r_pw, $r_csf)
{
    global $RWSESL3;
    global $RWSSRURL;
    global $RWSCRURL;
    global $RWSECMUL;
    if ($r_csf) {
        return;
    }
    $r_aus = get_enabled_auth_plugins();
    foreach ($r_aus as $r_aun) {
        $r_aup = get_auth_plugin($r_aun);
        if (strcasecmp($r_aup->authtype, RWSCAS) == 0) {
            $r_csp = $r_aup;
            break;
        }
    }
    if (!isset($r_csp)) {
        return;
    }
    if (empty($r_csp->config->hostname)) {
        return;
    }
    if ($r_csp->config->multiauth) {
        $r_auc = RWSGSOpt("authCAS", PARAM_ALPHANUMEXT);
        if ($r_auc === false || strlen($r_auc) == 0) {
            $r_auc = "CAS";
        }
        if (strcasecmp($r_auc, "CAS") != 0) {
            return;
        }
    }
    list($r_v1, $r_v2, $r_v3) = explode(".", phpCAS::getVersion());
    $r_csp->connectCAS();
    if (phpCAS::isSessionAuthenticated()) {
        return;
    }
    $r_rv = RWSGSOpt("version", PARAM_ALPHANUMEXT);
    if ($r_rv === false || strlen($r_rv) == 0) {
        unset($r_bv);
    } else {
        $r_bv = intval($r_rv);
    }
    if (strlen($RWSCRURL) > 0) {
        $r_svu = $RWSCRURL;
    } else {
        $r_svu = RWSGSUrl(false, false);
    }
    $r_svu .= "?rwscas=1";
    if (isset($r_bv)) {
        $r_svu .= "&version=";
        $r_svu .= urlencode($r_bv);
    }
    if ($RWSECMUL || $r_csp->config->multiauth) {
        if (isset($r_usrn)) {
            $r_svu .= "&rwsuser="******"&rwspass="******"?rwscas=2";
        if (isset($r_bv)) {
            $r_cbu .= "&version=";
            $r_cbu .= urlencode($r_bv);
        }
        if ($RWSECMUL || $r_csp->config->multiauth) {
            if (isset($r_usrn)) {
                $r_cbu .= "&rwsuser="******"&rwspass="******"rws");
        if ($r_ckf !== false) {
            $_SESSION['rwscas']['cookiejar'] = $r_ckf;
        }
    }
    $r_liu = phpCAS::getServerLoginURL();
    $r_ch = curl_init();
    curl_setopt($r_ch, CURLOPT_URL, $r_liu);
    curl_setopt($r_ch, CURLOPT_HTTPGET, true);
    curl_setopt($r_ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($r_ch, CURLOPT_HEADER, true);
    curl_setopt($r_ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($r_ch, CURLOPT_FAILONERROR, true);
    curl_setopt($r_ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($r_ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($r_ch, CURLOPT_SSL_VERIFYPEER, false);
    if ($RWSESL3) {
        curl_setopt($r_ch, CURLOPT_SSLVERSION, 3);
    }
    curl_setopt($r_ch, CURLOPT_USERAGENT, "PHP");
    if (isset($r_ckf)) {
        curl_setopt($r_ch, CURLOPT_COOKIEFILE, $r_ckf);
        curl_setopt($r_ch, CURLOPT_COOKIEJAR, $r_ckf);
    }
    $r_rsp = curl_exec($r_ch);
    if ($r_rsp === false) {
        curl_close($r_ch);
        return;
    }
    $r_p = 0;
    while (stripos($r_rsp, "HTTP/", $r_p) === 0) {
        $r_p = stripos($r_rsp, "\r\n\r\n", $r_p);
        if ($r_p === false) {
            break;
        }
        $r_p += 4;
    }
    if ($r_p === 0) {
        $r_hdrs = "";
        $r_hset = "";
        $r_bdy = $r_rsp;
    } else {
        if ($r_p === false) {
            $r_hdrs = $r_rsp;
            $r_hset = explode("\r\n\r\n", $r_hdrs);
            $r_bdy = "";
        } else {
            $r_hdrs = substr($r_rsp, 0, $r_p - 4);
            $r_hset = explode("\r\n\r\n", $r_hdrs);
            $r_bdy = substr($r_rsp, $r_p);
        }
    }
    $r_ac = "";
    $r_lt = "";
    $r_evt_id = "";
    $r_sub = "";
    $r_wrn = "";
    $r_exc = "";
    $r_rst = "";
    $r_p = 0;
    $r_l = strlen($r_bdy);
    $r_st = stripos($r_bdy, "<form ");
    if ($r_st !== false) {
        $r_end = stripos($r_bdy, ">", $r_st);
        if ($r_end === false) {
            $r_end = $r_l;
        }
        $r_p = stripos($r_bdy, "action=\"", $r_st);
        if ($r_p === false || $r_p > $r_end) {
            $r_p = stripos($r_bdy, "action = \"", $r_st);
        }
        if ($r_p === false || $r_p > $r_end) {
            $r_p = stripos($r_bdy, "action=\\'", $r_st);
        }
        if ($r_p === false || $r_p > $r_end) {
            $r_p = stripos($r_bdy, "action = \\'", $r_st);
        }
        if ($r_p !== false && $r_p < $r_end) {
            while ($r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                $r_p++;
            }
            $r_p++;
            $r_st = $r_p;
            while ($r_p < $r_end && $r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                $r_p++;
            }
            $r_end = $r_p;
            $r_ac = substr($r_bdy, $r_st, $r_end - $r_st);
        }
    }
    while (strlen($r_lt) == 0 || strlen($r_evt_id) == 0 || strlen($r_sub) == 0 || strlen($r_wrn) == 0 || strlen($r_exc) == 0 || strlen($r_rst) == 0) {
        $r_nx = stripos($r_bdy, "<input ", $r_p);
        if ($r_nx === false) {
            break;
        }
        $r_st = $r_nx;
        $r_end = stripos($r_bdy, ">", $r_st);
        if ($r_end === false) {
            $r_end = $r_l;
        }
        if (strlen($r_lt) == 0) {
            $r_st = stripos($r_bdy, "name=\"lt\"", $r_nx);
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \"lt\"", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name=\\'lt\\'", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \\'lt\\'", $r_nx);
            }
            if ($r_st !== false && $r_st < $r_end) {
                $r_p = stripos($r_bdy, "value=\"", $r_st);
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \"", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value=\\'", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \\'", $r_st);
                }
                if ($r_p !== false && $r_p < $r_end) {
                    while ($r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_p++;
                    $r_st = $r_p;
                    while ($r_p < $r_end && $r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_end = $r_p;
                    $r_lt = substr($r_bdy, $r_st, $r_end - $r_st);
                }
            }
        }
        if (strlen($r_evt_id) == 0) {
            $r_st = stripos($r_bdy, "name=\"_eventId\"", $r_nx);
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \"_eventId\"", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name=\\'_eventId\\'", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \\'_eventId\\'", $r_nx);
            }
            if ($r_st !== false && $r_st < $r_end) {
                $r_p = stripos($r_bdy, "value=\"", $r_st);
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \"", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value=\\'", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \\'", $r_st);
                }
                if ($r_p !== false && $r_p < $r_end) {
                    while ($r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_p++;
                    $r_st = $r_p;
                    while ($r_p < $r_end && $r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_end = $r_p;
                    $r_evt_id = substr($r_bdy, $r_st, $r_end - $r_st);
                }
            }
        }
        if (strlen($r_sub) == 0) {
            $r_st = stripos($r_bdy, "name=\"submit\"", $r_nx);
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \"submit\"", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name=\\'submit\\'", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \\'submit\\'", $r_nx);
            }
            if ($r_st !== false && $r_st < $r_end) {
                $r_p = stripos($r_bdy, "value=\"", $r_st);
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \"", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value=\\'", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \\'", $r_st);
                }
                if ($r_p !== false && $r_p < $r_end) {
                    while ($r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_p++;
                    $r_st = $r_p;
                    while ($r_p < $r_end && $r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_end = $r_p;
                    $r_sub = substr($r_bdy, $r_st, $r_end - $r_st);
                }
            }
        }
        if (strlen($r_wrn) == 0) {
            $r_st = stripos($r_bdy, "name=\"warn\"", $r_nx);
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \"warn\"", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name=\\'warn\\'", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \\'warn\\'", $r_nx);
            }
            if ($r_st !== false && $r_st < $r_end) {
                $r_p = stripos($r_bdy, "value=\"", $r_st);
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \"", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value=\\'", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \\'", $r_st);
                }
                if ($r_p !== false && $r_p < $r_end) {
                    while ($r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_p++;
                    $r_st = $r_p;
                    while ($r_p < $r_end && $r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_end = $r_p;
                    $r_wrn = substr($r_bdy, $r_st, $r_end - $r_st);
                }
            }
        }
        if (strlen($r_exc) == 0) {
            $r_st = stripos($r_bdy, "name=\"execution\"", $r_nx);
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \"execution\"", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name=\\'execution\\'", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \\'execution\\'", $r_nx);
            }
            if ($r_st !== false && $r_st < $r_end) {
                $r_p = stripos($r_bdy, "value=\"", $r_st);
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \"", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value=\\'", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \\'", $r_st);
                }
                if ($r_p !== false && $r_p < $r_end) {
                    while ($r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_p++;
                    $r_st = $r_p;
                    while ($r_p < $r_end && $r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_end = $r_p;
                    $r_exc = substr($r_bdy, $r_st, $r_end - $r_st);
                }
            }
        }
        if (strlen($r_rst) == 0) {
            $r_st = stripos($r_bdy, "name=\"reset\"", $r_nx);
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \"reset\"", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name=\\'reset\\'", $r_nx);
            }
            if ($r_st === false || $r_st > $r_end) {
                $r_st = stripos($r_bdy, "name = \\'reset\\'", $r_nx);
            }
            if ($r_st !== false && $r_st < $r_end) {
                $r_p = stripos($r_bdy, "value=\"", $r_st);
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \"", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value=\\'", $r_st);
                }
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = stripos($r_bdy, "value = \\'", $r_st);
                }
                if ($r_p !== false && $r_p < $r_end) {
                    while ($r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_p++;
                    $r_st = $r_p;
                    while ($r_p < $r_end && $r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
                        $r_p++;
                    }
                    $r_end = $r_p;
                    $r_rst = substr($r_bdy, $r_st, $r_end - $r_st);
                }
            }
        }
        $r_p = $r_nx + 1;
    }
    if (strlen($r_ac) == 0 || strlen($r_lt) == 0) {
        curl_close($r_ch);
        return;
    }
    if (strlen($r_evt_id) == 0) {
        unset($r_evt_id);
    }
    if (isset($r_evt_id) && strlen($r_sub) == 0) {
        $r_sub = "LOGIN";
    }
    if (strlen($r_wrn) == 0) {
        unset($r_wrn);
    }
    if (strlen($r_exc) == 0) {
        unset($r_exc);
    }
    if (strlen($r_rst) == 0) {
        unset($r_rst);
    }
    if (stripos($r_ac, "http://") !== 0 && stripos($r_ac, "https://") !== 0) {
        if ($r_ac[0] == "/") {
            $r_p = stripos($r_liu, "://");
            if ($r_p !== false) {
                $r_p += 3;
                $r_p = stripos($r_liu, "/", $r_p);
                if ($r_p !== false) {
                    $r_acu = substr($r_liu, 0, $r_p);
                    $r_acu .= $r_ac;
                }
            }
        } else {
            $r_p = stripos($r_liu, "/login?");
            if ($r_p !== false) {
                $r_acu = substr($r_liu, 0, $r_p);
                $r_acu .= "/{$r_ac}";
            }
        }
    } else {
        $r_acu = $r_ac;
    }
    if (!isset($r_acu)) {
        $r_acu = $r_liu;
    }
    $r_psf = "username="******"&password="******"&lt=";
    $r_psf .= urlencode($r_lt);
    $r_psf .= "&service=";
    $r_psf .= urlencode($r_svu);
    if (isset($r_evt_id)) {
        $r_psf .= "&_eventId=";
        $r_psf .= urlencode($r_evt_id);
        $r_psf .= "&submit=";
        $r_psf .= urlencode($r_sub);
    }
    if (isset($r_wrn)) {
        $r_psf .= "&warn=";
        $r_psf .= urlencode($r_wrn);
    }
    if (isset($r_exc)) {
        $r_psf .= "&execution=";
        $r_psf .= urlencode($r_exc);
    }
    if (isset($r_rst)) {
        $r_psf .= "&reset=";
        $r_psf .= urlencode($r_rst);
    }
    curl_setopt($r_ch, CURLOPT_URL, $r_acu);
    curl_setopt($r_ch, CURLOPT_HTTPGET, false);
    curl_setopt($r_ch, CURLOPT_POST, true);
    curl_setopt($r_ch, CURLOPT_POSTFIELDS, $r_psf);
    $r_rsp = curl_exec($r_ch);
    if ($r_rsp === false) {
        curl_close($r_ch);
        return;
    }
    $r_p = 0;
    while (stripos($r_rsp, "HTTP/", $r_p) === 0) {
        $r_p = stripos($r_rsp, "\r\n\r\n", $r_p);
        if ($r_p === false) {
            break;
        }
        $r_p += 4;
    }
    if ($r_p === 0) {
        $r_hdrs = "";
        $r_hset = "";
        $r_bdy = $r_rsp;
    } else {
        if ($r_p === false) {
            $r_hdrs = $r_rsp;
            $r_hset = explode("\r\n\r\n", $r_hdrs);
            $r_bdy = "";
        } else {
            $r_hdrs = substr($r_rsp, 0, $r_p - 4);
            $r_hset = explode("\r\n\r\n", $r_hdrs);
            $r_bdy = substr($r_rsp, $r_p);
        }
    }
    foreach ($r_hset as $r_set) {
        $r_hdrl = explode("\r\n", $r_set);
        foreach ($r_hdrl as $r_hdr) {
            if (stripos($r_hdr, "Location:") !== false) {
                $r_st = stripos($r_hdr, "?ticket=");
                if ($r_st === false) {
                    $r_st = stripos($r_hdr, "&ticket=");
                }
                if ($r_st !== false) {
                    $r_end = stripos($r_hdr, "&", $r_st + 1);
                    if ($r_end === false) {
                        $r_end = strlen($r_hdr);
                    }
                    $r_pm = substr($r_hdr, $r_st + 8, $r_end - $r_st);
                    if ($r_pm !== false && strlen($r_pm) > 0) {
                        $r_tkt = trim(urldecode($r_pm));
                        break;
                    }
                }
            }
        }
        if (isset($r_tkt)) {
            break;
        }
    }
    $r_rurl = "";
    $r_p = 0;
    $r_l = strlen($r_bdy);
    while (strlen($r_rurl) == 0) {
        $r_nx = stripos($r_bdy, "window.location.href", $r_p);
        if ($r_nx === false) {
            $r_nx = stripos($r_bdy, "window.location.replace", $r_p);
        }
        if ($r_nx === false) {
            $r_nx = stripos($r_bdy, "window.location", $r_p);
        }
        if ($r_nx === false) {
            $r_nx = stripos($r_bdy, "window.navigate", $r_p);
        }
        if ($r_nx === false) {
            $r_nx = stripos($r_bdy, "document.location.href", $r_p);
        }
        if ($r_nx === false) {
            $r_nx = stripos($r_bdy, "document.location.URL", $r_p);
        }
        if ($r_nx === false) {
            $r_nx = stripos($r_bdy, "document.location", $r_p);
        }
        if ($r_nx === false) {
            break;
        }
        $r_p = $r_nx;
        while ($r_p < $r_l && $r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
            $r_p++;
        }
        if ($r_p < $r_l) {
            $r_p++;
        }
        $r_st = $r_p;
        while ($r_p < $r_end && $r_bdy[$r_p] != "\"" && $r_bdy[$r_p] != "\\'") {
            $r_p++;
        }
        $r_end = $r_p;
        $r_rurl = substr($r_bdy, $r_st, $r_end - $r_st);
        $r_st = stripos($r_rurl, "?ticket=");
        if ($r_st === false) {
            $r_st = stripos($r_rurl, "&ticket=");
        }
        if ($r_st !== false) {
            $r_end = stripos($r_rurl, "&", $r_st + 1);
            if ($r_end === false) {
                $r_end = strlen($r_rurl);
            }
            $r_pm = substr($r_rurl, $r_st + 8, $r_end - $r_st);
            if ($r_pm !== false && strlen($r_pm) > 0) {
                $r_tkt = trim(urldecode($r_pm));
            }
        }
        if (!isset($r_tkt)) {
            $r_rurl = "";
        }
        $r_p = $r_nx + 1;
    }
    if (strlen($r_rurl) != 0) {
        curl_setopt($r_ch, CURLOPT_URL, $r_rurl);
        curl_setopt($r_ch, CURLOPT_HTTPGET, true);
        curl_setopt($r_ch, CURLOPT_POST, false);
        curl_setopt($r_ch, CURLOPT_POSTFIELDS, "");
        $redir_res = curl_exec($r_ch);
        if ($redir_res !== false) {
            $r_rsp = $redir_res;
            $r_p = 0;
            while (stripos($r_rsp, "HTTP/", $r_p) === 0) {
                $r_p = stripos($r_rsp, "\r\n\r\n", $r_p);
                if ($r_p === false) {
                    break;
                }
                $r_p += 4;
            }
            if ($r_p === 0) {
                $r_hdrs = "";
                $r_hset = "";
                $r_bdy = $r_rsp;
            } else {
                if ($r_p === false) {
                    $r_hdrs = $r_rsp;
                    $r_hset = explode("\r\n\r\n", $r_hdrs);
                    $r_bdy = "";
                } else {
                    $r_hdrs = substr($r_rsp, 0, $r_p - 4);
                    $r_hset = explode("\r\n\r\n", $r_hdrs);
                    $r_bdy = substr($r_rsp, $r_p);
                }
            }
        }
    }
    $r_asu = "";
    $r_psf = "";
    if (strlen($r_asu) != 0) {
        curl_setopt($r_ch, CURLOPT_URL, $r_asu);
        curl_setopt($r_ch, CURLOPT_HTTPGET, false);
        curl_setopt($r_ch, CURLOPT_POST, true);
        curl_setopt($r_ch, CURLOPT_POSTFIELDS, $r_psf);
        $r_ares = curl_exec($r_ch);
        if ($r_ares !== false) {
            $r_rsp = $r_ares;
            $r_p = 0;
            while (stripos($r_rsp, "HTTP/", $r_p) === 0) {
                $r_p = stripos($r_rsp, "\r\n\r\n", $r_p);
                if ($r_p === false) {
                    break;
                }
                $r_p += 4;
            }
            if ($r_p === 0) {
                $r_hdrs = "";
                $r_hset = "";
                $r_bdy = $r_rsp;
            } else {
                if ($r_p === false) {
                    $r_hdrs = $r_rsp;
                    $r_hset = explode("\r\n\r\n", $r_hdrs);
                    $r_bdy = "";
                } else {
                    $r_hdrs = substr($r_rsp, 0, $r_p - 4);
                    $r_hset = explode("\r\n\r\n", $r_hdrs);
                    $r_bdy = substr($r_rsp, $r_p);
                }
            }
        }
    }
    if (!isset($r_tkt)) {
        $r_st = stripos($r_bdy, "<rwscas>");
        if ($r_st !== false) {
            $r_end = stripos($r_bdy, "</rwscas>", $r_st);
            if ($r_end === false) {
                $r_end = strlen($r_hdr);
            }
            $r_p = stripos($r_bdy, "<st>", $r_st);
            if ($r_p !== false && $r_p < $r_end) {
                $r_p += 4;
                $r_st = $r_p;
                $r_p = stripos($r_bdy, "</st>", $r_st);
                if ($r_p === false || $r_p > $r_end) {
                    $r_p = $r_end;
                }
                $r_end = $r_p;
                $r_pm = trim(substr($r_bdy, $r_st, $r_end));
                if (strlen($r_pm)) {
                    $r_tkt = $r_pm;
                }
            }
        }
    }
    curl_close($r_ch);
    if (!isset($r_tkt)) {
        return;
    }
    if (strlen($RWSSRURL) > 0) {
        $r_rurl = $RWSSRURL;
    } else {
        $r_rurl = RWSGSUrl(false, false);
    }
    $r_rurl .= "?rwscas=3";
    if (isset($r_bv)) {
        $r_rurl .= "&version=";
        $r_rurl .= urlencode($r_bv);
    }
    if ($RWSECMUL || $r_csp->config->multiauth) {
        if (isset($r_usrn)) {
            $r_rurl .= "&rwsuser="******"&rwspass="******"&ticket=";
        $r_rurl .= urlencode($r_tkt);
    }
    header("Location: {$r_rurl}");
    exit;
}
Esempio n. 3
0
 public function logout()
 {
     if (phpCAS::isSessionAuthenticated()) {
         if (isset($_SESSION['phpCAS'])) {
             $serialized = serialize($_SESSION['phpCAS']);
         }
         phpCAS::log('Logout requested, but no session data found for user:' . PHP_EOL . $serialized);
     }
     phpCAS::logout();
 }
Esempio n. 4
0
 * Include the Entrada init code.
 */
require_once "init.inc.php";
ob_start("on_checkout");
$PROCEED_TO = isset($_GET["url"]) ? clean_input($_GET["url"], "trim") : (isset($_SERVER["REQUEST_URI"]) ? clean_input($_SERVER["REQUEST_URI"], "trim") : false);
$PATH_INFO = isset($_SERVER["PATH_INFO"]) ? clean_input($_SERVER["PATH_INFO"], array("url", "lowercase")) : "";
$PATH_SEPARATED = explode("/", $PATH_INFO);
/**
 * Process CAS authentication
 */
if (defined("AUTH_ALLOW_CAS") && AUTH_ALLOW_CAS == true) {
    if (!isset($_SESSION["isAuthorized"]) || !(bool) $_SESSION["isAuthorized"]) {
        if ($ACTION == "cas" || isset($_COOKIE[AUTH_CAS_COOKIE])) {
            phpCAS::forceAuthentication();
        }
        if (phpCAS::isSessionAuthenticated()) {
            if (isset($_SESSION[AUTH_CAS_SESSION][AUTH_CAS_ID])) {
                $result = cas_credentials($_SESSION[AUTH_CAS_SESSION][AUTH_CAS_ID]);
                if ($result) {
                    $CAS_AUTHENTICATED = true;
                    $username = $result["username"];
                    $password = $result["password"];
                    $ACTION = "login";
                }
            } else {
                phpCAS::logout(ENTRADA_URL . "?action=cas&state=failed");
            }
        }
        if ($ACTION == "cas" && isset($_GET["state"]) && $_GET["state"] == "failed") {
            add_error("Your login credentials are not recognized.<br /><br />Please contact a system administrator for further information.");
            $ACTION = "login";
Esempio n. 5
0
 public static function isLoggedIn()
 {
     return class_exists("phpCAS") && phpCAS::isSessionAuthenticated();
 }