代码之家  ›  专栏  ›  技术社区  ›  Joshua Belden

ASP中的UseAuthBeareAuthentication等效于什么。NET Core 2应用程序?

  •  4
  • Joshua Belden  · 技术社区  · 8 年前

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

    appBuilder.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
    

    当我添加Nuget包“Microsoft”时。奥温。安全OAuth”,我收到一条警告,该包与目标不兼容。NETCoreApp。有道理,但我不确定新的软件包是什么。

    我以为我需要的软件包是“微软”。AspNetCore。身份验证。“OAuth”。允许我添加到启动:

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

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

    最后,我看到可以这样配置oauth:

    app.UseOAuthAuthentication
    

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

    有什么想法吗?

    1 回复  |  直到 8 年前
        1
  •  1
  •   Tratcher    8 年前

    Core不提供这些API或其关联令牌服务器的直接替代品。当前的指导是使用类似IdentityServer4的服务器以及AddJWTBeareAuthentication。

    推荐文章