Esempio n. 1
0
        private ClaimsPrincipal GetPrincipalFromExpiredToken(string token)
        {
            var tokenValidationParameters = securityConfiguration.GeTokenValidationParameters();

            tokenValidationParameters.ValidateLifetime = false;

            var tokenHandler = new JwtSecurityTokenHandler();
            var principal    = tokenHandler.ValidateToken(token, tokenValidationParameters, out var securityToken);

            if (securityToken is JwtSecurityToken jwtSecurityToken &&
                jwtSecurityToken.Header.Alg.Equals(securityConfiguration.SigningAlgorithm, StringComparison.InvariantCultureIgnoreCase))
            {
                return(principal);
            }

            return(null);
        }