Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] How to create users using php or javascript in mosquitto

HI,

athenticated username and password works when password created using command like like ./np, then save it into database.

But I need to create passwords when user loggedin.

so please help me above script does't work for me

Thanks
Srinivas

On Thu, Aug 4, 2016 at 4:05 AM, Kees Nuyt <k.nuyt@xxxxxxxxx> wrote:

Hi,

On Wed, 3 Aug 2016 11:27:39 +0530, Srinivas wrote:

> Hi,
>
> I tried this one:
>
> $username="srinivas"; $password="54321";
> $salt_base64="mfJ0Eq3rIDLKG33r"; $salt=base64_decode($salt_base64);
> $hash=hash("sha512",$password.$salt, true);
> $hash_base64=base64_encode($hash);
> echo($username.":$6$".$salt_base64."$".$hash_base64."\n");
>
> output:
> srinivas:$6$mfJ0Eq3rIDLKG33r$PbXRFtUUWje0DJo9v34LsFslCwi1usyZrGi1VnSVLRk8Wtoca3df/ovlxWAD+IpYlrPWJKCt5J3g2Q9CQgl0MQ==
>
> and above useranme and passwords are inserted in mysql mqtt_users table,
> but not connected.

It is meant to be used as a line in
/etc/mosquitto/mosquitto.passwd (or whatever password file you
specify in /etc/mosquitto/mosquitto.conf or a mosquitto conf
file in /etc/mosquitto/conf.d ).

> what is $salt_base64? I given random string.

A random string will not (always) do. It must be a valid 16
character base64 string. The example should work.

As Mikkel said in the article: the broker must see a 12 byte
binary salt (16 byte base64) or authentication will fail.

> Thanks
> Srinivas

HTH

--
Regards,

Kees Nuyt


>On Tue, Aug 2, 2016 at 7:33 PM, Kees Nuyt <k.nuyt@xxxxxxxxx> wrote:
>
>>
>> Hi,
>>
>> I think that question has been answered already by Mikkel in
>> this same thread:
>>
>> From: Mikkel Kirkgaard Nielsen <miki@xxxxxxxxx>
>> Message-ID: <ff786571-e2c5-a334-cd1b-f7bf046682e4@xxxxxxxxx>
>> Date: Wed, 27 Jul 2016 12:06:42 +0200
>>
>>
>> --
>> Regards,
>>
>> Kees Nuyt
>>
>>
>> On Tue, 2 Aug 2016 17:20:32 +0530, you wrote:
>>
>> >HI,
>> >
>> >I successfully username and password authenticated with Mysql.
>> >
>> >My question is, how to encrypt password using php?   (accorind to video in
>> >command line using ./np)
>> >
>> >Thanks
>> >srinivas
>> >
>> >On Mon, Aug 1, 2016 at 1:23 PM, Mikkel Kirkgaard Nielsen <miki@xxxxxxxxx>
>> >wrote:
>> >
>> >> Hi again Srinivas.
>> >>
>> >> On 2016-08-01 09:14, Srinivas Pokala wrote:
>> >> > usernames write into "passwd" file, but when file size reached
>> >> > 20-30kb removed old data and  file writing started from 0kb
>> >> > is there any file size limit in config file?
>> >>
>> >> Doesn't seem so, here's 5000 users generated by mosquitto_passwd
>> >> occupying ~600KiB;
>> >>
>> >> $ touch ~/mosq_passwd_test
>> >> $ for i in $(seq 0 5000); do mosquitto_passwd -b ~/mosq_passwd_test
>> >> Bitten$i Insect; done
>> >> $ ls -l ~/mosq_passwd_test
>> >> -rw-rw-r-- 1 miki miki 599010 Aug  1 09:40 /home/miki/mosq_passwd_test
>> >> $ wc -l ~/mosq_passwd_test
>> >> 5001 /home/miki/mosq_passwd_test
>> >>
>> >> > otherwise how can I resolve this?
>> >>
>> >> Find out who zeroes the file while processing it in your environment?
>> >> Without more elaborate information or code to look at we can only do
>> >> guesswork. Maybe your are writing to the file from different processes?
>> >>
>> >> Have you considered the pure PHP approach I suggested in
>> >> http://dev.eclipse.org/mhonarc/lists/mosquitto-dev/msg01232.html? This
>> >> is much more clean and surely more secure and efficient than shelling
>> >> out for every user.
>> >>
>> >> Regards,
>> >> --
>> >> Mikkel
>> >>
>> >>
>> >> _______________________________________________
>> >> mosquitto-dev mailing list
>> >> mosquitto-dev@xxxxxxxxxxx
>> >> To change your delivery options, retrieve your password, or unsubscribe
>> >> from this list, visit
>> >> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev
>> >>
>> _______________________________________________
>> mosquitto-dev mailing list
>> mosquitto-dev@xxxxxxxxxxx
>> To change your delivery options, retrieve your password, or unsubscribe
>> from this list, visit
>> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev
>>
_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/mosquitto-dev


Back to the top