Questions tagged «jose»

6
.NET Core 2.0上的JWT
我一直在冒险,让JWT在DotNet core 2.0上工作(现在到达今天的最终版本)。有大量的文档,但是所有的示例代码似乎都在使用不推荐使用的API,并重新引入了Core。弄清楚应该如何实现它确实令人头晕。我尝试使用Jose,但使用了app。UseJwtBearerAuthentication已被弃用,并且没有关于下一步操作的文档。 是否有人有使用dotnet core 2.0的开源项目,该项目可以简单地从授权标头解析J​​WT,并允许我授权对HS256编码的JWT令牌的请求? 下面的类没有引发任何异常,但是没有任何请求被授权,并且我也没有指出为什么它们是未经授权的。响应为空401,因此对我来说,没有任何异常,但机密不匹配。 奇怪的是,我的令牌是用HS256算法加密的,但是我看不到任何指示符可以迫使它在任何地方使用该算法。 这是我到目前为止的课程: using System; using System.Collections.Generic; using System.IO; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Net.Http.Headers; using Newtonsoft.Json.Linq; using Microsoft.IdentityModel.Tokens; using System.Text; namespace Site.Authorization { public static class SiteAuthorizationExtensions { public static IServiceCollection AddSiteAuthorization(this IServiceCollection …
83 c#  .net-core  jwt  jose 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.