I am using Visual Studio 2015 Enterprise Update 1 and ASP.NET vNext rc1-update1 to issue and use JWT tokens as described here .
In our implementation, we want to control the validity of the token time.
We tried several approaches, all of which had undesirable side effects. For example, in one attempt, we applied the TokenValidationParameters.TokenValidationParameters.LifetimeValidator event in the Configure method:
app.UseJwtBearerAuthentication ( options => { options.TokenValidationParameters = new TokenValidationParameters() { LifetimeValidator = (DateTime? notBefore, DateTime? expires, SecurityToken securityToken, TokenValidationParameters validationParameters) => {
This event leads to a verification failure, as we would like, but the client receives an error of 500, while we would like to return an error of the 400th series and a small payload.
In another attempt, we tried various implementations of TokenValidationParameters.Events, such as checking claims in the ValidatedToken event, but found that we could not prevent the middleware from using the controller action to throw an exception that returned us to the 500 problem.
So my questions are:
What are the best methods for checking life using OIDC?
Can we make OIDC not include certain life requirements in the token, such as "nbf", since we do not need them?
42vogons Dec 09 '15 at 21:20 2015-12-09 21:20
source share