Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the official document, I haven't see reply with an additional challenge response. #27

Open
lzqwebsoft opened this issue Feb 1, 2018 · 0 comments

Comments

@lzqwebsoft
Copy link

At XmppPrebind class 450 line:

$challengeResponse = $this->send($domDocument->saveXML());

return $this->replyToChallengeResponse($challengeResponse);

which meaning to reply xmpp server when SASL authenticate success. but at official document i haven't see this step. if i do this. I will got a XmppPrebindException said: Invalid login!!
Here is request and response error xml content (xmpp server is Openfire):

#### request:
<?xml version="1.0" encoding="UTF-8"?>
<body xmlns="http://jabber.org/protocol/httpbind" content="text/xml charset=utf-8" rid="4723813009" xml:lang="en" sid="603v7hlcaw">
    <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
</body>
### response:
<body xmlns='http://jabber.org/protocol/httpbind' ack='4723813009'><failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure></body>

So in my code, I has remove this unnecessary step:

  /**
     * Send challenge request and build DIGEST-MD5 auth string
     *
     * @param Auth_SASL_Common $auth
     * @return string Auth XML to send
     */
    protected function sendChallengeAndBuildDigestMd5Auth(Auth_SASL_Common $auth) {
        $challenge = $this->sendChallenge();

        $authString = $auth->getResponse(self::getNodeFromJid($this->jid), $this->password, $challenge, $this->jabberHost, self::SERVICE_NAME);
        $this->debug($authString, 'DIGEST-MD5 Auth String');

        $authString = base64_encode($authString);

        $domDocument = $this->buildBody();
        $body = self::getBodyFromDomDocument($domDocument);

        $response = $domDocument->createElement('response');
        $response->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_SASL));
        $response->appendChild($domDocument->createTextNode($authString));

        $body->appendChild($response);


//        $challengeResponse = $this->send($domDocument->saveXML());
//
//        return $this->replyToChallengeResponse($challengeResponse);
         return $domDocument->saveXML();
    }

Then login, restart, and bind resource is successfully.

  • The function sendChallengeAndBuildCramMd5Auth too.

Is this reply step not needed?
I had fork your project to: https://github.com/lzqwebsoft/xmpp-prebind-php, remove this step and remove FirePHP (because firebug out), last add translate README to chinese. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant