I have a basic web API app that tries to support IntegratedWindowsAuthentication & Anonymous. Sample code is below,
using (WebApp.Start("http://localhost:8080/", (app) =>
{
HttpConfiguration config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
config.EnsureInitialized();
HttpListener listener = (HttpListener)app.Properties["System.Net.HttpListener"];
listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication | AuthenticationSchemes.Anonymous;
app.UseWebApi(config);
}))
public class TestController : ApiController
{
[Authorize]
[Route("Secret")]
public int Get()
{
return 42;
}
[Route("Public")]
public int GetNoSecurity()
{
return 42;
}
}
Expectation is that ~/Secret requires credentials and ~/Public doesn’t.
Things work fine with Fiddler but not with a browser. Hitting ~/Secret from chrome/IE doesn’t popup the credentials message box.