Currently I'm trying to solve my problem — which is implement NTLM authorization on my intranet site in the way how I think it should work, namely ask password only on certain pages. Not just hitting main page — so site should be divided on two pieces: available for all and restricted.
The issue I'm using Nancy framework and it does not implement NTLM natively. But this will not stop the real cowboy programmer. So I'm trying to develop custom request / response sequence to accomplish this goal.
For now I have discovered this Q&A, but solution there is glued to the IIS...
I have discovered site with a lots of complex information about NTLM and I wondering is there any C# class to simplify this process?
Namely, helping to create responses of different types.
Currently my code looks like this:
Get["/Profile/"] = parameters =>
{
var request = this.Request;
if (this.Request.Headers.Keys.Any(x => x == "Authorization"))
{
var items = Response.Context.Items;
var expert = new Expert(WindowsIdentity.GetCurrent());
var model = expert.Ensure();
return View["Profile.liquid", model];
}
else
{
var response = new Response();
response.StatusCode = HttpStatusCode.Unauthorized;
response.Headers.Add("WWW-Authenticate", "NTLM");
return response;
}
};
But it implements only first stage of NTLM authorization. Is it possible to avoid lots of manual code to implement other steps by involving ready to use helper?