示例#1
0
function doAuth($info, $trusted = null, $fail_cancels = false, $idpSelect = null)
{
    if (!$info) {
        // There is no authentication information, so bail
        return authCancel(null);
    }
    if ($info->idSelect()) {
        if ($idpSelect) {
            $req_url = idURL($idpSelect);
        } else {
            $trusted = false;
        }
    } else {
        $req_url = $info->identity;
    }
    $user = getLoggedInUser();
    setRequestInfo($info);
    if (!$info->idSelect() && $req_url != idURL($user)) {
        return login_render(array(), $req_url, $req_url);
    }
    $trust_root = $info->trust_root;
    if ($trusted) {
        setRequestInfo();
        $server =& getServer();
        $response =& $info->answer(true, null, $req_url);
        // Answer with some sample Simple Registration data.
        global $portal_cert_file;
        global $portal_private_key_file;
        $geni_user = geni_loadUser();
        $sreg_data = array();
        if ($geni_user) {
            $sreg_data['nickname'] = $geni_user->username;
            $sreg_data['email'] = $geni_user->email();
        }
        if (empty($sreg_data)) {
            error_log("OpenID: Unable to access user information.");
        }
        /*
        $sreg_data = array(
                           'fullname' => 'Example User',
                           'nickname' => 'example',
                           'dob' => '1970-01-01',
                           'email' => '*****@*****.**',
                           'gender' => 'F',
                           'postcode' => '12345',
                           'country' => 'ES',
                           'language' => 'eu',
                           'timezone' => 'America/New_York');
        */
        // Add the simple registration response values to the OpenID
        // response message.
        $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
        $sreg_response = Auth_OpenID_SRegResponse::extractResponse($sreg_request, $sreg_data);
        $sreg_response->toMessage($response->fields);
        // Generate a response to send to the user agent.
        $webresponse =& $server->encodeResponse($response);
        $new_headers = array();
        foreach ($webresponse->headers as $k => $v) {
            $new_headers[] = $k . ": " . $v;
        }
        return array($new_headers, $webresponse->body);
    } elseif ($fail_cancels) {
        return authCancel($info);
    } else {
        return trust_render($info);
    }
}
//  wireless_operations?operation=enable&project_name=X&project_id=XID
//    enable project X for wireless operations
//
//  wireless_operations?operation=disable&project_name=X&project_id=XID
//    disable project X for wireless operations
//
?>

<?php 
require_once 'user.php';
require_once 'sr_constants.php';
require_once 'sr_client.php';
require_once "pa_client.php";
require_once "pa_constants.php";
require_once "response_format.php";
$user = geni_loadUser();
if (!isset($user) || is_null($user) || !$user->isActive()) {
    relative_redirect('home.php');
}
$ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
$sa_url = get_first_service_of_type(SR_SERVICE_TYPE::SLICE_AUTHORITY);
// Invoke geni-sync-wireless tool on given project
function sync_object($object_type, $object_name)
{
    # Should only provide error information on stderr: put stdout to syslog
    $cmd = "geni-sync-wireless {$object_type} {$object_name}";
    error_log("SYNC(cmd) " . $cmd);
    $descriptors = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    $process = proc_open($cmd, $descriptors, $pipes);
    $std_output = stream_get_contents($pipes[1]);
    # Should be empty
示例#3
0
function show_header($title, $load_user = 1, $show_cards = false)
{
    global $in_maintenance_mode;
    global $in_lockdown_mode;
    global $has_maintenance_alert;
    global $maintenance_alert;
    global $user;
    if ($load_user) {
        global $user;
        if (!isset($user)) {
            $user = geni_loadUser();
        }
        check_km_authorization($user);
        record_last_seen($user, $_SERVER['REQUEST_URI']);
    }
    show_html_head($title);
    echo '<body>';
    echo '<script>';
    // For header interactivity
    echo '$(document).ready(function(){';
    echo '$(".has-sub").hover(function(){ $(this).find(\'ul\').show(); }, function(){ $(this).find(\'ul\').hide(); });';
    echo '$("#hamburger").click(function(){';
    echo '$("#dashboardtools").slideToggle();';
    echo '});';
    echo '});';
    echo '</script>';
    echo '<div id="dashboardheader">';
    echo '<img id="globe" src="/images/geni_globe.png" alt="Geni Logo" style="height:45px; margin-left: 20px; float: left;"/>';
    echo '<img id="hamburger" src="/images/menu.png" alt="optionsicon" style="height:20px; width: 20px; padding:15px; float: left;"/>';
    echo '<h2 class="dashtext" style="float: left; line-height: 50px; text-align: center; margin: 0 20px; display: inline; height: 50px; cursor: pointer;" 
          onclick="window.location=\'dashboard.php\'">GENI Portal</h2>';
    echo '<ul id="dashboardtools" class="floatright" style="vertical-align: top;">';
    if ($load_user) {
        echo "<li class='has-sub headerlink'>{$user->prettyName()}";
    } else {
        echo "<li class='has-sub headerlink'>User";
    }
    echo '<ul class="submenu">';
    echo '<li><a href="profile.php">Profile</a></li>';
    echo '<li><a href="profile.php#ssh">SSH Keys</a></li>';
    echo '<li><a href="profile.php#rspecs">RSpecs</a></li>';
    echo '<li><a href="profile.php#tools">Manage Accounts</a></li>';
    echo '<li><a href="profile.php#preferences">Preferences</a></li>';
    echo '<li><a href="' . relative_url("dologout.php") . '" >Logout</a></li>';
    if ($load_user && $user->isAllowed(CS_ACTION::ADMINISTER_MEMBERS, CS_CONTEXT_TYPE::MEMBER, null)) {
        echo '<li><a href="admin.php">Admin</a></li>';
    }
    echo '</ul></li>';
    echo '<li class="headerlink has-sub"><a href="help.php">Help</a>';
    echo '<ul class="submenu">';
    echo '<li><a target="_blank" href="http://groups.geni.net/geni/wiki">GENI Wiki <i class="material-icons">launch</i></a></li>';
    echo '<li><a target="_blank" href="http://groups.geni.net/geni/wiki/GENIExperimenter/GetHelp">GENI Help Wiki <i class="material-icons">launch</i></a></li>';
    echo '<li><a target="_blank" href="http://gmoc.grnoc.iu.edu/gmoc/index/support/gmoc-operations-calendars.html">Outages <i class="material-icons">launch</i> </a></li>';
    echo '<li><a target="_blank" href="http://groups.geni.net/geni/wiki/GENIGlossary">Glossary <i class="material-icons">launch</i></a></li>';
    echo '<li><a target="_blank" href="http://groups.geni.net/geni/wiki/GENIBibliography">Bibliography<i class="material-icons">launch</i></a></li>';
    echo '<li><a href="contact-us.php">Contact Us</a></li>';
    echo '</ul></li>';
    if ($load_user) {
        if (!isset($jfed_button_start)) {
            $jfedret = get_jfed_strs($user);
            $jfed_script_text = $jfedret[0];
            $jfed_button_start = $jfedret[1];
            $jfed_button_part2 = $jfedret[2];
            if (!is_null($jfed_button_start)) {
                print $jfed_script_text;
            }
        }
    }
    echo '<li class="headerlink has-sub">Partners';
    echo '<ul class="submenu">';
    echo "<li><a href='https://www.cloudlab.us/login.php' target='_blank'>CloudLab <i class='material-icons'>launch</i></a></li>";
    echo "<li><a href='http://gee-project.org/user' target='_blank'>GEE <i class='material-icons'>launch</i></a></li>";
    echo "<li><a href='wireless_redirect.php?site=ORBIT' target='_blank'>ORBIT<i class='material-icons'>launch</i></a></li>";
    echo "<li><a href='http://portal.savitestbed.ca/auth/login' target='_blank'>SAVI<i class='material-icons'>launch</i></a></li>";
    echo "<li><a href='wireless_redirect.php?site=WITEST' target='_blank'>WiTest<i class='material-icons'>launch</i></a></li>";
    echo '</ul></li>';
    echo '<li class="headerlink has-sub">Tools';
    echo '<ul class="submenu">';
    echo "<li><a href='gemini.php' target='_blank'>GENI Desktop<i class='material-icons'>launch</i></a></li>";
    if ($load_user && !is_null($jfed_button_start)) {
        echo "<li>";
        echo $jfed_button_start . getjFedSliceScript(NULL) . $jfed_button_part2 . ">jFed<i class='material-icons'>launch</i></button>";
        echo "</li>";
    }
    echo "<li><a href='http://labwiki.casa.umass.edu' target='_blank'>LabWiki <i class='material-icons'>launch</i></a></li>";
    echo "<li><a href='http://groups.geni.net/geni/wiki/GENIExperimenter/Tools' target='_blank' title='Omni, Geni-lib, VTS...'>Other Tools <i class='material-icons'>launch</i></a></li>";
    echo '</ul></li>';
    echo '<li class="headerlink has-sub"><a href="dashboard.php">Home</a>';
    echo '<ul class="submenu">';
    echo '<li><a href="dashboard.php#slices">Slices</a></li>';
    echo '<li><a href="dashboard.php#projects">Projects</a></li>';
    echo '</ul></li></ul>';
    echo '</div>';
    $cards_class = $show_cards ? 'content-cards' : 'one-card';
    echo '<div style="clear:both; height: 50px;">&nbsp;</div>';
    if ($in_maintenance_mode) {
        echo "<center><b>***** Maintenance Outage *****</b></center>";
    }
    if ($has_maintenance_alert) {
        print "<p class='instruction' id='maintenance_alert'>{$maintenance_alert}</p>";
    }
    echo "<div id='content-outer' class='{$cards_class}'>";
    echo "<div id='content'>";
}
function do_security_check($slice_id)
{
    $user = geni_loadUser();
    if (!isset($user) || is_null($user) || !$user->isActive()) {
        exit_with_response("User not logged in.");
    }
    if (!$user->isAllowed(SA_ACTION::LOOKUP_SLICE, CS_CONTEXT_TYPE::SLICE, $slice_id)) {
        exit_with_response("User " . $user->username . " not allowed to access this slice's information.");
    }
}
示例#5
0
// Test procedure for request infrastructure for SA, PA, MA
require_once 'util.php';
require_once 'rq_constants.php';
require_once 'rq_client.php';
require_once 'response_format.php';
require_once 'sr_constants.php';
require_once 'sr_client.php';
require_once 'pa_client.php';
require_once 'sa_client.php';
require_once 'cs_constants.php';
require_once 'user.php';
error_log("RQ TEST\n");
$sr_url = get_sr_url();
$sa_url = get_first_service_of_type(SR_SERVICE_TYPE::SLICE_AUTHORITY);
$ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
$signer = geni_loadUser();
function dump_rows($rows)
{
    foreach ($rows as $row) {
        dump_row($row);
    }
}
function dump_row($row)
{
    error_log("Row = " . print_r($row, true));
}
function test_requests_for_url($url, $context_type, $context_id)
{
    global $signer;
    $insert_result = create_request($url, $signer, $context_type, $context_id, RQ_REQUEST_TYPE::JOIN, 'foobar', '');
    error_log("IR = " . print_r($insert_result, true));
示例#6
0
function get_jfed_strs($user)
{
    global $portal_jquery_url;
    global $portal_jqueryui_css_url;
    global $portal_jqueryui_js_url;
    $jfed_button_start = null;
    $jfed_script_text = '';
    $jfed_button_part2 = '';
    $certkey = '';
    $browser = getBrowser();
    if (strpos(strtolower($browser["name"]), "chrom") !== false and strpos(strtolower($browser["platform"]), "mac") === 0) {
        //error_log("User browser: " . $browser["name"] . " version " . $browser["version"] . " on " . $browser["platform"]);
        // While interesting, this message appears every time a Chrome on Mac user displays this page. Too much.
        //error_log("User running Chrome on Mac. Can't launch jFed. User should try Safari or Firefox.");
        $jfed_button_start = "<button type='button' onclick='alert(\"jFed cannot run in Chrome on a Mac. Try Safari or Firefox.\")'";
        return array($jfed_script_text, $jfed_button_start, '');
    }
    if (!isset($user)) {
        $user = geni_loadUser();
    }
    if (!isset($ma_url)) {
        $ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
        if (!isset($ma_url) || is_null($ma_url) || $ma_url == '') {
            error_log("Found no MA in SR!'");
            return array('', null);
        }
    }
    // Code to set up jfed button
    $certresult = ma_lookup_certificate($ma_url, $user, $user->account_id);
    $expiration_key = 'expiration';
    $has_certificate = False;
    $has_key = False;
    $expired = False;
    $expiration = NULL;
    if (!is_null($certresult)) {
        $has_certificate = True;
        $has_key = array_key_exists(MA_ARGUMENT::PRIVATE_KEY, $certresult);
        if (array_key_exists($expiration_key, $certresult)) {
            $expiration = $certresult[$expiration_key];
            $now = new DateTime('now', new DateTimeZone("UTC"));
            $expired = $expiration < $now;
        }
    }
    if (!$has_certificate or $expired) {
        $jfed_button_start = "<button type='button' onclick='alert(\"Generate an SSL (Omni) key pair to use jFed.\")'";
        $jfed_button_part2 = '';
    } else {
        // Print the script tags needed
        $params = '';
        if ($has_key) {
            $certstring = $certresult[MA_ARGUMENT::PRIVATE_KEY] . "\n" . $certresult[MA_ARGUMENT::CERTIFICATE];
            $certkey = base64_encode($certstring);
            //      $params = ", params: {'login-certificate-string' : '" . base64_encode($certstring) . "' }";
        }
        $jfed_script_text = "\n        <script>\n        var config = {\n            java8_jnlp: 'http://jfed.iminds.be/jfed-geni-java8.jnlp',\n            java7_jnlp: 'http://jfed.iminds.be/jfed-geni-java7.jnlp'\n        };\n        var certkey = '{$certkey}';\n        //var slice_urn = 'urn:publicid:IDN+ch.geni.net:CHtest+slice+vm1';\n        var slice_urn = ''; // over-ridden in the onclick of the jFed button with the specific slice URN. launchjFed() uses this global. Tom says Gross!\n        </script>\n        <script src=\"//java.com/js/dtjava.js\"></script>\n        <script src='https://authority.ilabt.iminds.be/js/jfed_webstart_geni.js'></script>\n<div id='java7Dialog' title=\"Old Java version detected\" style=\"display: none\">\n<p>The latest version of jFed is only compatible with Java 8 or higher. We detected that you are using an older version.</p>\n<p>Please upgrade to Java 8 to get access to the newest version of jFed. Otherwise, you can use jFed 5.3.2, which is Java 7-compatible.</p>\n</div>\n\n<div id='noJavaDialog' title=\"No Java detected\" style=\"display: none\">\n<p>jFed requires Java to run. We however couldn't detect a Java installation in your browser.</p>\n<p>Please install the latest version of Java to continue.</p>\n</div>\n";
        // Brecht has id of 'start'
        $jfed_button_start = "<button id='jfed' type='button' onclick='";
        //launchjFed()'";
        $jfed_button_part2 = " launchjFed()'";
    }
    return array($jfed_script_text, $jfed_button_start, $jfed_button_part2);
}
示例#7
0
function send_geni_user($server, $info)
{
    $geni_user = geni_loadUser();
    $req_url = idURL($geni_user->username);
    $response =& $info->answer(true, null, $req_url);
    // Answer with some sample Simple Registration data.
    global $portal_cert_file;
    global $portal_private_key_file;
    $sreg_data = array();
    if ($geni_user) {
        $sreg_data['nickname'] = $geni_user->username;
        $sreg_data['email'] = $geni_user->email();
    }
    if (empty($sreg_data)) {
        error_log("OpenID: Unable to access user information.");
    }
    // Add the simple registration response values to the OpenID
    // response message.
    $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
    $sreg_response = Auth_OpenID_SRegResponse::extractResponse($sreg_request, $sreg_data);
    $sreg_response->toMessage($response->fields);
    /*
     * Attribute Exchange (AX) is an OpenID extension to pass additional
     * attributes. This code was derived by looking at some client
     * examples and the AX code. No server-side examples of PHP OpenID
     * AX were found.
     *
     * AX seems to be fragile. Small changes to the code below can
     * result in authentication failures.
     *
     * The user URN has '+' characters but these consistently caused
     * authentication failures in testing. Replacing the '+' with '|'
     * worked, so that is a necessary transformation below.
     */
    $ax_request = Auth_OpenID_AX_FetchRequest::fromOpenIDRequest($info);
    if ($ax_request and !Auth_OpenID_AX::isError($ax_request)) {
        /* error_log("received AX request: " . print_r($ax_request, true)); */
        $ax_response = new Auth_OpenID_AX_FetchResponse();
        add_project_slice_info($geni_user, $projects, $slices);
        foreach ($ax_request->iterTypes() as $ax_req_type) {
            switch ($ax_req_type) {
                case 'http://geni.net/projects':
                    $ax_response->setValues($ax_req_type, $projects);
                    break;
                case 'http://geni.net/slices':
                    $ax_response->setValues($ax_req_type, $slices);
                    break;
                case 'http://geni.net/user/urn':
                    $urn = $geni_user->urn();
                    $urn = str_replace('+', '|', $urn);
                    $ax_response->addValue('http://geni.net/user/urn', $urn);
                    break;
                case 'http://geni.net/user/prettyname':
                    $ax_response->addValue($ax_req_type, $geni_user->prettyName());
                    break;
                case 'http://geni.net/wimax/username':
                case 'http://geni.net/wimax/wimax_username':
                    $wimax_name = null;
                    if (isset($geni_user->ma_member->wimax_username)) {
                        $wimax_name = $geni_user->ma_member->wimax_username;
                    }
                    /* Only send wimax name if it exists. */
                    if ($wimax_name) {
                        $ax_response->addValue($ax_req_type, $wimax_name);
                    }
                    break;
                case 'http://geni.net/irods/username':
                    /* Get the iRODS username. Do we need to respect the
                     * 'irods_enabled' flag?
                     */
                    $irods_username = null;
                    if (isset($geni_user->ma_member->irods_username)) {
                        $irods_username = $geni_user->ma_member->irods_username;
                    }
                    /* Only send it if it exists. */
                    if ($irods_username) {
                        error_log("Returning iRODS username {$irods_username} for user " . $geni_user->urn());
                        $ax_response->addValue($ax_req_type, $irods_username);
                    } else {
                        error_log("No iRODS username in OpenID for user " . $geni_user->urn());
                    }
                    break;
                case 'http://geni.net/irods/zone':
                    /* Get the IRods zone for this user. */
                    $irods_zone = irods_default_zone();
                    /* Only send it if it exists. */
                    if ($irods_zone) {
                        error_log("Returning iRODS zone {$irods_zone} for user " . $geni_user->urn());
                        $ax_response->addValue($ax_req_type, $irods_zone);
                    } else {
                        error_log("No iRODS zone in OpenID for user " . $geni_user->urn());
                    }
                    break;
            }
        }
        $ax_response->toMessage($response->fields);
    }
    // Generate a response to send to the user agent.
    $webresponse =& $server->encodeResponse($response);
    $new_headers = array();
    foreach ($webresponse->headers as $k => $v) {
        $new_headers[] = $k . ": " . $v;
    }
    return array($new_headers, $webresponse->body);
}