<?php

require_once dirname(dirname(__FILE__)) . '/libextinc/OAuth.php';
$oauthconfig = SimpleSAML_Configuration::getConfig('module_oauth.php');
if (!$oauthconfig->getBoolean('getUserInfo.enable', FALSE)) {
    throw new Exception('Get user info endpoint is disabled. This endpoint can be enabled in the module_oauth.php configuration file.');
}
$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);
echo json_encode($data);
Beispiel #2
0
<?php

require_once dirname(dirname(__FILE__)) . '/libextinc/OAuth.php';
try {
    $store = new sspmod_oauth_OAuthStore();
    $server = new sspmod_oauth_OAuthServer($store);
    $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
    $plaintext_method = new OAuthSignatureMethod_PLAINTEXT();
    $rsa_method = new sspmod_oauth_OAuthSignatureMethodRSASHA1();
    $server->add_signature_method($hmac_method);
    $server->add_signature_method($plaintext_method);
    $server->add_signature_method($rsa_method);
    $req = OAuthRequest::from_request();
    $requestToken = $req->get_parameter('oauth_token');
    $verifier = $req->get_parameter("oauth_verifier");
    if ($verifier == null) {
        $verifier = '';
    }
    if (!$store->isAuthorized($requestToken, $verifier)) {
        throw new Exception('Your request was not authorized. Request token [' . $requestToken . '] not found.');
    }
    $accessToken = $server->fetch_access_token($req);
    $data = $store->moveAuthorizedData($requestToken, $verifier, $accessToken->key);
    echo $accessToken;
} catch (Exception $e) {
    header('Content-type: text/plain; utf-8', TRUE, 500);
    header('OAuth-Error: ' . $e->getMessage());
    print_r($e);
}
Beispiel #3
0
<?php

require_once dirname(dirname(__FILE__)) . '/libextinc/OAuth.php';
if (!array_key_exists('oauth_token', $_REQUEST)) {
    throw new Exception('Required URL parameter [oauth_token] is missing.');
}
$requestToken = $_REQUEST['oauth_token'];
$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);
$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getInstance();
$as = 'saml2';
if (!$session->isValid($as)) {
    SimpleSAML_Auth_Default::initLogin($as, SimpleSAML_Utilities::selfURL());
}
$attributes = $session->getAttributes();
#print_r($attributes);
$store->authorize($requestToken, $attributes);
if (isset($_REQUEST['oauth_callback'])) {
    SimpleSAML_Utilities::redirect($_REQUEST['oauth_callback']);
} else {
    $t = new SimpleSAML_XHTML_Template($config, 'oauth:authorized.php');
    $t->data['header'] = '{status:header_saml20_sp}';
    $t->data['remaining'] = $session->remainingTime();
    $t->data['sessionsize'] = $session->getSize();
    $t->data['attributes'] = $attributes;
    $t->data['logouturl'] = SimpleSAML_Utilities::selfURLNoQuery() . '?logout';
<?php

require_once dirname(dirname(__FILE__)) . '/libextinc/OAuth.php';
try {
    $store = new sspmod_oauth_OAuthStore();
    $server = new sspmod_oauth_OAuthServer($store);
    $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
    $plaintext_method = new OAuthSignatureMethod_PLAINTEXT();
    $rsa_method = new sspmod_oauth_OAuthSignatureMethodRSASHA1();
    $server->add_signature_method($hmac_method);
    $server->add_signature_method($plaintext_method);
    $server->add_signature_method($rsa_method);
    $req = OAuthRequest::from_request();
    $token = $server->fetch_request_token($req, null, $req->get_version());
    // OAuth1.0-revA adds oauth_callback_confirmed to token
    echo $token;
    if ($req->get_version() == '1.0a') {
        echo "&oauth_callback_confirmed=true";
    }
} catch (Exception $e) {
    header('Content-type: text/plain; utf-8', TRUE, 500);
    header('OAuth-Error: ' . $e->getMessage());
    print_r($e);
}
Beispiel #5
0
<?php

require_once dirname(dirname(__FILE__)) . '/libextinc/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();
$token = $server->fetch_request_token($req);
echo $token;