Welcome back to the Knowledge Portal Video series.
In the last two lectures we discussed about the basics of the digest authentication, as well as how
we can calculate the response based upon the various values.
Today we will look into how we can actually implement digest authentication on a web server.
Now digest authentication is not supported by Nginx, so we'll be using Apache in this case to have
a digest authentication upon talking about the scenario.
Let me open up the Internet Explorer and when I go to example.com slash admin here you see it is showing
a secret admin page.
So what our case study is that we have to protect this particular page, which is slash admin with a
digest authentication.
Now let's see on how we can do that.
The very first thing that you have to do is you have to install Apache or just verify if you have Apache
installed with RPM grep httpd.
In my case, it is there also.
Make sure that if you are having both Apache as well as Nginx.
Nginx should be stopped.
In my case I have both apache as well as nginx in single server.
Nginx is stopped, however Apache is running.
Great.
So as you have done this, let's go to the Apache configuration and see on how we can have a digest
based authentication.
So I'll go to pass http rtc Httpd.conf.
Httpd.conf.
Now if i search for mod underscore auth.
So these are the modules.
If we look over here on the second module, the second module is related to mod underscore, auth underscore
digest.
So this module is used for digest based authentication.
Make sure you have this particular module installed to verify.
Just verify that you have this particular line in your Apache configuration.
Let's go down and let's write our digest based authentication.
Detectives.
So the very first thing that you'll have to do over here is specify the location block location for,
say, admin.
So whatever I write below, this will be applicable for slash admin location.
First important directive is auth type.
There are two major auth types which is basic and digest.
So as we're implementing digest authentication will write digest over here.
Next come is the auth name.
This is basically the name of the realm, so I'll say knowledge portal.
Now I have to tell the digest module that if anyone comes to slash admin page, provide a username and
password based login screen, so the auth digest domain will be slash admin.
So that means if anyone comes to slash admin page, a username and password will be
asked to the user.
When this is done, let's say, or digest provider, I'll say file followed by the auth user file.
So this is the location of the username and password which will be stored in a particular file.
So I'll say e.t.c., let's put it in Http itself and let's name it digest underscore password, I'll
say pwt.
So this is the location where the username and password will be stored.
And the last directive will be.
And say required valid user.
I hope this is correct.
And to close a location block as well.
So summarizing for slash admin, the auth type is digest.
The realm is knowledge portal.
The password and user are stored in this particular file, and whenever someone tries to access slash
admin, he'll be provided with the login screen.
So I'll save this and before we restart Apache we'll have to.
Create a digest underscore BW file that we have defined.
So in order to create.
We'll use digest.
So this is the command.
So I'll say Digest C is followed, C is basically to create a new file.
I say digest underscore.
P.w.d..
So this is the file name followed by the Realm.
So this is the realm.
So our realm is knowledge portal.
I'll say knowledge Portal and the username.
Let's have username as admin.
It will prompt for a password.
I'll type in the password over here and if I do ls a digest underscore p.w.d. file is created.
Let me restart the Apache.
And it had failed due to some reason.
So let's verify what we did wrong.
Let's go down.
And I think this is it.
Okay, So now let's go back to the Internet Explorer and let's refresh the page.
And now you'll see it is asking for the username and password and this time the authentication is based
on digest.
So I hope this has been informative for you and I would really urge you to try it once and do it for
yourself.
This is it.
About this lecture.
I hope this has been informative for you and I'd like to thank you for viewing.