【发布时间】:2018-12-27 12:12:37
【问题描述】:
我了解 ASP.NET Core 具有可用于令牌验证的程序集 Microsoft.AspNetCore.Authentication.JwtBearer。但是,我只是不太明白 ASP.NET Core 内置中间件是否也可以像我们使用 Microsoft.Owin.Security.OAuth 那样生成令牌。有人可以帮我澄清以下问题吗?
-
我们能否像使用 Microsoft.Owin.Security.OAuth 一样使用 Microsoft.AspNetCore.Authentication.JwtBearer 生成和颁发令牌:
app.UseOAuthAuthorizationServer(oAuthServerOptions); app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());无需编写自定义代码来生成令牌?
如果我们不能用 Microsoft.Owin.Security 做到这一点,Microsoft.AspNetCore.Owin 中是否有任何类似于 Microsoft.Owin.Security.OAuth 的功能?
如果我们想使用应用内用户商店、为客户端公开端点以获取令牌并将其用于授权,是否使用像IdentityServer4 这样的第三方解决方案?谢谢。
【问题讨论】:
-
现在有点老了,但我们仍在使用我在这个答案中描述的原则:stackoverflow.com/questions/29048122/…
-
看看Two AuthorizationSchemes in ASP.NET Core 2,因为它涵盖了令牌生成。
-
@MarkG 非常感谢您的链接。这真的很有用!
标签: c# asp.net-core identityserver4 .net-core-authorization