Skip to content

Setup for IIS WebApi windows authentication #58311

Answered by andreyppsc
andreyppsc asked this question in Q&A
Discussion options

You must be logged in to vote

Never mind. I've managed to make it work by using the provided sample by docs.
I've added this in the Blazor.Server authentication controller:

private readonly HttpClient _windowsClient;

public AuthenticationController(IHttpClientFactory clientFactory)
{
    _windowsClient = clientFactory.CreateClient("WebApiWindows");
}

[HttpGet("authenticate-windows")]
[Authorize(AuthenticationSchemes = IISDefaults.AuthenticationScheme)]
public async Task<IActionResult> AuthenticateWindows()
{
    HttpResponseMessage authResponse = null;

    var user = User.Identity as WindowsIdentity;
    await WindowsIdentity.RunImpersonatedAsync(user.AccessToken, async () =>
    {
        authResponse = await _win…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by davidfowl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant