function oauth_accept() { require_once dirname(__FILE__) . '/common.inc.php'; require_once dirname(__FILE__) . '/../../../wp-includes/pluggable.php'; @(include_once dirname(__FILE__) . '/../xrds-simple.php'); if (function_exists('register_xrd')) { $xrds = get_option('xrds_simple'); if (!$xrds['oauth']) { register_xrd_service('main', 'OAuth Dummy Service', array('Type' => array(array('content' => 'http://oauth.net/discovery/1.0')), 'URI' => array(array('content' => '#oauth')))); register_xrd('oauth'); register_xrd_service('oauth', 'OAuth Request Token', array('Type' => array(array('content' => 'http://oauth.net/core/1.0/endpoint/request'), array('content' => 'http://oauth.net/core/1.0/parameters/uri-query'), array('content' => 'http://oauth.net/core/1.0/signature/HMAC-SHA1')), 'URI' => array(array('content' => get_bloginfo('wpurl') . '/wp-content/plugins/wp-oauth/request_token.php')))); register_xrd_service('oauth', 'OAuth Authorize Token', array('Type' => array(array('content' => 'http://oauth.net/core/1.0/endpoint/authorize'), array('content' => 'http://oauth.net/core/1.0/parameters/uri-query')), 'URI' => array(array('content' => get_bloginfo('wpurl') . '/wp-content/plugins/wp-oauth/authorize_token.php')))); register_xrd_service('oauth', 'OAuth Access Token', array('Type' => array(array('content' => 'http://oauth.net/core/1.0/endpoint/access'), array('content' => 'http://oauth.net/core/1.0/parameters/uri-query'), array('content' => 'http://oauth.net/core/1.0/signature/HMAC-SHA1')), 'URI' => array(array('content' => get_bloginfo('wpurl') . '/wp-content/plugins/wp-oauth/access_token.php')))); register_xrd_service('oauth', 'OAuth Resources', array('Type' => array(array('content' => 'http://oauth.net/core/1.0/endpoint/resource'), array('content' => 'http://oauth.net/core/1.0/parameters/uri-query'), array('content' => 'http://oauth.net/core/1.0/signature/HMAC-SHA1')))); register_xrd_service('oauth', 'OAuth Static Token', array('Type' => array(array('content' => 'http://oauth.net/discovery/1.0/consumer-identity/static')), 'LocalID' => array(array('content' => 'DUMMYKEY')))); } //end if ! oauth } //end if register_xrd $services = get_option('oauth_services'); $services['Post Comments'] = array('wp-comments-post.php'); $services['Edit and Create Entries and Categories'] = array('wp-app.php'); $store = new OAuthWordpressStore(); global $request, $omb_routes; if (isset($request->action) && in_array($request->action, $omb_routes)) { //$server = new OAuthServer($store); //$sha1_method = new OAuthSignatureMethod_HMAC_SHA1(); //$plaintext_method = new OAuthSignatureMethod_PLAINTEXT(); //$server->add_signature_method($sha1_method); //$server->add_signature_method($plaintext_method); //$req = OAuthRequest::from_request(); //list($consumer, $token) = $server->verify_request($req); //$userid = $store->user_from_token($consumer->key, $token->key); //$authed = get_usermeta($userid, 'oauth_consumers'); //$authed = $authed[$consumer->key]; //if($authed && $authed['authorized']) { // $allowed = false; // foreach($authed as $ends) // if(is_array($ends)) // foreach($ends as $end) // if(strstr($_SERVER['SCRIPT_URI'], $end)) // $allowed = true; // if($allowed) // set_current_user($userid); //}//end if } }
function register_xrd_service($xrd_id, $name, $content, $priority = 10) { $xrd = get_option('xrds_simple'); if (!is_array($xrd[$xrd_id])) { register_xrd($xrd_id); } $xrd[$xrd_id]['services'][$name] = array('priority' => $priority, 'content' => $content); update_option('xrds_simple', $xrd); }
function xrds_page() { register_xrd_service('main', 'AtomPub Service', array('Type' => array(array('content' => 'http://www.w3.org/2007/app')), 'MediaType' => array(array('content' => 'application/atomsvc+xml')), 'URI' => array(array('content' => get_bloginfo('wpurl') . '/wp-app.php/service')))); $xrds = get_option('xrds_simple'); if (!is_array($xrds)) { $xrds = array(); update_option('xrds_simple', $xrds); register_xrd('main'); } echo "<div class=\"wrap\">\n"; echo "<h2>XRDS-Simple XRDs</h2>\n"; if (isset($_REQUEST['delete'])) { unset($xrds[$_REQUEST['xrd_id']]); update_option('xrds_simple', $xrds); echo '<b>XRD deleted!</b>'; } //end if delete if ($_REQUEST['openid_server']) { $types = array(); if (isset($_REQUEST['openid_sreg'])) { $types[] = array('content' => 'http://openid.net/sreg/1.0'); $types[] = array('content' => 'http://openid.net/extensions/sreg/1.1'); } //end if sreg register_xrd_service('main', 'OpenID 2.0', array('Type' => array(array('content' => 'http://specs.openid.net/auth/2.0/signon'), array('content' => 'http://openid.net/signon/1.1')) + $types, 'URI' => array($_REQUEST['openid_server']), 'LocalID' => array($_REQUEST['openid_identifier']), 'openid:Delegate' => array($_REQUEST['openid_identifier']))); $xrds = get_option('xrds_simple'); echo '<b>OpenID delegated!</b>'; } //end if openid_server echo '<ul>'; foreach ($xrds as $key => $data) { echo '<li>' . htmlentities($key) . ' - <form style="display:inline;" method="post" action=""><input type="hidden" name="xrd_id" value="' . htmlentities($key) . '" /><input type="submit" name="delete" value="Delete" /></form></li>'; } //end foreach echo '</ul>'; echo "<h3>Delegate an OpenID</h3>\n"; echo '<form action="" method="post"><div>'; echo '<label for="openid_server">Server URI</label> <input type="text" name="openid_server" id="openid_server" value="' . htmlentities($services['OpenID 2.0']['URI']) . '" /><br />'; echo '<label for="openid_identifier">OpenID URI</label> <input type="text" name="openid_identifier" id="openid_identifier" value="' . htmlentities($services['OpenID 2.0']['LocalID']) . '" /><br />'; echo '<label for="openid_sreg">Simple Registration?</label> <input type="checkbox" name="openid_sreg" id="openid_sreg" checked="checked" /><br />'; echo '<input type="submit" value="Save »" />'; echo '</div></form>'; echo "\n</div>"; }
function oauth_omb_register_services() { global $request; global $db; $Identity =& $db->model('Identity'); $i = $Identity->find($request->id); //register_xrd_service('main', 'OAuth Dummy Service', array( // 'Type' => array( array('content' => 'http://oauth.net/discovery/1.0') ), // 'URI' => array( array('content' => '#oauth' ) ), //) ); //register_xrd_service('main', 'OMB Dummy Service', array( // 'Type' => array( array('content' => 'http://openmicroblogging.org/protocol/0.1') ), // 'URI' => array( array('content' => '#omb' ) ), //) ); register_xrd('oauth'); register_xrd('omb'); if (empty($i->profile)) { $i->set_value('profile', $request->url_for(array('resource' => "_" . $i->id))); $i->set_value('profile_url', $request->url_for(array('resource' => $i->nickname))); $i->save_changes(); } register_xrd_service('omb', 'OMB Post Notice', array('Type' => array(array('content' => OMB_VERSION . '/postNotice')), 'URI' => array(array('content' => $request->url_for('oauth_omb_post'))))); register_xrd_service('omb', 'OMB Update Profile', array('Type' => array(array('content' => OMB_VERSION . '/updateProfile')), 'URI' => array(array('content' => $request->url_for('oauth_omb_update'))))); register_xrd_service('oauth', 'OAuth Request Token', array('Type' => array(array('content' => OAUTH_VERSION . '/endpoint/request'), array('content' => OAUTH_VERSION . '/parameters/auth-header'), array('content' => OAUTH_VERSION . '/parameters/post-body'), array('content' => OAUTH_VERSION . '/signature/HMAC-SHA1')), 'URI' => array(array('content' => $request->url_for('request_token'))), 'LocalID' => array('content' => $i->profile))); register_xrd_service('oauth', 'OAuth Authorize Token', array('Type' => array(array('content' => OAUTH_VERSION . '/endpoint/authorize'), array('content' => OAUTH_VERSION . '/parameters/auth-header'), array('content' => OAUTH_VERSION . '/parameters/post-body'), array('content' => OAUTH_VERSION . '/signature/HMAC-SHA1')), 'URI' => array(array('content' => $request->url_for('oauth_authorize'))))); register_xrd_service('oauth', 'OAuth Access Token', array('Type' => array(array('content' => OAUTH_VERSION . '/endpoint/access'), array('content' => OAUTH_VERSION . '/parameters/auth-header'), array('content' => OAUTH_VERSION . '/parameters/post-body'), array('content' => OAUTH_VERSION . '/signature/HMAC-SHA1')), 'URI' => array(array('content' => $request->url_for('access_token'))))); register_xrd_service('oauth', 'OAuth Resources', array('Type' => array(array('content' => OAUTH_VERSION . '/endpoint/resource'), array('content' => OAUTH_VERSION . '/parameters/auth-header'), array('content' => OAUTH_VERSION . '/parameters/post-body'), array('content' => OAUTH_VERSION . '/signature/HMAC-SHA1')))); //register_xrd_service('oauth', 'OAuth Static Token', array( // 'Type' => array( // array('content' => 'http://oauth.net/discovery/1.0/consumer-identity/static'), // ), // 'LocalID' => array( array('content' => $request->url_for(array('resource'=>'identities','id'=>$request->id )))), //) ); }