My project has a front-end and an API in the same solution so I am building a custom authentication middleware which is meant to authorize only the API controllers since the Front-end controllers use Identity.
I am setting the AutomaticAuthenticate option false for Identity on Startup.cs like this
services.AddIdentity<ApplicationUser, IdentityRole>(config =>
{
config.User.RequireUniqueEmail = true;
config.Password.RequiredLength = 4;
config.Cookies.ApplicationCookie.AuthenticationScheme = "Cookie";
config.Cookies.ApplicationCookie.AutomaticAuthenticate = false;
}).AddEntityFrameworkStores<DbContext>()
.AddDefaultTokenProviders();
And for my custom middleware I implemented custom options and I've done this
app.UseApiAuthorizationMiddleware(new ApiAuthenticationOptions
{
AuthenticationScheme = "Api",
AutomaticAuthenticate = false
});
Now when I try to use
[Authorize(AuthenticationSchemes = "Api")]
in my controller Visul Studio tells me that AuthenticationSchemes couldn't be found and I'm missing and assemby or reference. Quick Action tool tells me to add
"System.Net.Primitives": "4.0.11-rc2-24027"
but I end up with version 4.0.10 and it doesn't compile... I'm not sure if what I'm done so far is good or if indeed there is an issue here.
I hope it's clear.
thanks