From a6609952ee957251b0571d60c9c6be59bfb6ba04 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 27 Nov 2024 23:33:40 +1100 Subject: [PATCH] remove some dead code --- .../Extensions/StringsExtensions.cs | 155 ------------------ .../Endpoints/DeviceAuthorizationEndpoint.cs | 22 --- .../Default/RequestObjectValidator.cs | 6 - 3 files changed, 183 deletions(-) diff --git a/src/EntityFramework.Storage/Extensions/StringsExtensions.cs b/src/EntityFramework.Storage/Extensions/StringsExtensions.cs index 01407b22c..fcc38c7b7 100644 --- a/src/EntityFramework.Storage/Extensions/StringsExtensions.cs +++ b/src/EntityFramework.Storage/Extensions/StringsExtensions.cs @@ -5,8 +5,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text.Encodings.Web; namespace Duende.IdentityServer.EntityFramework.Extensions; @@ -23,116 +21,6 @@ public static string ToSpaceSeparatedString(this IEnumerable list) return String.Join(' ', list); } - [DebuggerStepThrough] - public static IEnumerable FromSpaceSeparatedString(this string input) - { - input = input.Trim(); - return input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - } - - public static List ParseScopesString(this string scopes) - { - if (scopes.IsMissing()) - { - return null; - } - - scopes = scopes.Trim(); - var parsedScopes = scopes.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToList(); - - if (parsedScopes.Any()) - { - parsedScopes.Sort(); - return parsedScopes; - } - - return null; - } - - [DebuggerStepThrough] - public static bool IsMissing(this string value) - { - return string.IsNullOrWhiteSpace(value); - } - - [DebuggerStepThrough] - public static bool IsMissingOrTooLong(this string value, int maxLength) - { - if (string.IsNullOrWhiteSpace(value)) - { - return true; - } - if (value.Length > maxLength) - { - return true; - } - - return false; - } - - [DebuggerStepThrough] - public static bool IsPresent(this string value) - { - return !string.IsNullOrWhiteSpace(value); - } - - [DebuggerStepThrough] - public static string EnsureLeadingSlash(this string url) - { - if (url != null && !url.StartsWith('/')) - { - return "/" + url; - } - - return url; - } - - [DebuggerStepThrough] - public static string EnsureTrailingSlash(this string url) - { - if (url != null && !url.EndsWith('/')) - { - return url + "/"; - } - - return url; - } - - [DebuggerStepThrough] - public static string RemoveLeadingSlash(this string url) - { - if (url != null && url.StartsWith('/')) - { - url = url.Substring(1); - } - - return url; - } - - [DebuggerStepThrough] - public static string RemoveTrailingSlash(this string url) - { - if (url != null && url.EndsWith('/')) - { - url = url.Substring(0, url.Length - 1); - } - - return url; - } - - [DebuggerStepThrough] - public static string CleanUrlPath(this string url) - { - if (String.IsNullOrWhiteSpace(url)) url = "/"; - - if (url != "/" && url.EndsWith('/')) - { - url = url.Substring(0, url.Length - 1); - } - - return url; - } - [DebuggerStepThrough] public static bool IsLocalUrl(this string url) { @@ -195,47 +83,4 @@ static bool HasControlCharacter(ReadOnlySpan readOnlySpan) return false; } } - - [DebuggerStepThrough] - public static string AddQueryString(this string url, string query) - { - if (!url.Contains('?')) - { - url += "?"; - } - else if (!url.EndsWith('&')) - { - url += "&"; - } - - return url + query; - } - - [DebuggerStepThrough] - public static string AddQueryString(this string url, string name, string value) - { - return url.AddQueryString(name + "=" + UrlEncoder.Default.Encode(value)); - } - - [DebuggerStepThrough] - public static string AddHashFragment(this string url, string query) - { - if (!url.Contains('#')) - { - url += "#"; - } - - return url + query; - } - - public static string Obfuscate(this string value) - { - var last4Chars = "****"; - if (value.IsPresent() && value.Length > 4) - { - last4Chars = value.Substring(value.Length - 4); - } - - return "****" + last4Chars; - } } \ No newline at end of file diff --git a/src/IdentityServer/Endpoints/DeviceAuthorizationEndpoint.cs b/src/IdentityServer/Endpoints/DeviceAuthorizationEndpoint.cs index f2df82545..d4cee605a 100644 --- a/src/IdentityServer/Endpoints/DeviceAuthorizationEndpoint.cs +++ b/src/IdentityServer/Endpoints/DeviceAuthorizationEndpoint.cs @@ -126,26 +126,4 @@ private TokenErrorResult Error(string error, string errorDescription = null, Dic return new TokenErrorResult(response); } - - private void LogResponse(DeviceAuthorizationResponse response, DeviceAuthorizationRequestValidationResult requestResult) - { - var clientId = $"{requestResult.ValidatedRequest.Client.ClientId} ({requestResult.ValidatedRequest.Client?.ClientName ?? "no name set"})"; - - if (response.DeviceCode != null) - { - _logger.LogTrace("Device code issued for {clientId}: {deviceCode}", clientId, response.DeviceCode); - } - if (response.UserCode != null) - { - _logger.LogTrace("User code issued for {clientId}: {userCode}", clientId, response.UserCode); - } - if (response.VerificationUri != null) - { - _logger.LogTrace("Verification URI issued for {clientId}: {verificationUri}", clientId, response.VerificationUri); - } - if (response.VerificationUriComplete != null) - { - _logger.LogTrace("Verification URI (Complete) issued for {clientId}: {verificationUriComplete}", clientId, response.VerificationUriComplete); - } - } } \ No newline at end of file diff --git a/src/IdentityServer/Validation/Default/RequestObjectValidator.cs b/src/IdentityServer/Validation/Default/RequestObjectValidator.cs index fdd812a91..5da7fa7bb 100644 --- a/src/IdentityServer/Validation/Default/RequestObjectValidator.cs +++ b/src/IdentityServer/Validation/Default/RequestObjectValidator.cs @@ -343,10 +343,4 @@ private void LogError(string message, ValidatedAuthorizeRequest request) var requestDetails = new AuthorizeRequestValidationLog(request, _options.Logging.AuthorizeRequestSensitiveValuesFilter); _logger.LogError(message + "\n{@requestDetails}", requestDetails); } - - private void LogError(string message, string detail, ValidatedAuthorizeRequest request) - { - var requestDetails = new AuthorizeRequestValidationLog(request, _options.Logging.AuthorizeRequestSensitiveValuesFilter); - _logger.LogError(message + ": {detail}\n{@requestDetails}", detail, requestDetails); - } } \ No newline at end of file