From 1d8c34e06b1a7ece60e2567d0c4fa29eca638694 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 21 Nov 2024 23:20:11 +1100 Subject: [PATCH 1/2] remove redundant list and expression alloc in SecretValidator.ValidateAsync --- src/IdentityServer/Validation/Default/SecretValidator.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/IdentityServer/Validation/Default/SecretValidator.cs b/src/IdentityServer/Validation/Default/SecretValidator.cs index 58527d3e7..e10953ee5 100644 --- a/src/IdentityServer/Validation/Default/SecretValidator.cs +++ b/src/IdentityServer/Validation/Default/SecretValidator.cs @@ -43,11 +43,9 @@ public async Task ValidateAsync(IEnumerable secr { var secretsArray = secrets as Secret[] ?? secrets.ToArray(); - var expiredSecrets = secretsArray.Where(s => s.Expiration.HasExpired(_clock.UtcNow.UtcDateTime)).ToList(); - if (expiredSecrets.Any()) + foreach (var expired in secretsArray.Where(s => s.Expiration.HasExpired(_clock.UtcNow.UtcDateTime))) { - expiredSecrets.ForEach( - ex => _logger.LogInformation("Secret [{description}] is expired", ex.Description ?? "no description")); + _logger.LogInformation("Secret [{description}] is expired", expired.Description ?? "no description")) } var currentSecrets = secretsArray.Where(s => !s.Expiration.HasExpired(_clock.UtcNow.UtcDateTime)).ToArray(); From 0489e108a8a4616f0ec84f457e864c4b80a4b4ce Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 4 Dec 2024 21:03:53 +1100 Subject: [PATCH 2/2] Update SecretValidator.cs --- src/IdentityServer/Validation/Default/SecretValidator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IdentityServer/Validation/Default/SecretValidator.cs b/src/IdentityServer/Validation/Default/SecretValidator.cs index e10953ee5..7d1368d52 100644 --- a/src/IdentityServer/Validation/Default/SecretValidator.cs +++ b/src/IdentityServer/Validation/Default/SecretValidator.cs @@ -45,7 +45,7 @@ public async Task ValidateAsync(IEnumerable secr foreach (var expired in secretsArray.Where(s => s.Expiration.HasExpired(_clock.UtcNow.UtcDateTime))) { - _logger.LogInformation("Secret [{description}] is expired", expired.Description ?? "no description")) + _logger.LogInformation("Secret [{description}] is expired", expired.Description ?? "no description"); } var currentSecrets = secretsArray.Where(s => !s.Expiration.HasExpired(_clock.UtcNow.UtcDateTime)).ToArray();