【发布时间】: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