Having two asp.net core APIs where API A has basic auth and API B has windows auth.
API A is calling API B but since API B has windows auth enabled, API A needs to have HttpClient
with NTLM auth.
API A (simplified):
var ccahe = new CredentialCache
{
{
httpRequestMessage.RequestUri, "NTLM",
new NetworkCredential("a.antr01", "pw", "ICEPOR")
}
};
var httpClientHandler = new HttpClientHandler()
{
PreAuthenticate = true,
Credentials = ccahe,
UseDefaultCredentials = true,
AllowAutoRedirect = true
};
using (HttpClient httpClient = new HttpClient(httpClientHandler))
{
return await httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseHeadersRead);
}
as you see in the snippet above, I have a HttpClient
with user a.antr01
but with the debugger in API B in the claims transformation code I see the my user which is logged in Windows and running the IDEs under that account:
how to send the request from API A which would support NTLM to API B and API B would have a correct credentials on its side?
EDIT: if there would be a way how to support both basic and NTLM auth in API B - API A would not be needed anymore - maybe somebody has an idea how to achieve that?
so basic auth flow would be decode base64 -> auth against AD -> get authorization claims -> continue to controller
and NTLM auth would be (already authenticated) -> get authorization claims -> continue to controller