Beispiel #1
0
 /**
  * Start the OpenID authentication process.
  *
  * @param string $claimed_url claimed OpenID URL
  * @param action $action OpenID action being performed
  * @param array $arguments array of additional arguments to be included in the 'return_to' URL
  */
 function start_login($claimed_url, $action, $arguments = null)
 {
     global $openid;
     if (empty($claimed_url)) {
         return;
     }
     // do nothing.
     if (!WordPressOpenID_Logic::late_bind()) {
         return;
     }
     // something is broken
     if (null !== $openid_auth_request) {
         $auth_request = $openid_auth_request;
     } else {
         set_error_handler(array('WordPressOpenID_Logic', 'customer_error_handler'));
         $consumer = WordPressOpenID_Logic::getConsumer();
         $auth_request = $consumer->begin($claimed_url);
         restore_error_handler();
     }
     if (null === $auth_request) {
         $openid->error = 'Could not discover an OpenID identity server endpoint at the url: ' . htmlentities($claimed_url);
         if (strpos($claimed_url, '@')) {
             $openid->error .= '<br/>The address you specified had an @ sign in it, but OpenID ' . 'Identities are not email addresses, and should probably not contain an @ sign.';
         }
         $openid->log->debug('OpenIDConsumer: ' . $openid->error);
         return;
     }
     $openid->log->debug('OpenIDConsumer: Is an OpenID url. Starting redirect.');
     // build return_to URL
     $return_to = get_option('home') . '/openid_consumer';
     $auth_request->return_to_args['action'] = $action;
     if (is_array($arguments) && !empty($arguments)) {
         foreach ($arguments as $k => $v) {
             if ($k && $v) {
                 $auth_request->return_to_args[urlencode($k)] = urlencode($v);
             }
         }
     }
     /* If we've never heard of this url before, do attribute query */
     $store =& WordPressOpenID_Logic::getStore();
     if ($store->get_user_by_identity($auth_request->endpoint->identity_url) == NULL) {
         $attribute_query = true;
     }
     if ($attribute_query) {
         // SREG
         $sreg_request = Auth_OpenID_SRegRequest::build(array(), array('nickname', 'email', 'fullname'));
         if ($sreg_request) {
             $auth_request->addExtension($sreg_request);
         }
         // AX
     }
     $_SESSION['oid_return_to'] = $return_to;
     WordPressOpenID_Logic::doRedirect($auth_request, get_option('home'), $return_to);
     exit(0);
 }
Beispiel #2
0
function start_wp_openid()
{
    global $request;
    wp_plugin_include(array('wp-openid'));
    $logic = new WordPressOpenID_Logic(null);
    $logic->activate_plugin();
    if (!WordPressOpenID_Logic::late_bind()) {
        return;
    }
    $redirect_to = '';
    if (!empty($_SESSION['requested_url'])) {
        $redirect_to = $_SESSION['requested_url'];
    }
    $claimed_url = $request->openid_url;
    $consumer = WordPressOpenID_Logic::getConsumer();
    $auth_request = $consumer->begin($claimed_url);
    if (null === $auth_request) {
        trigger_error('OpenID server not found at ' . htmlentities($claimed_url), E_USER_ERROR);
    }
    $return_to = $request->url_for('openid_continue') . '/';
    $store =& WordPressOpenID_Logic::getStore();
    $sreg_request = Auth_OpenID_SRegRequest::build(array(), array('nickname', 'email', 'fullname'));
    $auth_request->addExtension($sreg_request);
    $_SESSION['oid_return_to'] = $return_to;
    WordPressOpenID_Logic::doRedirect($auth_request, $request->protected_url, $return_to);
    exit(0);
}
Beispiel #3
0
 /**
  * Start the OpenID authentication process.
  *
  * @param string $claimed_url claimed OpenID URL
  * @param action $action OpenID action being performed
  * @param array $arguments array of additional arguments to be included in the 'return_to' URL
  */
 function start_login($claimed_url, $action, $arguments = null)
 {
     global $openid;
     if (empty($claimed_url)) {
         return;
     }
     // do nothing.
     if (!WordPressOpenID_Logic::late_bind()) {
         return;
     }
     // something is broken
     $auth_request = WordPressOpenID_Logic::begin_consumer($claimed_url);
     if (null === $auth_request) {
         $openid->action = 'error';
         $openid->message = 'Could not discover an OpenID identity server endpoint at the url: ' . htmlentities($claimed_url);
         if (strpos($claimed_url, '@')) {
             $openid->message .= '<br />It looks like you entered an email address, but it ' . 'was not able to be transformed into a valid OpenID.';
         }
         $openid->log->debug('OpenIDConsumer: ' . $openid->message);
         return;
     }
     $openid->log->debug('OpenIDConsumer: Is an OpenID url. Starting redirect.');
     // build return_to URL
     $return_to = trailingslashit(get_option('home'));
     $auth_request->return_to_args['openid_consumer'] = '1';
     $auth_request->return_to_args['action'] = $action;
     if (is_array($arguments) && !empty($arguments)) {
         foreach ($arguments as $k => $v) {
             if ($k && $v) {
                 $auth_request->return_to_args[urlencode($k)] = urlencode($v);
             }
         }
     }
     /* If we've never heard of this url before, do attribute query */
     $store =& WordPressOpenID_Logic::getStore();
     if ($store->get_user_by_identity($auth_request->endpoint->identity_url) == NULL) {
         $attribute_query = true;
     }
     if ($attribute_query) {
         // SREG
         $sreg_request = Auth_OpenID_SRegRequest::build(array(), array('nickname', 'email', 'fullname'));
         if ($sreg_request) {
             $auth_request->addExtension($sreg_request);
         }
         // AX
     }
     $_SESSION['oid_return_to'] = $return_to;
     WordPressOpenID_Logic::doRedirect($auth_request, get_option('home'), $return_to);
     exit(0);
 }