From 560f5b3456ca98f49187fab4181f8b88bc21d28c Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 15 Aug 2023 18:40:21 +0100 Subject: [PATCH] Remove redundant formatting Remove redundant string formatting from JumpCloud. --- .../JumpCloudAuthenticationDefaults.cs | 11 ++++++----- .../JumpCloudPostConfigureOptions.cs | 11 ++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/AspNet.Security.OAuth.JumpCloud/JumpCloudAuthenticationDefaults.cs b/src/AspNet.Security.OAuth.JumpCloud/JumpCloudAuthenticationDefaults.cs index d9256fd6f..61fce3675 100644 --- a/src/AspNet.Security.OAuth.JumpCloud/JumpCloudAuthenticationDefaults.cs +++ b/src/AspNet.Security.OAuth.JumpCloud/JumpCloudAuthenticationDefaults.cs @@ -4,8 +4,6 @@ * for more information concerning the license and the contributors participating to this project. */ -using System.Globalization; - namespace AspNet.Security.OAuth.JumpCloud; /// @@ -36,30 +34,33 @@ public static class JumpCloudAuthenticationDefaults /// /// Default path format to use for . /// + [Obsolete("This field is obsolete and will be removed in a future version.")] public static readonly string AuthorizationEndpointPathFormat = "/oauth2/auth"; /// /// Default path format to use for . /// + [Obsolete("This field is obsolete and will be removed in a future version.")] public static readonly string TokenEndpointPathFormat = "/oauth2/token"; /// /// Default path format to use for . /// + [Obsolete("This field is obsolete and will be removed in a future version.")] public static readonly string UserInformationEndpointPathFormat = "/userinfo"; /// /// Default path to use for . /// - public static readonly string AuthorizationEndpointPath = string.Format(CultureInfo.InvariantCulture, AuthorizationEndpointPathFormat); + public static readonly string AuthorizationEndpointPath = "/oauth2/auth"; /// /// Default path to use for . /// - public static readonly string TokenEndpointPath = string.Format(CultureInfo.InvariantCulture, TokenEndpointPathFormat); + public static readonly string TokenEndpointPath = "/oauth2/token"; /// /// Default path to use for . /// - public static readonly string UserInformationEndpointPath = string.Format(CultureInfo.InvariantCulture, UserInformationEndpointPathFormat); + public static readonly string UserInformationEndpointPath = "/userinfo"; } diff --git a/src/AspNet.Security.OAuth.JumpCloud/JumpCloudPostConfigureOptions.cs b/src/AspNet.Security.OAuth.JumpCloud/JumpCloudPostConfigureOptions.cs index 5d926bf25..f8a10ae69 100644 --- a/src/AspNet.Security.OAuth.JumpCloud/JumpCloudPostConfigureOptions.cs +++ b/src/AspNet.Security.OAuth.JumpCloud/JumpCloudPostConfigureOptions.cs @@ -4,7 +4,6 @@ * for more information concerning the license and the contributors participating to this project. */ -using System.Globalization; using Microsoft.Extensions.Options; namespace AspNet.Security.OAuth.JumpCloud; @@ -24,15 +23,13 @@ public void PostConfigure( throw new ArgumentException("No JumpCloud domain configured.", nameof(options)); } - options.AuthorizationEndpoint = CreateUrl(options.Domain, JumpCloudAuthenticationDefaults.AuthorizationEndpointPathFormat); - options.TokenEndpoint = CreateUrl(options.Domain, JumpCloudAuthenticationDefaults.TokenEndpointPathFormat); - options.UserInformationEndpoint = CreateUrl(options.Domain, JumpCloudAuthenticationDefaults.UserInformationEndpointPathFormat); + options.AuthorizationEndpoint = CreateUrl(options.Domain, JumpCloudAuthenticationDefaults.AuthorizationEndpointPath); + options.TokenEndpoint = CreateUrl(options.Domain, JumpCloudAuthenticationDefaults.TokenEndpointPath); + options.UserInformationEndpoint = CreateUrl(options.Domain, JumpCloudAuthenticationDefaults.UserInformationEndpointPath); } - private static string CreateUrl(string domain, string pathFormat, params object[] args) + private static string CreateUrl(string domain, string path) { - var path = string.Format(CultureInfo.InvariantCulture, pathFormat, args); - // Enforce use of HTTPS var builder = new UriBuilder(domain) {