From 4578a21c151b530dcdbc083ec633d711aa0f4d4b Mon Sep 17 00:00:00 2001 From: Brett Hazen <2651260+bhazen@users.noreply.github.com> Date: Tue, 9 Sep 2025 13:04:03 -0500 Subject: [PATCH] Naming improvements for new config for registration_endpoint in discovery document --- .../DynamicClientRegistrationDiscoveryOptions.cs | 14 +++++++------- .../IdentityServerApplicationBuilderExtensions.cs | 4 ++-- .../Default/DiscoveryResponseGenerator.cs | 12 ++++++------ .../Endpoints/Discovery/DiscoveryEndpointTests.cs | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/identity-server/src/IdentityServer/Configuration/DependencyInjection/Options/DynamicClientRegistrationDiscoveryOptions.cs b/identity-server/src/IdentityServer/Configuration/DependencyInjection/Options/DynamicClientRegistrationDiscoveryOptions.cs index 78d5e5882..abe516c4e 100644 --- a/identity-server/src/IdentityServer/Configuration/DependencyInjection/Options/DynamicClientRegistrationDiscoveryOptions.cs +++ b/identity-server/src/IdentityServer/Configuration/DependencyInjection/Options/DynamicClientRegistrationDiscoveryOptions.cs @@ -4,7 +4,7 @@ #nullable enable namespace Duende.IdentityServer.Configuration; -public enum RegistrationEndpointType +public enum RegistrationEndpointMode { /// /// Will not show a registration endpoint in the discovery document @@ -12,14 +12,14 @@ public enum RegistrationEndpointType None, /// - /// Will use the static URL from + /// Will use the static URL from /// Static, /// - /// Will generate the URL dynamically based on the host + /// Will infer the URL dynamically based on the host /// - Dynamic + Inferred } public class DynamicClientRegistrationDiscoveryOptions @@ -30,13 +30,13 @@ public class DynamicClientRegistrationDiscoveryOptions /// /// The type of the registration endpoint. /// - public RegistrationEndpointType RegistrationEndpointType { get; set; } = RegistrationEndpointType.None; + public RegistrationEndpointMode RegistrationEndpointMode { get; set; } = RegistrationEndpointMode.None; /// /// Gets or sets the custom registration endpoint /// /// - /// The URL of the authorization endpoint to use in the discovery document if is set to . + /// The URL of the authorization endpoint to use in the discovery document if is set to . /// - public Uri? CustomRegistrationEndpoint { get; set; } + public Uri? StaticRegistrationEndpoint { get; set; } } diff --git a/identity-server/src/IdentityServer/Configuration/IdentityServerApplicationBuilderExtensions.cs b/identity-server/src/IdentityServer/Configuration/IdentityServerApplicationBuilderExtensions.cs index 9437f8d34..54a369998 100644 --- a/identity-server/src/IdentityServer/Configuration/IdentityServerApplicationBuilderExtensions.cs +++ b/identity-server/src/IdentityServer/Configuration/IdentityServerApplicationBuilderExtensions.cs @@ -216,8 +216,8 @@ public static class IdentityServerApplicationBuilderExtensions throw new InvalidOperationException("CorsPolicyName is not configured"); } - if (options.Discovery.DynamicClientRegistration.RegistrationEndpointType == RegistrationEndpointType.Static - && options.Discovery.DynamicClientRegistration.CustomRegistrationEndpoint == null) + if (options.Discovery.DynamicClientRegistration.RegistrationEndpointMode == RegistrationEndpointMode.Static + && options.Discovery.DynamicClientRegistration.StaticRegistrationEndpoint == null) { throw new InvalidOperationException("DynamicClientRegistration.CustomRegistrationEndpoint must be set when using static registration endpoint type."); } diff --git a/identity-server/src/IdentityServer/ResponseHandling/Default/DiscoveryResponseGenerator.cs b/identity-server/src/IdentityServer/ResponseHandling/Default/DiscoveryResponseGenerator.cs index 049c80968..c43b1a7de 100644 --- a/identity-server/src/IdentityServer/ResponseHandling/Default/DiscoveryResponseGenerator.cs +++ b/identity-server/src/IdentityServer/ResponseHandling/Default/DiscoveryResponseGenerator.cs @@ -409,18 +409,18 @@ public class DiscoveryResponseGenerator : IDiscoveryResponseGenerator entries.Add(OidcConstants.Discovery.DPoPSigningAlgorithmsSupported, Options.DPoP.SupportedDPoPSigningAlgorithms); } - switch (Options.Discovery.DynamicClientRegistration.RegistrationEndpointType) + switch (Options.Discovery.DynamicClientRegistration.RegistrationEndpointMode) { - case RegistrationEndpointType.Static: - if (Options.Discovery.DynamicClientRegistration.CustomRegistrationEndpoint != null) + case RegistrationEndpointMode.Static: + if (Options.Discovery.DynamicClientRegistration.StaticRegistrationEndpoint != null) { - entries.Add(OidcConstants.Discovery.RegistrationEndpoint, Options.Discovery.DynamicClientRegistration.CustomRegistrationEndpoint.ToString()); + entries.Add(OidcConstants.Discovery.RegistrationEndpoint, Options.Discovery.DynamicClientRegistration.StaticRegistrationEndpoint.ToString()); } break; - case RegistrationEndpointType.Dynamic: + case RegistrationEndpointMode.Inferred: entries.Add(OidcConstants.Discovery.RegistrationEndpoint, baseUrl + ProtocolRoutePaths.DynamicClientRegistration); break; - case RegistrationEndpointType.None: + case RegistrationEndpointMode.None: default: break; } diff --git a/identity-server/test/IdentityServer.IntegrationTests/Endpoints/Discovery/DiscoveryEndpointTests.cs b/identity-server/test/IdentityServer.IntegrationTests/Endpoints/Discovery/DiscoveryEndpointTests.cs index a67d1523d..45aa4494b 100644 --- a/identity-server/test/IdentityServer.IntegrationTests/Endpoints/Discovery/DiscoveryEndpointTests.cs +++ b/identity-server/test/IdentityServer.IntegrationTests/Endpoints/Discovery/DiscoveryEndpointTests.cs @@ -474,8 +474,8 @@ public class DiscoveryEndpointTests { var pipeline = new IdentityServerPipeline(); pipeline.Initialize(); - pipeline.Options.Discovery.DynamicClientRegistration.RegistrationEndpointType = RegistrationEndpointType.Static; - pipeline.Options.Discovery.DynamicClientRegistration.CustomRegistrationEndpoint = new Uri("https://custom.example.com/register"); + pipeline.Options.Discovery.DynamicClientRegistration.RegistrationEndpointMode = RegistrationEndpointMode.Static; + pipeline.Options.Discovery.DynamicClientRegistration.StaticRegistrationEndpoint = new Uri("https://custom.example.com/register"); var result = await pipeline.BackChannelClient.GetAsync("https://server/.well-known/openid-configuration"); var json = await result.Content.ReadAsStringAsync(); @@ -490,7 +490,7 @@ public class DiscoveryEndpointTests { var pipeline = new IdentityServerPipeline(); pipeline.Initialize(); - pipeline.Options.Discovery.DynamicClientRegistration.RegistrationEndpointType = RegistrationEndpointType.Dynamic; + pipeline.Options.Discovery.DynamicClientRegistration.RegistrationEndpointMode = RegistrationEndpointMode.Inferred; var result = await pipeline.BackChannelClient.GetAsync("https://server/.well-known/openid-configuration"); var json = await result.Content.ReadAsStringAsync(); @@ -505,7 +505,7 @@ public class DiscoveryEndpointTests { var pipeline = new IdentityServerPipeline(); pipeline.Initialize(); - pipeline.Options.Discovery.DynamicClientRegistration.RegistrationEndpointType = RegistrationEndpointType.None; + pipeline.Options.Discovery.DynamicClientRegistration.RegistrationEndpointMode = RegistrationEndpointMode.None; var result = await pipeline.BackChannelClient.GetAsync("https://server/.well-known/openid-configuration"); var json = await result.Content.ReadAsStringAsync();