Пример #1
0
 /// <summary>
 /// 配置JsonWebToken(JWT)身份验证
 /// 需在Configure中加入 app.UseAuthentication() 以使得登陆配置生效
 /// </summary>
 /// <param name="services"></param>
 /// <param name="secret">密钥</param>
 /// <param name="issuer">信任签发者</param>
 /// <param name="audience">信任服务者</param>
 /// <param name="name">Token名称</param>
 /// <param name="clockSkew">宽限时间/时间验证偏差(默认偏差5分钟)</param>
 /// <returns></returns>
 public static IServiceCollection AddJsonWebTokenAuthentication(this IServiceCollection services, string secret, string issuer, string audience, string name = JsonWebToken.TokenNameDefault, TimeSpan clockSkew = default(TimeSpan))
 => AddJsonWebTokenAuthentication(services, JsonWebToken.CrateSecurityKey(secret), issuer, audience, name, clockSkew);