I am trying to make an ASP.NET Core Web API, which uses Windows AD groups for sign in. Based on the documentation, I have configured the authorization and authentication in the Startup.ConfigureServices() method:
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthorization(options =>
{
options.AddPolicy("Reader", policy => policy.RequireRole(@"<DOMAIN>\<AD_ROLE_NAME>"));
});
services
.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
.AddNegotiate();
services.AddControllers();
}
I have then added the [Authorize] attribute to my controller, to ensure than only users who are a member of the AD group, can get access to the end point:
[Authorize(Policy = "Reader")]
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
If I run the API (from Visual Studio) with IIS, it seems to work fine. However, if I change it the execution method which has the same name as the API (I think it's Kestrel?), then it keeps prompting me for sign in.
How do I get it to work with Kestrel (or whatever that other option is)?

