Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows authentication #3

Open
dragouf opened this issue Nov 13, 2020 · 1 comment
Open

windows authentication #3

dragouf opened this issue Nov 13, 2020 · 1 comment

Comments

@dragouf
Copy link

dragouf commented Nov 13, 2020

great example. Just a not, in a windows authentication (NTLM) network, just do that :

private static readonly HttpClient _httpClient = new HttpClient(new HttpClientHandler { UseDefaultCredentials = true });

to transfer authentication with the request.

@dragouf
Copy link
Author

dragouf commented Nov 20, 2020

also, since it will be windows auth of the server in this case you can transfer browser windows user by using impersonation like this :

var wi = (WindowsIdentity)context.User.Identity;
// transfer windows user of the browser request (impersonate)
await WindowsIdentity.RunImpersonatedAsync(wi.AccessToken, async () =>
{
    using (var responseMessage = await _httpClient.SendAsync(targetRequestMessage, HttpCompletionOption.ResponseHeadersRead, context.RequestAborted))
     {
         context.Response.StatusCode = (int)responseMessage.StatusCode;

        this.CopyFromTargetResponseHeaders(context, responseMessage);

         await this.ProcessResponseContent(context, responseMessage);
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant