【问题标题】:What is the equivalent of UseOAuthBearerAuthentication in an ASP.NET Core 2 application?ASP.NET Core 2 应用程序中的 UseOAuthBearerAuthentication 等价物是什么?
【发布时间】:2017-12-14 00:15:28
【问题描述】:

我正在升级一个从我们的 oAuth 服务器接受访问令牌的资源服务器。在 .NET 4.7 中,我的启动配置如下所示:

appBuilder.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

当我添加 Nuget 包“Microsoft.Owin.Security.OAuth”时,我收到一条警告,指出该包与目标 .NETCoreApp 不兼容。有道理,但我不确定新包是什么。

我认为我需要的包是“Microsoft.AspNetCore.Authentication.OAuth”。这允许我添加到启动:

services
     .AddAuthentication(OAuthDefaults.DisplayName)
     .AddOAuth("Bearer", options => options.AuthorizationEndpoint = "uhhh" );

我为什么要配置端点,我只是想查找授权令牌,而不是实际提供它们。这看起来像是 oAuth 服务器的设置,而不是收件人。此外,旧的“OAuthBearerAuthenticationOptions”类允许我覆盖“AccessTokenFormat”之类的内容,但我在新选项中没有看到。

最后,我看到可以选择以这种方式配置 oauth:

app.UseOAuthAuthentication

但它抱怨说它已经过时,看起来像 Core 1 版本的“AddOAuth”,而与 AccessTokenFormat 无关。

有什么想法吗?

【问题讨论】:

  • 你最终做了什么来解决这个问题,一些自定义中间件来取消保护令牌?

标签: oauth-2.0 asp.net-core-2.0


【解决方案1】:

Core 不提供这些 API 或其关联令牌服务器的直接替代品。当前的指导是您将 IdentityServer4 之类的服务器与 AddJwtBearerAuthentication 一起使用。

【讨论】:

    猜你喜欢
    • 2019-12-01
    • 2017-07-24
    • 2018-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多