Skip to content

windows authentication #3

Open
Open

Description

@dragouf

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.

Activity

  1. dragouf commented on Nov 20, 2020

    @dragouf
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions