示例#1
0
$config = get_config('auth/teosso');
if ($logout) {
    // log the session out - redirect to special Intel logout URL
    auth_plugin_teosso::err('in logout sequence');
    require_logout();
    redirect($config->signout_url);
} elseif (!isloggedin() && isguestuser()) {
    // not sure if we need this one... guest user to be treated differently?
    auth_plugin_teosso::err('in guest user login sequence');
} elseif (!isloggedin()) {
    // initiate login sequence - redirect to special login link for Intel
    auth_plugin_teosso::err('in login sequence');
    teosso_authenticate_user();
} else {
    // is logged in - go back to the main site page
    auth_plugin_teosso::err('allready logged in');
    header('Location: ' . $CFG->wwwroot);
}
// parse out the TEO SSO authentication header, and process the login
//SM_USER = <cpm><acct_id>123456</acct_id><acct_name>hoang</acct_name><email>hoang.m.nguyen@intel.com</email>
//          <firstn>Hoang</firstn><lastn>Nguyen</lastn></cpm>
function teosso_authenticate_user()
{
    global $CFG, $USER, $SESSION;
    $pluginconfig = get_config('auth/teosso');
    // retrieve the login data from the HTTP Headers
    $attributes = auth_plugin_teosso::get_sso_attributes();
    // check to see if we got any authentication data
    if (empty($attributes)) {
        redirect($pluginconfig->signin_url);
    }
示例#2
0
 static function get_sso_attributes()
 {
     $attribute_list = array('acct_id' => 'idnumber', 'acct_name' => 'username', 'email' => 'email', 'firstn' => 'firstname', 'lastn' => 'lastname');
     $attribute_list = array('field_map_username', 'field_map_firstname', 'field_map_lastname', 'field_map_email', 'field_map_idnumber');
     // get the config again as this is a static call
     $pluginconfig = get_config('auth/teosso');
     //retrieve the login data from the HTTP Headers
     $headers = apache_request_headers();
     foreach ($headers as $header => $value) {
         auth_plugin_teosso::err("{$header}: {$value}");
     }
     $attributes = array();
     foreach ($attribute_list as $attribute) {
         if (isset($headers[$pluginconfig->{$attribute}])) {
             $attributes[$pluginconfig->{$attribute}] = $headers[$pluginconfig->{$attribute}];
         }
     }
     foreach ($attributes as $key => $value) {
         auth_plugin_teosso::err("{$key} => {$value}");
     }
     return $attributes;
 }