How can I solve the "Type Reference" BaseControlContext "claim ..... 'for AspNet.Security.OpenIdConnect.Server

I ran into a strange problem. I am reading and creating an OpenID Connect server with ASOS this ASOS article - AspNet.Security.OpenIdConnect.Server .

I just created a new sample solution and added a new subclass class AuthorizationProvider OpenIdConnectServerProvider and override the virtual method ie ExtractAuthorizationRequest

AuthorizationProvider.cs

 public class AuthorizationProvider : OpenIdConnectServerProvider { public override Task ExtractAuthorizationRequest(ExtractAuthorizationRequestContext context) { // If a request_id parameter can be found in the authorization request, // restore the complete authorization request stored in the user session. if (!string.IsNullOrEmpty(context.Request.RequestId)) { var payload = context.HttpContext.Session.Get(context.Request.RequestId); if (payload == null) { context.Reject( error: OpenIdConnectConstants.Errors.InvalidRequest, description: "Invalid request: timeout expired."); return Task.FromResult(0); } // Restore the authorization request parameters from the serialized payload. using (var reader = new BsonReader(new MemoryStream(payload))) { foreach (var parameter in JObject.Load(reader)) { // Avoid overriding the current request parameters. if (context.Request.HasParameter(parameter.Key)) { continue; } context.Request.SetParameter(parameter.Key, parameter.Value); } } } return Task.FromResult(0); } } 

Question : As soon as I add the Microsoft.AspNetCore.Identity (2.0.0) NuGet package to my project, context.Reject will start to produce the following error

"The reference to the BaseControlContext type claims to be defined in Microsoft.AspNetCore.Authentication, but could not be found.

But as soon as I remove the Microsoft.AspNetCore.Identity NuGet dependency, the error disappears and everything looks fine.

Note:

  1. I am using VS 2017.
  2. I am using the dotnetcore 2.0 SDK.
  3. I created a solution using .Net Core 2.0.
+5
source share
1 answer

Significant changes have been made to the ASP.NET Core 2.0 authentication stack. The changes are so important that all authentication middleware written for ASP.NET Core 1.x is incompatible (including all aspnet-contrib projects).

You can read https://github.com/aspnet/Announcements/issues/262 for more information.

The good news is that we have a version of ASOS for ASP.NET Core 2.0 RTM. Bits 2.0.0-preview1-* can be found in the MyGet aspnet-contrib channel ( https://www.myget.org/F/aspnet-contrib/api/v3/index.json ).

+2
source

Source: https://habr.com/ru/post/1271121/


All Articles