diff options
Diffstat (limited to 'Auth/OpenID')
-rw-r--r-- | Auth/OpenID/Association.php | 6 | ||||
-rw-r--r-- | Auth/OpenID/Consumer.php | 4 | ||||
-rw-r--r-- | Auth/OpenID/Discover.php | 22 | ||||
-rw-r--r-- | Auth/OpenID/FileStore.php | 2 | ||||
-rw-r--r-- | Auth/OpenID/SQLStore.php | 2 |
5 files changed, 30 insertions, 6 deletions
diff --git a/Auth/OpenID/Association.php b/Auth/OpenID/Association.php index 2cd74e5..6a3a11b 100644 --- a/Auth/OpenID/Association.php +++ b/Auth/OpenID/Association.php @@ -131,8 +131,10 @@ class Auth_OpenID_Association { function Auth_OpenID_Association( $handle, $secret, $issued, $lifetime, $assoc_type) { - if (!in_array($assoc_type, - Auth_OpenID_getSupportedAssociationTypes())) { + // use array_key_exists because in_array doesn't check + // correctly for numerical indexes + $types_hash = array_flip(Auth_OpenID_getSupportedAssociationTypes()); + if (!array_key_exists($assoc_type, $types_hash)) { $fmt = 'Unsupported association type (%s)'; trigger_error(sprintf($fmt, $assoc_type), E_USER_ERROR); } diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php index b7f9439..d2d6f92 100644 --- a/Auth/OpenID/Consumer.php +++ b/Auth/OpenID/Consumer.php @@ -1216,8 +1216,8 @@ class Auth_OpenID_GenericConsumer { } return new Auth_OpenID_FailureResponse(null, - sprintf('No matching endpoint found after discovering %s', - $claimed_id)); + sprintf('No matching endpoint found after discovering %s: %s', + $claimed_id, $result->message)); } /** diff --git a/Auth/OpenID/Discover.php b/Auth/OpenID/Discover.php index 6bc30f3..ac17927 100644 --- a/Auth/OpenID/Discover.php +++ b/Auth/OpenID/Discover.php @@ -32,6 +32,28 @@ function Auth_OpenID_getOpenIDTypeURIs() Auth_OpenID_RP_RETURN_TO_URL_TYPE); } + +/* + * Provides a user-readable interpretation of a type uri. + * Useful for error messages. + */ +function Auth_OpenID_getOpenIDTypeName($type_uri) { + switch ($type_uri) { + case Auth_OpenID_TYPE_2_0_IDP: + return 'OpenID 2.0 IDP'; + case Auth_OpenID_TYPE_2_0: + return 'OpenID 2.0'; + case Auth_OpenID_TYPE_1_2: + return 'OpenID 1.2'; + case Auth_OpenID_TYPE_1_1: + return 'OpenID 1.1'; + case Auth_OpenID_TYPE_1_0: + return 'OpenID 1.0'; + case Auth_OpenID_RP_RETURN_TO_URL_TYPE: + return 'OpenID relying party'; + } +} + /** * Object representing an OpenID service endpoint. */ diff --git a/Auth/OpenID/FileStore.php b/Auth/OpenID/FileStore.php index 6774a7f..187234e 100644 --- a/Auth/OpenID/FileStore.php +++ b/Auth/OpenID/FileStore.php @@ -367,7 +367,7 @@ class Auth_OpenID_FileStore extends Auth_OpenID_OpenIDStore { } if ( abs($timestamp - time()) > $Auth_OpenID_SKEW ) { - return False; + return false; } if ($server_url) { diff --git a/Auth/OpenID/SQLStore.php b/Auth/OpenID/SQLStore.php index abd81bf..5c75e70 100644 --- a/Auth/OpenID/SQLStore.php +++ b/Auth/OpenID/SQLStore.php @@ -482,7 +482,7 @@ class Auth_OpenID_SQLStore extends Auth_OpenID_OpenIDStore { global $Auth_OpenID_SKEW; if ( abs($timestamp - time()) > $Auth_OpenID_SKEW ) { - return False; + return false; } return $this->_add_nonce($server_url, $timestamp, $salt); |