Changeset 434713
- Timestamp:
- 09/07/2011 03:09:03 PM (15 years ago)
- Location:
- xmpp-auth/trunk
- Files:
-
- 11 added
- 3 edited
-
Auth (added)
-
Auth/SASL (added)
-
Auth/SASL.php (added)
-
Auth/SASL/Anonymous.php (added)
-
Auth/SASL/Common.php (added)
-
Auth/SASL/CramMD5.php (added)
-
Auth/SASL/DigestMD5.php (added)
-
Auth/SASL/External.php (added)
-
Auth/SASL/Login.php (added)
-
Auth/SASL/Plain.php (added)
-
Auth/SASL/SCRAM.php (added)
-
my_socket.php (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
-
xmpp_stream.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
xmpp-auth/trunk/my_socket.php
r429749 r434713 72 72 return $cache[$addr]; 73 73 } 74 // XXX: do I want to unset and update the cache here? 75 // Or I consider it should be taken care at next step? 74 76 } 75 77 // I check the existence because according to documentation, -
xmpp-auth/trunk/readme.txt
r429749 r434713 112 112 *Note for gentoo users*: you must set the 'xml' USE flag. 113 113 114 * **Auth_SASL** *PEAR* module (`pear install Auth_SASL` or install with your115 distribution's package manager) for SASL authentication. For now, this116 dependency is mandatory. Maybe in some future will it become optional.117 118 114 * **OpenSSL** (> 0.9.6) must be installed on the server and PHP must be built 119 115 with `--with-openssl`. … … 134 130 135 131 This script has been tested only currently on Wordpress 3.2.1 up to Wordpress 136 3.2.1 with PHP 5.3.5 up to PHP 5.3. 6, running on a GNU/Linux 64 bits (Gentoo132 3.2.1 with PHP 5.3.5 up to PHP 5.3.8, running on a GNU/Linux 64 bits (Gentoo 137 133 Linux). 138 134 Hopefully it should work with other software versions (not for PHP4, because … … 281 277 proposed in RFC-1035) and reorder cached data using failure and success 282 278 knowledge. 279 - PEAR Auth_SASL coded is included in the plugin, hence the dependency is no more. 280 - A patch has been sent upstream for SCRAM support. 283 281 284 282 = 0.3 = … … 314 312 = 0.4 = 315 313 316 French localization available. DNS cached for improved performance. 314 French localization available. DNS cached for improved performance. SCRAM-* support added. 317 315 318 316 = 0.3 = -
xmpp-auth/trunk/xmpp_stream.php
r429749 r434713 21 21 */ 22 22 23 require_once('Auth/SASL/DigestMD5.php'); 24 require_once('Auth/SASL/Plain.php'); 25 require_once('Auth/SASL/CramMD5.php'); 26 require_once('Auth/SASL/Anonymous.php'); 23 require_once(dirname(__FILE__) . '/Auth/SASL.php'); 24 require_once(dirname(__FILE__) . '/Auth/SASL/DigestMD5.php'); 25 require_once(dirname(__FILE__) . '/Auth/SASL/Plain.php'); 26 require_once(dirname(__FILE__) . '/Auth/SASL/CramMD5.php'); 27 require_once(dirname(__FILE__) . '/Auth/SASL/SCRAM.php'); 28 //require_once('./Auth/SASL/Anonymous.php'); 27 29 $old_error_level = error_reporting(0); 28 30 include_once "Net/DNS.php"; // For SRV Records. // Optional. … … 58 60 // The more securized, the preferred mechanism... 59 61 // For now will consider only the digest-md5 authentication. 60 private $known_auth = array ('DIGEST-MD5' => 10, 'CRAM-MD5' => 7, 'PLAIN' => 4);62 private $known_auth = array ('DIGEST-MD5' => 6, 'CRAM-MD5' => 8, 'PLAIN' => 4, 'SCRAM-SHA-1' => 10); 61 63 private $chosen_mechanism = ''; 62 64 private $use_tls = false; … … 594 596 595 597 } 596 elseif ($this->chosen_mechanism == "CRAM-MD5") 597 { 598 $sasl = new Auth_SASL_CramMD5 (); 599 $uncoded = $sasl->getResponse ($this->node, $this->password, $decoded_challenge); 600 // To be tested. Should the first argument be full jid or just username? 598 elseif ($this->chosen_mechanism == "SCRAM-SHA-1") 599 { 600 // Apparently that never gets used! 601 if (!isset($this->sasl)) 602 $this->sasl = new Auth_SASL_SCRAM('SHA-1'); 603 $uncoded = $this->sasl->getResponse ($this->node, $this->password, $decoded_challenge); 601 604 602 605 $coded = base64_encode ($uncoded); … … 610 613 return; 611 614 } 615 } 616 elseif ($this->chosen_mechanism == "CRAM-MD5") 617 { 618 $sasl = new Auth_SASL_CramMD5 (); 619 $uncoded = $sasl->getResponse ($this->node, $this->password, $decoded_challenge); 620 // To be tested. Should the first argument be full jid or just username? 621 622 $coded = base64_encode ($uncoded); 623 $response = '<response xmlns=\'urn:ietf:params:xml:ns:xmpp-sasl\'>' . $coded . '</response>'; 624 625 if (! $this->socket->send ($response)) 626 { 627 $this->last_error = __('Authentication failure: ', 'xmpp-auth'); 628 $this->last_error .= $_socket->last_error; 629 $this->flags['authenticated'] = false; 630 return; 631 } 612 632 613 633 } … … 623 643 elseif ($name == 'urn:ietf:params:xml:ns:xmpp-sasl:challenge') 624 644 { 645 // Never gets here either. 625 646 unset ($this->flags['challenged_once']); 626 647 $response = '<response xmlns=\'urn:ietf:params:xml:ns:xmpp-sasl\'/>'; … … 725 746 $mechanism .= $coded . "</auth>"; 726 747 } 748 elseif ($this->chosen_mechanism == "SCRAM-SHA-1") 749 { 750 // Apparently I don't come here! 751 if (!isset($this->sasl)) 752 $this->sasl = new Auth_SASL_SCRAM('SHA-1'); 753 $uncoded = $this->sasl->getResponse ($this->node, $this->password); 754 $coded = base64_encode ($uncoded); 755 756 $mechanism = "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='SCRAM-SHA-1'>"; 757 $mechanism .= $coded . "</auth>"; 758 } 727 759 else 728 760 { … … 755 787 return; 756 788 } 757 elseif ($name == 'urn:ietf:params:xml:ns:xmpp-sasl:challenge' 758 && ! array_key_exists ('challenged_once', $this->flags))789 elseif ($name == 'urn:ietf:params:xml:ns:xmpp-sasl:challenge') 790 //&& ! array_key_exists ('challenged_once', $this->flags)) 759 791 { 760 792 // I get the challenge from cdata and decode it (base64). … … 762 794 if ($this->chosen_mechanism == "DIGEST-MD5") 763 795 { 764 $sasl = new Auth_SASL_DigestMD5 (); 765 $uncoded = $sasl->getResponse ($this->node, $this->password, $decoded_challenge, $this->domain, 'xmpp'); 796 if (array_key_exists ('challenged_once', $this->flags)) 797 $uncoded = ''; 798 else 799 { 800 $sasl = new Auth_SASL_DigestMD5 (); 801 $uncoded = $sasl->getResponse ($this->node, $this->password, $decoded_challenge, $this->domain, 'xmpp'); 802 } 803 } 804 elseif ($this->chosen_mechanism == "SCRAM-SHA-1") 805 { 806 if (!isset($this->sasl)) 807 $this->sasl = new Auth_SASL_SCRAM('SHA-1'); 808 $uncoded = $this->sasl->getResponse ($this->node, $this->password, $decoded_challenge); 766 809 } 767 810 elseif ($this->chosen_mechanism == "CRAM-MD5") … … 844 887 $mechanism .= $coded . "</auth>"; 845 888 } 889 elseif ($this->chosen_mechanism == "SCRAM-SHA-1") 890 { 891 if (!isset($this->sasl)) 892 { 893 //$this->sasl = new Auth_SASL_SCRAM('SHA-1'); 894 $sasl = new Auth_SASL(); 895 $this->sasl = $sasl->factory('SCRAM-SHA-1'); 896 } 897 $uncoded = $this->sasl->getResponse ($this->node, $this->password); 898 $coded = base64_encode ($uncoded); 899 900 $mechanism = "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='SCRAM-SHA-1'>"; 901 $mechanism .= $coded . "</auth>"; 902 } 846 903 else 847 904 {
Note: See TracChangeset
for help on using the changeset viewer.