Closed daydayup2018 closed 6 years ago
@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.
Big Thanks @poyker it works
Any idea why the year 2038? I can't find the code that actually performs this validation check.
Its almost certainly something to do with the jwt exp field being encoded in Unix time (seconds since 00:00:00 UTC on 1 January 1970). Anything later than 03:14:07 on Tuesday, 19 January 2038 when encoded as an integer overflows 32 bits.
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(Nullabled__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
1 notBefore, Nullable
1 expires, SecurityToken securityToken, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateLifetime(Nullable1 notBefore, Nullable
1 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.