Esempio n. 1
0
/**
 * Add XRDS entries for OpenID Server.  Entries added will be highly 
 * dependant on the requested URL and plugin configuration.
 */
function openid_provider_xrds_simple($xrds)
{
    $user = openid_server_requested_user();
    if (!$user && get_option('openid_blog_owner')) {
        $url_parts = parse_url(get_option('home'));
        if ('/' . $url_parts['path'] != $_SERVER['REQUEST_URI'] && !is_admin()) {
            return $xrds;
        }
        if (!defined('OPENID_DISALLOW_OWNER') || !OPENID_DISALLOW_OWNER) {
            $user = get_userdatabylogin(get_option('openid_blog_owner'));
        }
    }
    if ($user) {
        // if user doesn't have capability, bail
        $user_object = new WP_User($user->ID);
        if (!$user_object->has_cap('use_openid_provider')) {
            return $xrds;
        }
        if (get_usermeta($user->ID, 'openid_delegate')) {
            $services = get_usermeta($user->ID, 'openid_delegate_services');
        } else {
            $services = array(0 => array('Type' => array(array('content' => 'http://specs.openid.net/auth/2.0/signon')), 'URI' => trailingslashit(get_option('siteurl')) . '?openid_server=1', 'LocalID' => get_author_posts_url($user->ID)), 1 => array('Type' => array(array('content' => 'http://openid.net/signon/1.1')), 'URI' => trailingslashit(get_option('siteurl')) . '?openid_server=1', 'openid:Delegate' => get_author_posts_url($user->ID)));
        }
    } else {
        $services = array(array('Type' => array(array('content' => 'http://specs.openid.net/auth/2.0/server')), 'URI' => trailingslashit(get_option('siteurl')) . '?openid_server=1', 'LocalID' => 'http://specs.openid.net/auth/2.0/identifier_select'));
    }
    if (!empty($services)) {
        foreach ($services as $index => $service) {
            $name = 'OpenID Provider Service (' . $index . ')';
            $xrds = xrds_add_service($xrds, 'main', $name, $service, $index);
        }
    }
    return $xrds;
}
Esempio n. 2
0
/**
 * Add XRDS entries for OpenID Server.  Entries added will be highly 
 * dependant on the requested URL and plugin configuration.
 */
function openid_provider_xrds_simple($xrds)
{
    global $wp_roles;
    if (!$wp_roles) {
        $wp_roles = new WP_Roles();
    }
    $provider_enabled = false;
    foreach ($wp_roles->role_names as $key => $name) {
        $role = $wp_roles->get_role($key);
        if ($role->has_cap('use_openid_provider')) {
            $provider_enabled = true;
            break;
        }
    }
    if (!$provider_enabled) {
        return $xrds;
    }
    $user = openid_server_requested_user();
    if (!$user && get_option('openid_blog_owner')) {
        $url_parts = parse_url(get_option('home'));
        $script = preg_replace('/index.php$/', '', $_SERVER['SCRIPT_NAME']);
        if ('/' . $url_parts['path'] != $script && !is_admin()) {
            return $xrds;
        }
        if (!defined('OPENID_DISALLOW_OWNER') || !OPENID_DISALLOW_OWNER) {
            $user = get_userdatabylogin(get_option('openid_blog_owner'));
        }
    }
    if ($user) {
        // if user doesn't have capability, bail
        $user_object = new WP_User($user->ID);
        if (!$user_object->has_cap('use_openid_provider')) {
            return $xrds;
        }
        if (get_usermeta($user->ID, 'openid_delegate')) {
            $services = get_usermeta($user->ID, 'openid_delegate_services');
        } else {
            $services = array(0 => array('Type' => array(array('content' => 'http://specs.openid.net/auth/2.0/signon')), 'URI' => trailingslashit(get_option('siteurl')) . '?openid_server=1', 'LocalID' => get_author_posts_url($user->ID)), 1 => array('Type' => array(array('content' => 'http://openid.net/signon/1.1')), 'URI' => trailingslashit(get_option('siteurl')) . '?openid_server=1', 'openid:Delegate' => get_author_posts_url($user->ID)));
        }
    } else {
        $services = array(array('Type' => array(array('content' => 'http://specs.openid.net/auth/2.0/server')), 'URI' => trailingslashit(get_option('siteurl')) . '?openid_server=1', 'LocalID' => 'http://specs.openid.net/auth/2.0/identifier_select'));
    }
    if (!empty($services)) {
        foreach ($services as $index => $service) {
            $name = 'OpenID Provider Service (' . $index . ')';
            $xrds = xrds_add_service($xrds, 'main', $name, $service, $index);
        }
    }
    return $xrds;
}
Esempio n. 3
0
/**
 *
 * @uses apply_filters() Calls 'openid_consumer_return_urls' to collect return_to URLs to be included in XRDS document.
 */
function openid_consumer_xrds_simple($xrds)
{
    if (get_option('openid_xrds_returnto')) {
        // OpenID Consumer Service
        $return_urls = array_unique(apply_filters('openid_consumer_return_urls', array()));
        if (!empty($return_urls)) {
            $xrds = xrds_add_simple_service($xrds, 'OpenID Consumer Service', 'http://specs.openid.net/auth/2.0/return_to', $return_urls);
        }
    }
    if (get_option('openid_xrds_idib')) {
        // Identity in the Browser Login Service
        $xrds = xrds_add_service($xrds, 'main', 'Identity in the Browser Login Service', array('Type' => array(array('content' => 'http://specs.openid.net/idib/1.0/login')), 'URI' => array(array('simple:httpMethod' => 'POST', 'content' => site_url('/wp-login.php', 'login_post')))));
        // Identity in the Browser Indicator Service
        $xrds = xrds_add_simple_service($xrds, 'Identity in the Browser Indicator Service', 'http://specs.openid.net/idib/1.0/indicator', site_url('/') . '?openid_check_login');
    }
    return $xrds;
}
Esempio n. 4
0
/**
 * Contribute the AtomPub Service to XRDS-Simple.
 *
 * @param array $xrds current XRDS-Simple array
 * @return array updated XRDS-Simple array
 */
function xrds_atompub_service($xrds) {
	$xrds = xrds_add_service($xrds, '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' ) ),
		)
	);

	return $xrds;
}
Esempio n. 5
0
 function xrds_simple($xrds)
 {
     $xrds = xrds_add_service($xrds, 'main', 'OpenID Consumer Service', array('Type' => array(array('content' => 'http://specs.openid.net/auth/2.0/return_to')), 'URI' => array(array('content' => trailingslashit(get_option('home'))))));
     $siteurl = function_exists('site_url') ? site_url('/wp-login.php', 'login_post') : get_option('siteurl') . '/wp-login.php';
     $xrds = xrds_add_service($xrds, 'main', 'Identity in the Browser Login Service', array('Type' => array(array('content' => 'http://specs.openid.net/idib/1.0/login')), 'URI' => array(array('simple:httpMethod' => 'POST', 'content' => $siteurl))));
     $xrds = xrds_add_service($xrds, 'main', 'Identity in the Browser Indicator Service', array('Type' => array(array('content' => 'http://specs.openid.net/idib/1.0/indicator')), 'URI' => array(array('content' => trailingslashit(get_option('home')) . '?openid_check_login'))));
     return $xrds;
 }