Let us see the difference between the two HTTP authentication using Wireshark
(Tool to analyse packets sent or received) .
1. Http Basic Authentication
As soon as the client types in the correct username:password,as requested by the Web-server, the Web-Server checks in the Database if the credentials are correct and gives the access to the resource .
Here is how the packets are sent and received :
In the first packet the Client fill the credentials using the POST method at the resource - lab/webapp/basicauth
.In return the server replies back with http response code 200 ok ,i.e, the username:password were correct .
Now , In the Authorization
header it shows that it is Basic Authorization followed by some random string .This String is the encoded (Base64) version of the credentials admin:aadd
(including colon ) .
2 . Http Digest Authentication(rfc 2069)
So far we have seen that the Basic Authentication sends username:password in plaintext over the network .But the Digest Auth sends a HASH of the Password using Hash algorithm.
Here are packets showing the requests made by the client and response from the server .
As soon as the client types the credentials requested by the server , the Password is converted to a response
using an algorithm and then is sent to the server , If the server Database has same response as given by the client the server gives the access to the resource , otherwise a 401 error .
In the above Authorization
, the response
string is calculated using the values of Username
,Realm
,Password
,http-method
,URI
and Nonce
as shown in the image :
Hence , we can see that the Digest Authentication is more Secure as it involve Hashing (MD5 encryption) , So the packet sniffer tools cannot sniff the Password although in Basic Auth the exact Password was shown on Wireshark.