示例#1
0
        // TODO:  Add support for multiple keys...
        private DeviceAuthResult ValidateTokenUsingSymmetricKey(Guid symmetricKey, string deviceToken, TokenValidationParameters validationParams)
        {
            TokenValidationParameters jwtValidationParams = validationParams.Clone();

            jwtValidationParams.IssuerSigningKeys = new SecurityKey[] {
                new SymmetricSecurityKey(symmetricKey.ToByteArray())
                {
                    KeyId = $"DeviceId_{symmetricKey:D}"
                }
            };

            return(DeviceAuthResult.SetAuthenticated(
                       IsDeviceTokenValid(deviceToken, jwtValidationParams)));
        }