Is it possible to use both of them?
Currently i have a Rest API protected by Digest Auth, One of the developers is struggling to get their Android application working with Digest and suggested if could use Basic and OR Digest depending on the Header sent?
Is there anything specific sent from Digest Vs Basic i could use to determine a switch statement in my PHP Code?
It does go against what i want and understand the difference in security, this is just a fall back in case of worst case scenario.
For example something like this:
$headers = apache_request_headers();
if(isset($headers['Authorization'])){
if (strpos($headers['Authorization'], "Digest")!== false) {
// Use Digest Authentication Method
echo "You are using Digest Auth ";
} else if (strpos($headers['Authorization'], "Basic")!== false){
// Use Basic Authentication Method
Echo "You are using Basic Auth";
}
}
This code works, but Digest does not appear to send Digest in the Authorization header by default, its something that has to be passed across manually, this is in my experience when working with Postman and my GET Application communicating with my Rest API.