【发布时间】:2014-08-24 02:43:58
【问题描述】:
我将 Json Web Tokens 用于我的 ASP.NET Web API...和 thinktectures 身份模型。
所以在我的 web api Startup.cs 中,我调用 IdentityModelJwtBearerAuthenticationExtensions 扩展方法,如下所示:
app.UseJsonWebToken(
issuer: Constants.IssuerName,
audience: Constants.Audience,
signingKey: Constants.SigningKey
);
然后我用 AuthorizeAttribute 装饰我的 API 控制器。
好的,很好,很好!都很好。
但是当令牌过期时......我得到的只是未经授权的 401。
我想让 JwtSecurityTokenHandler 中的 SecurityTokenValidationException(“生命周期验证失败。令牌已过期”)冒泡并在 Web API 中可见。
我该怎么做?
我环顾四周,找不到正确的方向。
和 JwtBearerAuthenticationOptions 有关系吗?
为任何智慧干杯。
【问题讨论】:
标签: c# oauth-2.0 jwt thinktecture-ident-server thinktecture-ident-model