diff options
-rw-r--r-- | Auth/OpenID/Consumer/Consumer.php | 54 | ||||
-rw-r--r-- | Tests/Auth/OpenID/Consumer.php | 14 |
2 files changed, 24 insertions, 44 deletions
diff --git a/Auth/OpenID/Consumer/Consumer.php b/Auth/OpenID/Consumer/Consumer.php index dce431d..bdabeca 100644 --- a/Auth/OpenID/Consumer/Consumer.php +++ b/Auth/OpenID/Consumer/Consumer.php @@ -273,11 +273,6 @@ class Auth_OpenID_Consumer { var $mode; /** - * A boolean indicating whether the consumer is in immediate mode. - */ - var $immediate; - - /** * This method initializes a new Auth_OpenID_Consumer instance to * access the library. * @@ -306,7 +301,7 @@ class Auth_OpenID_Consumer { * in the module description. The default value is False, which * disables immediate mode. */ - function Auth_OpenID_Consumer(&$store, $fetcher = null, $immediate = false) + function Auth_OpenID_Consumer(&$store, $fetcher = null) { if ($store === null) { trigger_error("Must supply non-null store to create consumer", @@ -324,14 +319,6 @@ class Auth_OpenID_Consumer { } else { $this->fetcher =& $fetcher; } - - if ($immediate) { - $this->mode = 'checkid_immediate'; - } else { - $this->mode = 'checkid_setup'; - } - - $this->immediate = $immediate; } /** @@ -433,7 +420,8 @@ class Auth_OpenID_Consumer { * @return string $url This method returns a string containing the * URL to redirect to when such a URL is successfully constructed. */ - function constructRedirect($auth_request, $return_to, $trust_root) + function constructRedirect($auth_request, $return_to, $trust_root, + $immediate = false) { $assoc = $this->_getAssociation($auth_request->server_url, $replace = 1); @@ -444,8 +432,20 @@ class Auth_OpenID_Consumer { return null; } - return $this->_constructRedirect($assoc, $auth_request, - $return_to, $trust_root); + $mode = $immediate ? 'checkid_immediate' : 'checkid_setup'; + $redir_args = array( + 'openid.identity' => $auth_request->server_id, + 'openid.return_to' => $return_to, + 'openid.trust_root' => $trust_root, + 'openid.mode' => $mode, + ); + + if ($assoc !== null) { + $redir_args['openid.assoc_handle'] = $assoc->handle; + } + + $this->store->storeNonce($auth_request->nonce); + return Auth_OpenID_appendArgs($auth_request->server_url, $redir_args); } /** @@ -535,26 +535,6 @@ class Auth_OpenID_Consumer { /** * @access private */ - function _constructRedirect($assoc, $auth_req, $return_to, $trust_root) - { - $redir_args = array( - 'openid.identity' => $auth_req->server_id, - 'openid.return_to' => $return_to, - 'openid.trust_root' => $trust_root, - 'openid.mode' => $this->mode, - ); - - if ($assoc !== null) { - $redir_args['openid.assoc_handle'] = $assoc->handle; - } - - $this->store->storeNonce($auth_req->nonce); - return Auth_OpenID_appendArgs($auth_req->server_url, $redir_args); - } - - /** - * @access private - */ function _doIdRes($token, $query) { $ret = $this->_splitToken($token); diff --git a/Tests/Auth/OpenID/Consumer.php b/Tests/Auth/OpenID/Consumer.php index 857cb8b..4758a88 100644 --- a/Tests/Auth/OpenID/Consumer.php +++ b/Tests/Auth/OpenID/Consumer.php @@ -151,7 +151,7 @@ $_Auth_OpenID_consumer_url = "http://consumer.example.com/"; class Tests_Auth_OpenID_Consumer extends PHPUnit_TestCase { function _run(&$consumer, $user_url, $mode, $delegate_url, - &$fetcher, &$store) + &$fetcher, &$store, $immediate) { global $_Auth_OpenID_consumer_url, $_Auth_OpenID_server_url; @@ -162,7 +162,7 @@ class Tests_Auth_OpenID_Consumer extends PHPUnit_TestCase { $return_to = $_Auth_OpenID_consumer_url; $trust_root = $_Auth_OpenID_consumer_url; $redirect_url = $consumer->constructRedirect($info, $return_to, - $trust_root); + $trust_root, $immediate); $parsed = parse_url($redirect_url); $qs = $parsed['query']; @@ -230,12 +230,12 @@ class Tests_Auth_OpenID_Consumer extends PHPUnit_TestCase { $_Auth_OpenID_assocs[0][0], $_Auth_OpenID_assocs[0][1]); - $consumer = new Auth_OpenID_TestConsumer($store, &$fetcher, $immediate); + $consumer = new Auth_OpenID_TestConsumer($store, &$fetcher); $expected_num_assocs = 0; $this->assertEquals($expected_num_assocs, $fetcher->num_assocs); $this->_run($consumer, $user_url, $mode, $delegate_url, - $fetcher, $store); + $fetcher, $store, $immediate); if ($consumer->_use_assocs) { $expected_num_assocs += 1; @@ -245,7 +245,7 @@ class Tests_Auth_OpenID_Consumer extends PHPUnit_TestCase { // Test that doing it again uses the existing association $this->_run($consumer, $user_url, $mode, $delegate_url, - $fetcher, $store); + $fetcher, $store, $immediate); $this->assertEquals($expected_num_assocs, $fetcher->num_assocs); @@ -254,7 +254,7 @@ class Tests_Auth_OpenID_Consumer extends PHPUnit_TestCase { $fetcher->assoc_handle); $this->_run($consumer, $user_url, $mode, $delegate_url, - $fetcher, $store); + $fetcher, $store, $immediate); if ($consumer->_use_assocs) { $expected_num_assocs += 1; @@ -264,7 +264,7 @@ class Tests_Auth_OpenID_Consumer extends PHPUnit_TestCase { // Test that doing it again uses the existing association $this->_run($consumer, $user_url, $mode, $delegate_url, - $fetcher, $store); + $fetcher, $store, $immediate); $this->assertEquals($expected_num_assocs, $fetcher->num_assocs); |