Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lifetime validation failed. The token is missing an Expiration Time. #99

Closed
daydayup2018 opened this issue Jan 23, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@daydayup2018
Copy link

commented Jan 23, 2018

Hi, there:

I use two VS2017, one run NopCommerce 4.0, including the API, one run the sample application which download from here.

I got this error, not sure why? please help.

Thanks

Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler: Information: Failed to validate the token eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1MTY2NjE3NzcsImV4cCI6MzY2NDE0NTQyNCwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo1NTM5MCIsImF1ZCI6WyJodHRwOi8vbG9jYWxob3N0OjU1MzkwL3Jlc291cmNlcyIsIm5vcF9hcGkiXSwiY2xpZW50X2lkIjoiZjhiYzk2MDItYjQwMi00ZjhjLTlkZGMtMjgwNTI4OGE5OGY1Iiwic3ViIjoiZjhiYzk2MDItYjQwMi00ZjhjLTlkZGMtMjgwNTI4OGE5OGY1IiwiYXV0aF90aW1lIjoxNTE2NjYxNzcyLCJpZHAiOiJsb2NhbCIsInNjb3BlIjpbIm5vcF9hcGkiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicHdkIl19.IfSjNlwL-_BKMukJXG94H5mTo8b4WbQnkQkR0Inr_vhhRZdB2MSS41dBaulaKd9fJZSEAFglyXfz6r6xZ_U-yYyG_PupzTLdLcWe3vLdQkWhSPnk34k1qsQlVfVYdewXANVXyrus0xCsYYdvfWguY99_BBgLdC-TovC_xETg-trTc_I9KT8rkdnflXZLKf4x_YMkSajHor9SvYSyLo__3-ufbO_F1z4GL2m887TSCCKSDRfOACK2OiNM-puQKrpXrHrKEo_Dw1jzIFpSgXArUZe9K5LQ9XE-fva-Y6M9Su8BeukaOe6cEmBqj6hXRpCCVZUOVWyjo33Z70Rm3GjMfg.

Microsoft.IdentityModel.Tokens.SecurityTokenNoExpirationException: IDX10225: Lifetime validation failed. The token is missing an Expiration Time.
Tokentype: 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken'.
at Microsoft.IdentityModel.Tokens.Validators.ValidateLifetime(Nullable1 notBefore, Nullable1 expires, SecurityToken securityToken, TokenValidationParameters validationParameters)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateLifetime(Nullable1 notBefore, Nullable1 expires, JwtSecurityToken securityToken, TokenValidationParameters validationParameters)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateTokenPayload(JwtSecurityToken jwt, TokenValidationParameters validationParameters)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.d__6.MoveNext()
Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler: Information: Bearer was not authenticated. Failure message: IDX10225: Lifetime validation failed. The token is missing an Expiration Time.
Tokentype: 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken'.
Microsoft.AspNetCore.Authorization.DefaultAuthorizationService: Information: Authorization failed for user: (null).
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Information: Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.
Microsoft.AspNetCore.Mvc.ChallengeResult: Information: Executing ChallengeResult with authentication schemes (Bearer).
Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler: Information: AuthenticationScheme: Bearer was challenged.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Information: Executed action Nop.Plugin.Api.Controllers.CustomersController.GetCustomersCount (Nop.Plugin.Api) in 85.0442ms

@poyker

This comment has been minimized.

Copy link
Member

commented Jan 24, 2018

@daydayup2018

Thank you for reporting this and the proposed solution!

I think it is missing the Expiration Time because in the administration we have set it to me Int.MaxValue.
If you set it to 1200 seconds (20 minutes) for example then the lifetime validation works.
It looks like MS are limiting the time to be no later than 2038 and in our case it exceeds it (when using Int.MaxValue). I will simply make a smaller default expiration time that will be properly validated.

@poyker poyker closed this in dee654c Jan 24, 2018

@daydayup2018

This comment has been minimized.

Copy link
Author

commented Jan 24, 2018

Big Thanks @poyker it works

@aaronhoffman

This comment has been minimized.

Copy link

commented Jul 1, 2019

Any idea why the year 2038? I can't find the code that actually performs this validation check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.