I recently ran into an issue where I was unable to add basic authentication to a Sitecore site – and the fix for it turned out to have nothing to do with Sitecore at all.
Adding basic authentication through IIS is easy (usually) – disable anonymous authentication and enable/configure basic authentication. But no matter what I tried, I could not get IIS to perform the basic authentication for me. Even when disabling all authentication methods, the site would still be served ok.
As it turns out, the project that was deployed had the WebMatrix DLLs included. And the pure existence of these DLLs would trip up IIS authentication! There’s a stack overflow article here that also describes the problem.
The Sitecore instance in question does not use WebMatrix, so I could safely removing the following NuGet packages from the solution:
And then delete these DLLs from all target instances:
And boom – authentication through IIS started to work as expected.