vernemq / vernemq

A distributed MQTT message broker based on Erlang/OTP. Built for high quality & Industrial use cases. The VerneMQ mission is active & the project maintained. Thank you for your support!
https://vernemq.com
Apache License 2.0
3.23k stars 394 forks source link

2019-08-02 17:40:41.777 [warning] <0.879.0>@vmq_mqtt5_fsm:check_user:857 can't authenticate client {[],<<"mqttjs_0986b129">>} from 127.0.0.1:52052 due to invalid_credentials #1278

Closed golmujik closed 5 years ago

golmujik commented 5 years ago

2019-08-02 17:40:41.777 [warning] <0.879.0>@vmq_mqtt5_fsm:check_user:857 can't authenticate client {[],<<"mqttjs_0986b129">>} from 127.0.0.1:52052 due to invalid_credentials

How can I generate the password which will work with it? in Mongo DB

My mongodb contains this

db.vmq_acl_auth.insert({ mountpoint: '', client_id: 'test-client', username: 'test-user', passhash: '$2a$12$WDzmynWSMRVzfszQkB2MsOWYQK9qGtfjVpO8iBdimTOjCK/u6CzJK', publish_acl: [ {pattern: 'a/b/c'}, {pattern: 'a/+/d'} ], subscribe_acl: [ {pattern: 'a/#'} ] })

codeadict commented 5 years ago

Can you please reformat the issue like this one https://github.com/vernemq/vernemq/issues/1234, adding more structure and context to the question could help the team/community help you.

Thanks

golmujik commented 5 years ago

Ok I will do that☺️

larshesel commented 5 years ago

As @codeadict mentions, please use the issue template when opening issues. From the short snippet I can see that you have an auth entry for the client-id test-client, but you're connecting with a client using the client-id mqttjs_0986b129 which doesn't match the entry and the client is rejected.

golmujik commented 5 years ago

Hi, I got a solution that in lua script file named mongodb.lua I replaced if doc.passhash == bcrypt.hashpw(reg.password, doc.passhash) then with if doc.passhash == reg.password then and it started working

I am sure the password stored in mongodb is wrongly hashed so I just want a way to properly generate the hash which will work with it? please

larshesel commented 5 years ago

If you did that then the password in mongodb isn't hashed. Perhaps you have an old entry in there. Try to list all entries/documents to verify. Can I please ask you to ask usage questions on the community slack channel: https://slack-invite.vernemq.com/ as this is clearly not a bug.

golmujik commented 5 years ago

Yes, it is not a bug after removing the lines which check for hash I saved plain string password in database and client too.

golmujik commented 5 years ago

So the only thing I think I am doing wrong is generating a wrong hash and I don't know how to generate a proper hash. So help with the step to generate proper supported hash would be appreciated. :)

golmujik commented 5 years ago

I did not join slack because I have not used it yet I don't have an account either.

golmujik commented 5 years ago

Hi, @larshesel I asked in slack too but I did not get the way to generate hash will work with it. Please help if you know 😞 .

larshesel commented 5 years ago

answered on slack.