Ada*_*ley 6 jwt bearer-token asp.net-core
我想要的是ASP.NET Core中JWT生成和JWT消耗的方法.
没有OAuth2流程,我确实让IdentityServerv3与OAuth2一起使用,但是当我拥有双方时,对于访问API的单个应用程序来说,这样做太过分了.
我遇到的主要困难是在ASP.NET Core中找到相当于Microsoft.Owin.Security.Jwt的内容.此列表中的任何内容https://www.myget.org/gallery/aspnetvnext似乎都与此无关.或者该包实际上与ASP.NET Core保持相关性?
如果您正在寻找(简单)生成自己的JWT令牌的方法,您应该直接使用JwtSecurityTokenHandler
.您可以在System.IdentityModel.Tokens
您提到的MyGet存储库的软件包中找到它(但现在版本有点旧),或者直接在Azure AD存储库的System.IdentityModel.Tokens.Jwt
软件包中找到它:https://www.myget.org/gallery/azureadwebstacknightly
当然,使用标准协议来发布和检索您的JWT令牌是超过建议的,OAuth2和OpenID Connect可能是最佳候选者.
请注意,IdentityServer不是唯一可以在ASP.NET 5上运行的服务器.我个人正在研究Katana 3附带的OAuth2授权服务器中间件的高级分支,它提供了不同的方法:https://github.com /aspnet-contrib/AspNet.Security.OpenIdConnect.Server
app.UseOAuthBearerAuthentication(new JwtBearerOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
Audience = "http://localhost:54540/",
Authority = "http://localhost:54540/"
});
app.UseOpenIdConnectServer(options =>
{
options.Provider = new AuthorizationProvider();
});
Run Code Online (Sandbox Code Playgroud)
要了解有关此项目的更多信息,我建议您阅读http://kevinchalet.com/2016/07/13/creating-your-own-openid-connect-server-with-asos-introduction/.
如果您需要更多信息,请随时在https://jabbr.net/#/rooms/AspNetCore上ping我.
归档时间: |
|
查看次数: |
6495 次 |
最近记录: |