5

Tôi đang gặp vấn đề lạ. Tôi đang đọc và tạo OpenID Connect server with ASOS bài viết này ASOS - AspNet.Security.OpenIdConnect.Server.Làm cách nào để giải quyết tham chiếu kiểu 'BaseControlContext' ..... 'cho AspNet.Security.OpenIdConnect.Server

Tôi chỉ đơn giản là tạo ra giải pháp mẫu mới và thêm mới lớp lớp con AuthorizationProvider của OpenIdConnectServerProvider và ghi đè lên các phương pháp ảo i.e. 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); 
    } 
} 

Issue: Ngay sau khi tôi thêm Microsoft.AspNetCore.Identity (2.0.0) Gói NuGet vào dự án của tôi, context.Reject bắt đầu cung cấp lỗi sau

"Tham chiếu đến loại 'BaseControlContext" xác nhận quyền sở hữu được xác định trong Microsoft.AspNetCore.Authentication, nhưng không thể tìm thấy.

Nhưng ngay sau khi tôi xóa Microsoft.AspNetCore.Identity Phụ thuộc NuGet, lỗi biến mất và tất cả đều ổn.

Lưu ý:

  1. Tôi đang sử dụng VS 2017.
  2. Tôi đang sử dụng dotnetcore 2.0 SDK.
  3. Tôi đã tạo giải pháp bằng cách sử dụng .Net Core 2.0.

Trả lời

2

Thay đổi lớn đã được đưa vào ngăn xếp xác thực ASP.NET Core 2.0. Những thay đổi quan trọng đến mức tất cả phần mềm trung gian xác thực được viết cho ASP.NET Core 1.x không tương thích (bao gồm tất cả các dự án aspnet-contrib).

Bạn có thể đọc https://github.com/aspnet/Announcements/issues/262 để biết thêm thông tin.

Tin tốt là chúng tôi có phiên bản tương thích với ASP.NET Core 2.0 RTM của ASOS. Bạn có thể tìm thấy các bit 2.0.0-preview1-* trên nguồn cấp dữ liệu myGet aspnet-contrib (https://www.myget.org/F/aspnet-contrib/api/v3/index.json).

+0

Cảm ơn ý kiến ​​của bạn – immirza

+0

Điều này cũng có nghĩa là tôi không thể triển khai IAppBuilder trong IApplicationBuilder bằng phương pháp UseOwin theo hướng dẫn chính thức của microsoft? Bạn có thể xem câu hỏi này không, vui lòng https://stackoverflow.com/questions/45847623/unable-to-configuer-iapplicationbuilder-useowin – immirza

+0

@immirza Tôi không chắc tôi hiểu câu hỏi của bạn. ASOS cho ASP.NET Core (1.x hoặc 2.x) không phụ thuộc vào OWIN, vì vậy bạn không cần một adapter để làm cho nó hoạt động (đó là một thành phần cốt lõi của ASP.NET). – Pinpoint

Các vấn đề liên quan