$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getInstance();
$metaconfig = SimpleSAML_Configuration::getConfig('module_virtualorg.php');
$authsource = $metaconfig->getValue('auth', 'login-admin');
$useridattr = $metaconfig->getValue('useridattr', 'eduPersonPrincipalName');
if ($session->isValid($authsource)) {
    $attributes = $session->getAttributes();
    // Check if userid exists
    if (!isset($attributes[$useridattr])) {
        throw new Exception('User ID is missing');
    }
    $userid = $attributes[$useridattr][0];
} else {
    SimpleSAML_Auth_Default::initLogin($authsource, SimpleSAML_Utilities::selfURL());
}
$vos = new sspmod_virtualorg_VOStorage();
if (!isset($_REQUEST['id'])) {
    throw new Exception('VO ID not provided.');
}
if (!isset($_REQUEST['token'])) {
    throw new Exception('VO register token not provided.');
}
$id = $_REQUEST['id'];
# echo ('<pre>'); print_r($attributes); exit;
$insertAttributes = array('displayName' => $attributes['cn'], 'mail' => $attributes['mail'], 'o' => $attributes['o']);
$vometa = $vos->getVO($id);
$token = sha1($metaconfig->getValue('secret') . '|' . $id . '|' . $vometa['secret']);
if ($_REQUEST['token'] !== $token) {
    throw new Exception('VO Registration token was invalid.');
}
$membership = $vos->getVOmembership($id, $userid);
<?php

/* Load simpleSAMLphp, configuration and metadata */
$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getInstance();
$metaconfig = SimpleSAML_Configuration::getConfig('module_virtualorg.php');
$authsource = $metaconfig->getValue('auth', 'login-admin');
$useridattr = $metaconfig->getValue('useridattr', 'eduPersonPrincipalName');
if ($session->isValid($authsource)) {
    $attributes = $session->getAttributes();
    // Check if userid exists
    if (!isset($attributes[$useridattr])) {
        throw new Exception('User ID is missing');
    }
    $userid = $attributes[$useridattr][0];
} else {
    SimpleSAML_Auth_Default::initLogin($authsource, SimpleSAML_Utilities::selfURL());
}
$vos = new sspmod_virtualorg_VOStorage();
// $vos->addVO('foobar', 'GEANT3 JRA2', 'Identity Federation group', '*****@*****.**', 'secret123');
// $vos->addMembership('foobar', '*****@*****.**', json_encode($attributes));
//
// $attributes['o'] = array('GEANT', 'JRA3T2');
// $vos->updateMembership('foobar', '*****@*****.**', json_encode($attributes));
$volist = $vos->getVOlist($userid);
// $vomembership = $vos->getVOmembership('foobar', '*****@*****.**');
$template = new SimpleSAML_XHTML_Template($config, 'virtualorg:volist.php');
$template->data['volist'] = $volist;
$template->data['userid'] = $userid;
$template->show();
$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getInstance();
$metaconfig = SimpleSAML_Configuration::getConfig('module_virtualorg.php');
$authsource = $metaconfig->getValue('auth', 'login-admin');
$useridattr = $metaconfig->getValue('useridattr', 'eduPersonPrincipalName');
if ($session->isValid($authsource)) {
    $attributes = $session->getAttributes();
    // Check if userid exists
    if (!isset($attributes[$useridattr])) {
        throw new Exception('User ID is missing');
    }
    $userid = $attributes[$useridattr][0];
} else {
    SimpleSAML_Auth_Default::initLogin($authsource, SimpleSAML_Utilities::selfURL());
}
$vos = new sspmod_virtualorg_VOStorage();
if (!isset($_REQUEST['id'])) {
    throw new Exception('VO ID not provided.');
}
if (!isset($_REQUEST['userid'])) {
    throw new Exception('User ID not provided.');
}
$id = $_REQUEST['id'];
$edituser = $_REQUEST['userid'];
$vometa = $vos->getVO($id);
if ($vometa['owner'] !== $userid) {
    throw new Exception('You are not the owner of this VO and cannot edit attributes.');
}
$vomembership = $vos->getVOmembership($id, $edituser);
$voattributes = json_decode($vomembership['attributes'], TRUE);
if (isset($_POST['type']) && $_POST['type'] === 'edit') {
Exemplo n.º 4
0
$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getInstance();
$metaconfig = SimpleSAML_Configuration::getConfig('module_virtualorg.php');
$authsource = $metaconfig->getValue('auth', 'login-admin');
$useridattr = $metaconfig->getValue('useridattr', 'eduPersonPrincipalName');
if ($session->isValid($authsource)) {
    $attributes = $session->getAttributes();
    // Check if userid exists
    if (!isset($attributes[$useridattr])) {
        throw new Exception('User ID is missing');
    }
    $userid = $attributes[$useridattr][0];
} else {
    SimpleSAML_Auth_Default::initLogin($authsource, SimpleSAML_Utilities::selfURL());
}
$vos = new sspmod_virtualorg_VOStorage();
if (!isset($_REQUEST['id'])) {
    throw new Exception('VO ID not provided.');
}
$id = $_REQUEST['id'];
if (isset($_POST['type']) && $_POST['type'] === 'createnew') {
    if (!isset($_POST['name'])) {
        throw new Exception('VO name not provided.');
    }
    $name = $_POST['name'];
    if (!isset($_POST['descr'])) {
        throw new Exception('VO descr not provided.');
    }
    $descr = $_POST['descr'];
    $secret = SimpleSAML_Utilities::generateID();
    $vos->addVO($id, $name, $descr, $userid, $secret);
<?php

/*
 * OAuth section
 */
$config = SimpleSAML_Configuration::getInstance();
require_once $config->resolvePath('modules/oauth/libextinc/OAuth.php');
$oauthconfig = SimpleSAML_Configuration::getConfig('module_oauth.php');
$store = new sspmod_oauth_OAuthStore();
$server = new sspmod_oauth_OAuthServer($store);
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
$plaintext_method = new OAuthSignatureMethod_PLAINTEXT();
$server->add_signature_method($hmac_method);
$server->add_signature_method($plaintext_method);
$req = OAuthRequest::from_request();
list($consumer, $token) = $server->verify_request($req);
$data = $store->getAuthorizedData($token->key);
/*
 * -----------
 */
$metaconfig = SimpleSAML_Configuration::getConfig('module_virtualorg.php');
$vos = new sspmod_virtualorg_VOStorage();
#if (!isset($_REQUEST['method'])) throw new Exception('Method parameter not provided');
#if ($method === 'memberOf') {
$memberof = $vos->getVOmemberships($data['eduPersonPrincipalName'][0]);
echo json_encode($memberof);
exit;
#}