Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Authentication for Kestrel hosted in Windows service

I am running an ASP.NET Core application hosted in a Windows service as described here:

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-2.1

I need this application to support Windows Authentication. What are my options? I tried using Application Request Routing / URL Rewrite module in IIS as a reverse proxy with Windows Authentication but could not figure out how to make that work. Any guidance would be appreciated.

like image 565
Sandy Avatar asked Dec 19 '18 00:12

Sandy


People also ask

Does Kestrel support Windows Authentication?

Authentication. Negotiate NuGet package can be used with Kestrel to support Windows Authentication using Negotiate and Kerberos on Windows, Linux, and macOS. Credentials can be persisted across requests on a connection.

How do I enable Windows Authentication on my server?

Go to Control Panel -> Programs and Features -> Turn windows features on or off. Expand Internet Information Services -> World Wide Web Services. Under Security, select the Windows Authentication check box. Click OK to finish the configuration.

How do I enable Windows Authentication in .NET Core?

It's NOT enabled, by default. You have to open IIS Manager, click on your server (NOT the website - the name of the server machine hosting IIS). Then click on Authentication - you will see "Windows Authentication" is disabled. Enable it.


1 Answers

With .Net Core 3.0 you can use Windows Authentication with Kestrel. There is a Nuget Package for it: Microsoft.AspNetCore.Authentication.Negotiate

You then can add it in Startup.ConfigureServices:

services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
   .AddNegotiate();

For more Information also see:
https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-3.0&tabs=visual-studio#kestrel

like image 172
Yush0 Avatar answered Sep 19 '22 08:09

Yush0