Currently, for every call that comes to my ASP.NET Core MVC Application, I do the following in the OnValidatePrincipal event of the cookie:
- Get the
id_tokenout of the cookie via a call toGetTokenValue. - Call
JwtSecurityTokenHandler's ValidateToken to turn the token into json. - Get the
ValidToproperty out of the json. - Compare it to see if the token is expired.
It seems a bit excessive to me to do this on each an every call. I am wondering if there is someway I can just store the ValidTo value in the cookie itself. That way I would not have to parse out the json to check for expiration on each call.
Is there a way I can get the id_token's ValidTo stored such that a call like this could give me the expiration: GetTokenValue("id_token_valid_to")?