Ejemplo n.º 1
0
 function _run($consumer, $user_url, $mode, $delegate_url, $fetcher, $store, $immediate)
 {
     global $_Auth_OpenID_consumer_url, $_Auth_OpenID_server_url;
     if (!defined('Auth_OpenID_NO_MATH_SUPPORT')) {
         setConsumerSession($consumer);
     }
     $endpoint = new Auth_OpenID_ServiceEndpoint();
     $endpoint->claimed_id = $user_url;
     $endpoint->server_url = $_Auth_OpenID_server_url;
     $endpoint->local_id = $delegate_url;
     $endpoint->type_uris = array(Auth_OpenID_TYPE_1_1);
     $result = $consumer->begin($endpoint);
     $return_to = $_Auth_OpenID_consumer_url;
     $trust_root = $_Auth_OpenID_consumer_url;
     $redirect_url = $result->redirectURL($trust_root, $return_to, $immediate);
     $parsed = parse_url($redirect_url);
     $qs = $parsed['query'];
     $q = Auth_OpenID_parse($qs);
     $new_return_to = $q['openid.return_to'];
     unset($q['openid.return_to']);
     $expected = array('openid.mode' => $mode, 'openid.identity' => $delegate_url, 'openid.trust_root' => $trust_root);
     if ($consumer->_use_assocs) {
         $expected['openid.assoc_handle'] = $fetcher->assoc_handle;
     }
     $this->assertEquals($expected, $q);
     $this->assertEquals(0, strpos($redirect_url, $_Auth_OpenID_server_url));
     $this->assertEquals(0, strpos($new_return_to, $return_to));
     $parsed = parse_url($new_return_to);
     $query = Auth_OpenID_parse($parsed['query']);
     $query = array_merge($query, array('openid.mode' => 'id_res', 'openid.return_to' => $new_return_to, 'openid.identity' => $delegate_url, 'openid.assoc_handle' => $fetcher->assoc_handle));
     if (!$consumer->_use_assocs) {
         $query['openid.signed'] = 'assoc_handle,mode,signed,identity';
         $query['openid.assoc_handle'] = $fetcher->assoc_handle;
         $query['openid.sig'] = 'fake';
     }
     $message = Auth_OpenID_Message::fromPostArgs($query);
     if ($consumer->_use_assocs) {
         $assoc = $store->getAssociation($_Auth_OpenID_server_url, $fetcher->assoc_handle);
         $message = $assoc->signMessage($message);
     }
     $result = $consumer->complete($message, $result->endpoint, $new_return_to);
     $this->assertEquals(Auth_OpenID_SUCCESS, $result->status);
     $this->assertEquals($result->identity_url, $user_url);
 }
Ejemplo n.º 2
0
 function _run(&$consumer, $user_url, $mode, $delegate_url, &$fetcher, &$store, $immediate)
 {
     global $_Auth_OpenID_consumer_url, $_Auth_OpenID_server_url;
     $endpoint = new Auth_OpenID_ServiceEndpoint();
     $endpoint->identity_url = $user_url;
     $endpoint->server_url = $_Auth_OpenID_server_url;
     $endpoint->delegate = $delegate_url;
     $result = $consumer->begin($endpoint);
     $return_to = $_Auth_OpenID_consumer_url;
     $trust_root = $_Auth_OpenID_consumer_url;
     $redirect_url = $result->redirectURL($trust_root, $return_to, $immediate);
     $parsed = parse_url($redirect_url);
     $qs = $parsed['query'];
     $q = Auth_OpenID_parse($qs);
     $new_return_to = $q['openid.return_to'];
     unset($q['openid.return_to']);
     $expected = array('openid.mode' => $mode, 'openid.identity' => $delegate_url, 'openid.trust_root' => $trust_root);
     if ($consumer->_use_assocs) {
         $expected['openid.assoc_handle'] = $fetcher->assoc_handle;
     }
     $this->assertEquals($expected, $q);
     $this->assertEquals(0, strpos($redirect_url, $_Auth_OpenID_server_url));
     $this->assertEquals(0, strpos($new_return_to, $return_to));
     $query = array('nonce' => $result->return_to_args['nonce'], 'openid.mode' => 'id_res', 'openid.return_to' => $new_return_to, 'openid.identity' => $delegate_url, 'openid.assoc_handle' => $fetcher->assoc_handle);
     if ($consumer->_use_assocs) {
         $assoc = $store->getAssociation($_Auth_OpenID_server_url, $fetcher->assoc_handle);
         $assoc->addSignature(array('mode', 'return_to', 'identity'), $query);
     } else {
         $query['openid.signed'] = 'assoc_handle,sig,signed';
         $query['openid.assoc_handle'] = $fetcher->assoc_handle;
         $query['openid.sig'] = 'fake';
     }
     $result = $consumer->complete($query, $result->endpoint);
     $this->assertEquals($result->status, 'success');
     $this->assertEquals($result->identity_url, $user_url);
 }