xmppo / go-xmpp

Go XMPP Library (From Yasuhiro Matsumoto and based on the code from Russ Cox)
https://golang.org/
BSD 3-Clause "New" or "Revised" License
526 stars 170 forks source link

No proper errror message for failed auth when using SCRAM #157

Closed mdosch closed 8 months ago

mdosch commented 1 year ago

When auth fails due to wrong username or password the error message is 2023/08/18 10:12:52 failed to connect to server: unexpected conted in SCRAM challenge when using SCRAM. I think it should be checked for <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure> after sending the client first message: https://github.com/mattn/go-xmpp/blob/master/xmpp.go#L439

I tried to fix this myself but unfortunately didn't succeed.

eleksir commented 11 months ago

If you look closer into auth code, you probably notice that it ignores pretty much most of fmt.Fprint() errors. Even worse - i tried incorrect password (unintentionally, it was mistype, of course) and stuff was stoned. It waits for successful answer forever (i think). Anyway, there is enough room for improvement in auth procedure.

mdosch commented 11 months ago

I tried several times to get this improved, but seems I do not know enough of all the low level xml handling happening there. I would really appreciate if someone could have a look at this. :)

eleksir commented 11 months ago

It's nothing special, really. Everything according to RFC :) But RFC a bit vaguely describes this moments. So RFC itself here is not particularly helpful. But official xmpp wiki really is. Look at https://wiki.xmpp.org/web/SASL_and_DIGEST-MD5 at this page digest-md5 mechanics are well-described.

I put this altogether in my fork here: https://github.com/eleksir/go-xmpp/blob/6c0bb895d935f5f03d261f8b9785c3658de1b214/xmpp.go#L380

and for exactly digest-md5: https://github.com/eleksir/go-xmpp/blob/6c0bb895d935f5f03d261f8b9785c3658de1b214/xmpp.go#L714

Maybe on some holidays i totally make myself kick and send PR to your fork. But it seems will not happen in closest couple of weeks. I'm a bit lazy and have some tasks to do other than go-xmpp.

mdosch commented 11 months ago

My problem is not the xml regarding the RFC or XEPs but the xml handling done in the lib go-xmpp. If I check for the failure after this line then the accessing of the server first message for the good case doesn't work in this line.

On 08.10.2023 01:18, Eleksir wrote:

It's nothing special, really. Everything according to RFC :) But RFC a bit vaguely describes this moments. So RFC itself here is not particularly helpful. But official xmpp wiki really is. Look at https://wiki.xmpp.org/web/SASL_and_DIGEST-MD5 at this page digest-md5 mechanics are well-described.

I put this altogether in my fork here: https://github.com/eleksir/go-xmpp/blob/6c0bb895d935f5f03d261f8b9785c3658de1b214/xmpp.go#L380

and for exactly digest-md5: https://github.com/eleksir/go-xmpp/blob/6c0bb895d935f5f03d261f8b9785c3658de1b214/xmpp.go#L714

Maybe on some holidays i totally make myself kick and send PR to your fork. But it seems will not happen in closest couple of weeks. I'm a bit lazy and have some tasks to do other than go-xmpp.

-- Reply to this email directly or view it on GitHub: https://github.com/mattn/go-xmpp/issues/157#issuecomment-1751958663 You are receiving this because you authored the thread.

Message ID: @.***>

Neustradamus commented 10 months ago

To follow

mdosch commented 8 months ago

I tried again and now I get from prosody:

2024/01/10 16:27:56 failed to connect to server: auth failure: The response provided by the client doesn't match the one we calculated.

And from ejabberd:

2024/01/10 16:30:13 failed to connect to server: auth failure: Invalid username or password

Seems that got "accidentally" fixed by a recent commit.