In token's validation, I checked the token's lifetime and it was 13:07:10. When I run the validation it was 13:12 and the validation was successful. Why?
When it was about 13:15 I run the validation again and it threw an exception, as expected.
Is there a minimum expiration time for the token?
Creating the token:
var token = new JwtSecurityToken(
issuer: token_issuer,
audience: token_audience,
claims: claims,
expires: DateTime.Now.AddSeconds(5),
signingCredentials: creds
);
Validating the token:
private static bool ValidateToken(string token)
{
try
{
TokenValidationParameters validationParameters = new TokenValidationParameters
{
IssuerSigningKey = new SymmetricSecurityKey(token_salt),
ValidAudience = token_audience,
ValidIssuer = token_issuer,
RequireExpirationTime = true
};
ClaimsPrincipal principal = new JwtSecurityTokenHandler().ValidateToken(token_last, validationParameters, out SecurityToken validatedToken);
return true;
}
catch(SecurityTokenExpiredException ex)
{
}
return false;
}