gpt4 book ai didi

oauth - 我如何解决 AspNet.Security.OpenIdConnect.Server 的 '"对类型 'BaseControlContext"声明的引用...

转载 作者:行者123 更新时间:2023-12-02 17:25:01 27 4
gpt4 key购买 nike

我面临着奇怪的问题。我正在阅读并使用 ASOS 创建 OpenID Connect 服务器这篇文章 ASOS - AspNet.Security.OpenIdConnect.Server .

我只是创建了新的示例解决方案,并添加了 OpenIdConnectServerProvider 的新子类 AuthorizationProvider 类,并覆盖了虚拟方法 i.e.提取授权请求

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);
}
}

问题:一旦我将 Microsoft.AspNetCore.Identity (2.0.0) NuGet 包添加到我的项目中,context.Reject 就开始出现以下错误

"Reference to type 'BaseControlContext" claim it is defined in Microsoft.AspNetCore.Authentication, but it could not be found.

但是,一旦我删除 Microsoft.AspNetCore.Identity NuGet 依赖项,错误就会消失,一切看起来都很好。

注意:

  • 我使用的是 VS 2017。
  • 我正在使用 dotnetcore 2.0 SDK。
  • 我使用 .Net Core 2.0 创建了解决方案。
  • 最佳答案

    ASP.NET Core 2.0 的身份验证堆栈中引入了巨大的更改。这些更改非常重要,以至于为 ASP.NET Core 1.x 编写的所有身份验证中间件都不兼容(包括所有 aspnet-contrib 项目)。

    您可以阅读https://github.com/aspnet/Announcements/issues/262了解更多信息。

    好消息是我们有 ASP.NET Core 2.0 RTM 兼容版本的 ASOS。您可以在 aspnet-contrib MyGet feed ( https://www.myget.org/F/aspnet-contrib/api/v3/index.json ) 上找到 2.0.0-preview1-* 位。

    关于oauth - 我如何解决 AspNet.Security.OpenIdConnect.Server 的 '"对类型 'BaseControlContext"声明的引用...,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45824964/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com