Reenabling support for digest based authentication

Reordered the authentication flow so as to check for digest based
authentication before using the specified callback in the controller