Welcome back guys to video number 7.4 where
we're going to talk about authentication and authorization actually
without authentication and authorization
iot devices are full of vulnerability.
In anybody can access your device without authentication
and it can do whatever they want.
So emqx provide a very
beautiful interface for Access and authentication. So
just
login to your emqx panel by
tapping localhost or column 18083
port and here we
will click on the excess control and on the Authentication.
And just click on the create.
and here we will have a three options password base JWT
and
scram and it is a different authentication technique, but
we are going to use the password paste authentication technique.
So click on the next.
And here we have a lot of different options built-in database
MySQL mongodb post ask postery
SQL and redis reduces a
very old Triple A authentication server.
So you guys can use that rediff if
your organization is already using that to avoid
the duplication of
data entry regarding the users. But right now I'm going
to use the built-in database but MySQL is also good option and the
mongodb is a no escalator base and majority of
developers are now using mongodb to store the
data and
it's the requirement of current scenario that people are
using modern stack mean stack and mongodb
is a by default in that stack. So right
now we're going to use the HTM built-in database and click on
that.
And select the username. Yes. We are
not using the client ID. We will use the username here. We
have option how to store the password sha2506 md5
airplane as such a
256 is a good to go and suffix is good
create and now
it works come to authorization.
And here need to create on built-in database next and
create and we're good to go with that.
Again, go back to the Authentication.
And click on the users and now we
need to add the users. So click on ADD and
type here.
Dev one
and one two, three is a password.
Okay, and you can add as
many users.
to have two main device to
okay.
So this is the authentication but
what is meant by authorization? For example,
we have a two devices and we have a separate
separate topics, but we only want that this
device only send data to the specific topic
and this user name and password
send the data to specific topic. So
this will solve in authorization
where we will put all the settings. So
firstly we need to verify the authentication. Okay, so
firstly I need to type here localhost.
localhost and
883 and here I'm going
to use the topic Home Room 1 and
this is the temperature. Okay and connect and you
will get the error because now the authentication is enabled but
if you want to disable your authentication, you can
just click on that and your authentication will be disabled and
now we are good to go and you see we are connected
disconnected again.
And we're going to enable it again.
And now try and it will say the issue. So
click on authentication and provide the password
Dev username and tab 1 2
3 is a password connect it and we're good to go with that. Okay.
Now it works fine and
Yeah, I need to open the terminal.
mosquito underscores
minus age localhost minus
p
1803 minus t topic to
save the time. I need to copy that topic.
and
topic minus
Okay type it and it will give you.
Authorization error. So I need
to here type A minus U Dev 1 minus
capital P and
1 2 3. It's a password and now we are
going to go with that. Okay.
This is the difference small piece for port and
the capital P is for the password. Okay.
I'm going to type here 18.
Okay.
minus t topic
Oh, yes now it's maybe there's
a glitch that it's not showing but now
you see here that I think there is an
issue with that because the mosquito underscore
sub is divided by the eclipse Foundation, but it
has a client. I think it didn't.
Need to do just like that stuff because it's got us
stuck. Okay, so now it's good to go with that. And now
what I need to do is I need
to
try out for example Room 2 and
I need to
Open up another terminal CMD.
Sorry.
I just copy that command.
to save the time
control V and here I'm going to change it to
the room, too.
And in the room to what I will do is
again connect and here I'm going to drive the
hundred. Okay sand.
And it's sending now the issue is that that this
username?
should
send and receive regarding Room 1 not to
Room 2. So how we can limit to that
user. So click on the authorization.
And in the built-in database permissions here.
We will click on that topic client ID
doesn't need and
publish purpose
I think for the all users is for
the users.
Yes, no, no to the
specific. I need to type username. Okay?
For the specific user. We have a
Dev 1 and
only allow
to the specific topic. What is the specific topic
is?
Room 1 don't worry, I'm going to
okay, I will type here room.
One and temperature. Okay, Bob and
sub both are allowed operations on that.
Okay, and for
dev2
will allow
or you can say slash home slash
room to temperature.
Okay, and we are good to go with that. Now we will try it
again and try to send and it's sending again
and again, but still we need to
Yes, maybe we can restrict.
So guys. I hope you like the authentication how
we can configure the username and password and how the system
works. So I see you in the next video. We're going to send the
data to the cloud. So you guys in the next we have a good day. Bye.