J'essaye de m'authentifier avec un serveur XMPP en utilisant SASL.Authentification XMPP SASL sur Ejabberd avec PHP
/**
* Send Authentication, SASL
* @return Bool
* @param $username String
* @param $password String
*/
function authenticate($username, $password) {
$this->username = $username;
$this->password = $password;
var_dump($username, $password, $this->domain);
$auth = base64_encode($username.'@'.$this->domain."\u0000".$username."\u0000".$password);
$xml = '<auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">'.$auth.'</auth>';
if ($this->write($xml)) {
if ($xml = $this->listen(1, true)) {
if (preg_match("/<success/i", $xml)) {
$this->authenticated = $this->_sendStream();
}
}
}
$this->events->trigger('authenticate', $this->authenticated);
return $this->authenticated;
}
Le serveur XMPP répond cependant avec:
<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><bad-protocol/></failure>
Ceci est contre un serveur ejabberd. Quand j'ouvre le flux XMPP, il annonce:
<stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
Il coutures pour moi que SASL - PLAIN devrait fonctionner. J'ai une version JavaScript, qui fonctionne parfaitement sur le serveur OpenFire. (Je ne peux pas le tester sur ejabberd au moment)
sendAuthentication: function() {
clearTimeout(XMPP.sendAuthentication_timer);
var auth = Base64.encode(XMPP.username+'@'+XMPP.domain+'\u0000'+XMPP.username+'\u0000'+XMPP.password);
mySocket.events.receive.observe(XMPP.receivedAuthSuccess, function() {
mySocket.send('<auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">' + auth + '</auth>');
});
}
donc je ne peux pas pourquoi la version PHP ne fonctionne pas.
Avez-vous ouvert un rapport de bogue? Cela aiderait d'autres personnes à ne pas avoir le même problème que vous. – cweiske