lundi 22 août 2022

http request - How to implement fallback layer, if one authenfication way fails

I have created a program in C#.NET that also fires http queries and runs entirely on the intranet. These queries use NTLM authentication, which in rare cases may not work. For this case I would like to implement some kind of fallback layer that uses Basic Authentication with a stored default user. This default user has very limited rights, but this is usually sufficient. Nevertheless, my code should then send a mail to an internal distribution list, so that we get the problem.

What is the best way to implement such a fallback layer?

As a standalone class with the Chain of Responsibility pattern?

Basic structure:

  • Client wants to fire a http query
  • Handler checks if the NTLM authentication works
  • If the NTLM authentication does not work (401), it uses the basic authentication with the stored default user
  • Info mail goes to internal distribution list
  • If Basic authentication does not work either (401), an error is issued and info mail goes to internal distribution list

Aucun commentaire:

Enregistrer un commentaire