From f2d2529670b6b11e227499e5ff6aa21ad3265b94 Mon Sep 17 00:00:00 2001 From: Andriy Tolstoy Date: Tue, 20 Aug 2024 09:41:33 +0200 Subject: [PATCH 1/3] use Append method --- .../Extensions/AuthenticationPropertiesExtensions.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs b/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs index e3272fd5b..f0ec830ac 100644 --- a/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs +++ b/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Duende Software. All rights reserved. +// Copyright (c) Duende Software. All rights reserved. // See LICENSE in the project root for license information. @@ -100,10 +100,7 @@ public static void AddClientId(this AuthenticationProperties properties, string var clients = properties.GetClientList(); if (!clients.Contains(clientId)) { - var update = clients.ToList(); - update.Add(clientId); - - properties.SetClientList(update); + properties.SetClientList(clients.Append(clientId)); } } From 1b990deff90f8f60ceec4cf07de852ada2d50292 Mon Sep 17 00:00:00 2001 From: Andriy Tolstoy Date: Tue, 20 Aug 2024 09:42:33 +0200 Subject: [PATCH 2/3] use TryGetValue method --- .../Extensions/AuthenticationPropertiesExtensions.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs b/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs index f0ec830ac..43661ccb5 100644 --- a/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs +++ b/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs @@ -26,12 +26,7 @@ public static class AuthenticationPropertiesExtensions /// public static string GetSessionId(this AuthenticationProperties properties) { - if (properties?.Items.ContainsKey(SessionIdKey) == true) - { - return properties.Items[SessionIdKey]; - } - - return null; + return properties?.Items.TryGetValue(SessionIdKey, out var value) == true ? value : null; } /// From 652161719d9f3d72d3c3efd2bc424e722f8e9806 Mon Sep 17 00:00:00 2001 From: Andriy Tolstoy Date: Tue, 20 Aug 2024 09:44:12 +0200 Subject: [PATCH 3/3] use TryGetValue method --- .../Extensions/AuthenticationPropertiesExtensions.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs b/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs index 43661ccb5..213063b6b 100644 --- a/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs +++ b/src/IdentityServer/Extensions/AuthenticationPropertiesExtensions.cs @@ -47,13 +47,12 @@ public static void SetSessionId(this AuthenticationProperties properties, string /// public static IEnumerable GetClientList(this AuthenticationProperties properties) { - if (properties?.Items.ContainsKey(ClientListKey) == true) + if (properties?.Items.TryGetValue(ClientListKey, out var value) == true) { - var value = properties.Items[ClientListKey]; return DecodeList(value); } - return Enumerable.Empty(); + return []; } ///