]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Janrain OpenID extlib updated
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 5 Jul 2015 21:07:41 +0000 (23:07 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 5 Jul 2015 21:07:41 +0000 (23:07 +0200)
From their tree on a4090d0b30f850044413630333341cd327cbb55a
Source: https://github.com/openid/php-openid

extlib/Auth/OpenID/Consumer.php
extlib/Auth/OpenID/FileStore.php
extlib/Auth/OpenID/PredisStore.php
extlib/Auth/OpenID/TrustRoot.php
extlib/Auth/Yadis/Manager.php
extlib/Auth/Yadis/ParanoidHTTPFetcher.php
extlib/Auth/Yadis/ParseHTML.php
extlib/Auth/Yadis/XML.php
extlib/Auth/Yadis/XRDS.php
extlib/Auth/Yadis/Yadis.php

index d562e33f354823498e55109b8670256e92672093..9ac0c500e8c02523716fdc7f56142895694fa3f6 100644 (file)
@@ -29,7 +29,7 @@
  * identity check.
  *
  * LIBRARY DESIGN
- * 
+ *
  * This consumer library is designed with that flow in mind.  The goal
  * is to make it as easy as possible to perform the above steps
  * securely.
@@ -427,7 +427,7 @@ class Auth_OpenID_Consumer {
             $loader->fromSession($endpoint_data);
 
         $message = Auth_OpenID_Message::fromPostArgs($query);
-        $response = $this->consumer->complete($message, $endpoint, 
+        $response = $this->consumer->complete($message, $endpoint,
                                               $current_url);
         $this->session->del($this->_token_key);
 
@@ -616,6 +616,9 @@ class Auth_OpenID_GenericConsumer {
         $this->store = $store;
         $this->negotiator = Auth_OpenID_getDefaultNegotiator();
         $this->_use_assocs = (is_null($this->store) ? false : true);
+        if (get_class($this->store) == "Auth_OpenID_DumbStore") {
+            $this->_use_assocs = false;
+        }
 
         $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
 
@@ -666,7 +669,7 @@ class Auth_OpenID_GenericConsumer {
                                         '_completeInvalid');
 
         return call_user_func_array(array($this, $method),
-                                    array($message, &$endpoint, $return_to));
+                                    array($message, $endpoint, $return_to));
     }
 
     /**
@@ -1186,7 +1189,7 @@ class Auth_OpenID_GenericConsumer {
         list($unused, $services) = call_user_func_array($this->discoverMethod,
                                                         array(
                                                             $claimed_id,
-                                                            &$this->fetcher,
+                                                            $this->fetcher,
                                                         ));
 
         if (!$services) {
@@ -1202,7 +1205,7 @@ class Auth_OpenID_GenericConsumer {
     /**
      * @access private
      */
-    function _verifyDiscoveryServices($claimed_id, 
+    function _verifyDiscoveryServices($claimed_id,
                                       $services, $to_match_endpoints)
     {
         // Search the services resulting from discovery to find one
@@ -1210,7 +1213,7 @@ class Auth_OpenID_GenericConsumer {
 
         foreach ($services as $endpoint) {
             foreach ($to_match_endpoints as $to_match_endpoint) {
-                $result = $this->_verifyDiscoverySingle($endpoint, 
+                $result = $this->_verifyDiscoverySingle($endpoint,
                                                         $to_match_endpoint);
 
                 if (!Auth_OpenID::isFailure($result)) {
@@ -1368,7 +1371,7 @@ class Auth_OpenID_GenericConsumer {
             }
         }
         $ca_message = $message->copy();
-        $ca_message->setArg(Auth_OpenID_OPENID_NS, 'mode', 
+        $ca_message->setArg(Auth_OpenID_OPENID_NS, 'mode',
                             'check_authentication');
         return $ca_message;
     }
@@ -1606,7 +1609,7 @@ class Auth_OpenID_GenericConsumer {
 
         $expires_in = Auth_OpenID::intval($expires_in_str);
         if ($expires_in === false) {
-            
+
             $err = sprintf("Could not parse expires_in from association ".
                            "response %s", print_r($assoc_response, true));
             return new Auth_OpenID_FailureResponse(null, $err);
@@ -1953,7 +1956,7 @@ class Auth_OpenID_AuthRequest {
     function htmlMarkup($realm, $return_to=null, $immediate=false,
                         $form_tag_attrs=null)
     {
-        $form = $this->formMarkup($realm, $return_to, $immediate, 
+        $form = $this->formMarkup($realm, $return_to, $immediate,
                                   $form_tag_attrs);
 
         if (Auth_OpenID::isFailure($form)) {
index 7eec791d24c29d846d48c94f9487b88868b07797..d74f83dcb4e12b2c5a0bed27377ab6417124dedf 100644 (file)
@@ -482,7 +482,7 @@ class Auth_OpenID_FileStore extends Auth_OpenID_OpenIDStore {
         }
 
         if ($handle = opendir($dir)) {
-            while ($item = readdir($handle)) {
+            while (false !== ($item = readdir($handle))) {
                 if (!in_array($item, array('.', '..'))) {
                     if (is_dir($dir . $item)) {
 
index 7108c2faf99cf2b0e793365f40ddd565be2ce2fd..14ecbbd6f8fc619f0f80d571992b966e90d93655 100644 (file)
@@ -104,8 +104,11 @@ class Auth_OpenID_PredisStore extends Auth_OpenID_OpenIDStore {
         
         // no handle given, receiving the latest issued
         $serverKey = $this->associationServerKey($server_url);
-        $lastKey = $this->redis->lpop($serverKey);
-        if (!$lastKey) { return null; }
+        $lastKey = $this->redis->lindex($serverKey, -1);
+        if (!$lastKey) { 
+            // no previous association with this server
+            return null; 
+        }
 
         // get association, return null if failed
         return $this->getAssociationFromServer($lastKey);
@@ -156,10 +159,10 @@ class Auth_OpenID_PredisStore extends Auth_OpenID_OpenIDStore {
         
         // SETNX will set the value only of the key doesn't exist yet.
         $nonceKey = $this->nonceKey($server_url, $salt);
-        $added = $this->predis->setnx($nonceKey);
+        $added = $this->redis->setnx($nonceKey, "1");
         if ($added) {
             // Will set expiration
-            $this->predis->expire($nonceKey, $Auth_OpenID_SKEW);
+            $this->redis->expire($nonceKey, $Auth_OpenID_SKEW);
             return true;
         } else {
             return false;
index 000440b5888649b75f7b3d81f8b29eb283b06450..5e69490788ea020dfc7e05601fb61ec4e5cd9908 100644 (file)
@@ -210,7 +210,7 @@ class Auth_OpenID_TrustRoot {
         if ($parts['host'] == 'localhost') {
             return true;
         }
-        
+
         $host_parts = explode('.', $parts['host']);
         if ($parts['wildcard']) {
             // Remove the empty string from the beginning of the array
@@ -413,7 +413,7 @@ function Auth_OpenID_getAllowedReturnURLs($relying_party_url, $fetcher,
     }
 
     call_user_func_array($discover_function,
-                         array($relying_party_url, &$fetcher));
+                         array($relying_party_url, $fetcher));
 
     $return_to_urls = array();
     $matching_endpoints = Auth_OpenID_extractReturnURL($endpoints);
index 15e69079bb7cb48e7324922601c7097a3d9062b0..664521c9ceba2de255edd9bc2bb7bfde264e47bf 100644 (file)
@@ -414,7 +414,7 @@ class Auth_Yadis_Discovery {
             list($yadis_url, $services) = call_user_func_array($discover_cb,
                                                                array(
                                                                 $this->url,
-                                                                &$fetcher,
+                                                                $fetcher,
                                                                ));
 
             $manager = $this->createManager($services, $yadis_url);
index 125029c4cb9f114cb896fd24955e4ed22df0da34..627ea9a8a2a09233cd3fca7fd3e25dfe560d2db5 100644 (file)
@@ -90,6 +90,15 @@ class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher {
             $this->reset();
 
             $c = curl_init();
+            if (defined('Auth_OpenID_DISABLE_SSL_VERIFYPEER')
+                    && Auth_OpenID_DISABLE_SSL_VERIFYPEER === true) {
+                trigger_error(
+                    'You have disabled SSL verifcation, this is a TERRIBLE ' .
+                    'idea in almost all cases. Set Auth_OpenID_DISABLE_SSL_' .
+                    'VERIFYPEER to false if you want to be safe again',
+                    E_USER_WARNING);
+                curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
+            }
 
             if ($c === false) {
                 Auth_OpenID::log(
index 6f0f8b7e282574a62b651a5f470bab923b40d324..255d7cd27c813e25049ab443337d3e21a3b3b3dd 100644 (file)
@@ -65,29 +65,6 @@ class Auth_Yadis_ParseHTML {
                                       $this->_entity_replacements));
     }
 
-    /**
-     * Replace HTML entities (amp, lt, gt, and quot) as well as
-     * numeric entities (e.g. #x9f;) with their actual values and
-     * return the new string.
-     *
-     * @access private
-     * @param string $str The string in which to look for entities
-     * @return string $new_str The new string entities decoded
-     */
-    function replaceEntities($str)
-    {
-        foreach ($this->_entity_replacements as $old => $new) {
-            $str = preg_replace(sprintf("/&%s;/", $old), $new, $str);
-        }
-
-        // Replace numeric entities because html_entity_decode doesn't
-        // do it for us.
-        $str = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $str);
-        $str = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $str);
-
-        return $str;
-    }
-
     /**
      * Strip single and double quotes off of a string, if they are
      * present.
@@ -216,7 +193,7 @@ class Auth_Yadis_ParseHTML {
             $link_attrs = array();
             foreach ($attr_matches[0] as $index => $full_match) {
                 $name = $attr_matches[1][$index];
-                $value = $this->replaceEntities(
+                $value = html_entity_decode(
                               $this->removeQuotes($attr_matches[2][$index]));
 
                 $link_attrs[strtolower($name)] = $value;
index 39a9942220cadf1f9268d3f52e510f845f1c556a..2b8a20eb311287450cd0d44a7a28c7e3c96af518 100644 (file)
@@ -250,6 +250,10 @@ class Auth_Yadis_dom extends Auth_Yadis_XMLParser {
             return false;
         }
 
+        if (isset($this->doc->doctype)) {
+            return false;
+        }
+
         $this->xpath = new DOMXPath($this->doc);
 
         if ($this->xpath) {
@@ -343,11 +347,11 @@ function Auth_Yadis_getSupportedExtensions()
 function Auth_Yadis_getXMLParser()
 {
     global $__Auth_Yadis_defaultParser;
-    
+
     if (isset($__Auth_Yadis_defaultParser)) {
         return $__Auth_Yadis_defaultParser;
     }
-    
+
     foreach(Auth_Yadis_getSupportedExtensions() as $extension => $classname)
     {
       if (extension_loaded($extension))
@@ -357,7 +361,7 @@ function Auth_Yadis_getXMLParser()
         return $p;
       }
     }
-    
+
     return false;
 }
 
index 1f5af96fb21a69c0dcc0641fde44567eb72e9a24..044d1e761cb0776c7b1e75c8c24ce2f11ab9aeee 100644 (file)
@@ -429,7 +429,7 @@ class Auth_Yadis_XRDS {
 
                 foreach ($filters as $filter) {
 
-                    if (call_user_func_array($filter, array(&$service))) {
+                    if (call_user_func_array($filter, array($service))) {
                         $matches++;
 
                         if ($filter_mode == SERVICES_YADIS_MATCH_ANY) {
index 9ea2db7f91f5c9aa626912235d6d239a0afa4577..f8853671e207b1ca292a3ee04ad441a03e59651b 100644 (file)
@@ -141,7 +141,7 @@ function Auth_Yadis_getServiceEndpoints($input_url, $xrds_parse_func,
     }
 
     $yadis_result = call_user_func_array($discover_func,
-                                         array($input_url, &$fetcher));
+                                         array($input_url, $fetcher));
 
     if ($yadis_result === null) {
         return array($input_url, array());