diff options
author | tailor <cygnus@janrain.com> | 2006-05-08 21:50:44 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2006-05-08 21:50:44 +0000 |
commit | d049272d918076c88e82e0f129922693d593de8d (patch) | |
tree | b9b99ec12452b74851fb3f4b780de5401d832b4e | |
parent | 4db77595677049b2d4772bc430ec875a5a5f8658 (diff) | |
download | php-openid-d049272d918076c88e82e0f129922693d593de8d.zip php-openid-d049272d918076c88e82e0f129922693d593de8d.tar.gz php-openid-d049272d918076c88e82e0f129922693d593de8d.tar.bz2 |
[project @ Finished changes for using yadis service manager]
-rw-r--r-- | Auth/OpenID/Consumer.php | 50 | ||||
-rw-r--r-- | Auth/OpenID/Discover.php | 7 |
2 files changed, 26 insertions, 31 deletions
diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php index d808b3d..eabe043 100644 --- a/Auth/OpenID/Consumer.php +++ b/Auth/OpenID/Consumer.php @@ -194,6 +194,7 @@ require_once "Auth/OpenID/CryptUtil.php"; require_once "Auth/OpenID/DiffieHellman.php"; require_once "Auth/OpenID/KVForm.php"; require_once "Auth/OpenID/Discover.php"; +require_once "Services/Yadis/Manager.php"; /** * This is the status code returned when either the of the beginAuth @@ -235,26 +236,6 @@ define('Auth_OpenID_DEFAULT_NONCE_CHRS',"abcdefghijklmnopqrstuvwxyz" . */ define('Auth_OpenID_DEFAULT_TOKEN_LIFETIME', 60 * 5); // five minutes -class Auth_OpenID_PHPSession { - function set($name, $value) - { - $_SESSION[$name] = $value; - } - - function get($name, $default=null) - { - if (array_key_exists($name, $_SESSION)) { - return $_SESSION[$name]; - } else { - return $default; - } - } - - function del($name) - { - unset($_SESSION[$name]); - } -} class Auth_OpenID_Consumer { @@ -264,7 +245,7 @@ class Auth_OpenID_Consumer { function Auth_OpenID_Consumer(&$store, $session = null) { if ($session === null) { - $session = new Auth_OpenID_PHPSession(); + $session = new Services_Yadis_PHPSession(); } $this->session =& $session; @@ -274,14 +255,21 @@ class Auth_OpenID_Consumer { function begin($user_url) { + global $_yadis_available; + $openid_url = Auth_OpenID::normalizeUrl($user_url); - if (false) { // If yadis_available + if ($_yadis_available) { + $disco = new Services_Yadis_Discovery($this->session, + $openid_url, + $this->session_key_prefix); + $endpoint = $disco->getNextService('Auth_OpenID_discoverWithYadis', + $this->consumer->fetcher); } else { $endpoint = null; $result = Auth_OpenID_discover($openid_url, $this->consumer->fetcher); if ($result !== null) { - list($temp, $endpoints) = $result; + list($temp, $endpoints, $http_response) = $result; $endpoint = $endpoints[0]; } } @@ -302,6 +290,8 @@ class Auth_OpenID_Consumer { function complete($query) { + global $_yadis_available; + $token = $this->session->get($this->_token_key); if ($token === null) { @@ -312,13 +302,13 @@ class Auth_OpenID_Consumer { } if (in_array($response->status, array('success', 'cancel'))) { - /* - if yadis_available and response.identity_url is not None: - disco = Discovery(self.session, response.identity_url) - # This is OK to do even if we did not do discovery in - # the first place. - disco.cleanup() - */ + if ($_yadis_available && + $response->identity_url !== null) { + $disco = new Services_Yadis_Discovery($this->session, + $response->identity_url, + $this->session_key_prefix); + $disco->cleanup(); + } } return $response; diff --git a/Auth/OpenID/Discover.php b/Auth/OpenID/Discover.php index 1b5aaaa..a5f3c76 100644 --- a/Auth/OpenID/Discover.php +++ b/Auth/OpenID/Discover.php @@ -5,7 +5,7 @@ */ require_once "Auth/OpenID.php"; -require_once "Auth/OpenID/Parse.php"; // need Auth_OpenID_legacy_discover +require_once "Auth/OpenID/Parse.php"; // If the Yadis library is available, use it. Otherwise, only use // old-style discovery. @@ -17,6 +17,11 @@ $try_include = @include 'Services/Yadis/Yadis.php'; if ($try_include) { $_yadis_available = true; +} else { + trigger_error("Yadis support not found; please install the ". + "JanRain, Inc. PHP Yadis library, available at ". + "http://www.openidenabled.com.", + E_USER_ERROR); } define('_OPENID_1_0_NS', 'http://openid.net/xmlns/1.0'); |