Asp.Net Core Custom Authentication Middleware scheme
<p>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.</p>

<p>I am setting the AutomaticAuthenticate option false for Identity on Startup.cs like this</p>

<pre><code>services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;(config =&gt;
        {                
            config.User.RequireUniqueEmail = true;
            config.Password.RequiredLength = 4;
            config.Cookies.ApplicationCookie.AuthenticationScheme = "Cookie";
            config.Cookies.ApplicationCookie.AutomaticAuthenticate = false;                           
        }).AddEntityFrameworkStores&lt;DbContext&gt;()
        .AddDefaultTokenProviders();
</code></pre>

<p>And for my custom middleware I implemented custom options and I've done this</p>

<pre><code>app.UseApiAuthorizationMiddleware(new ApiAuthenticationOptions
        {
            AuthenticationScheme = "Api",
            AutomaticAuthenticate = false
        });
</code></pre>

<p>Now when I try to use </p>

<pre><code>[Authorize(AuthenticationSchemes = "Api")]
</code></pre>

<p>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 </p>

<pre><code>"System.Net.Primitives": "4.0.11-rc2-24027"
</code></pre>

<p>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.</p>

<p>I hope it's clear.</p>

<p>thanks</p>