diff --git a/src/Identity/IdentityServer/DynamicClientStore.cs b/src/Identity/IdentityServer/DynamicClientStore.cs index 997ff64d0b..b78a0ab4e5 100644 --- a/src/Identity/IdentityServer/DynamicClientStore.cs +++ b/src/Identity/IdentityServer/DynamicClientStore.cs @@ -46,8 +46,6 @@ internal class DynamicClientStore : IClientStore // Increment past the period var identifierName = clientIdSpan[..firstPeriod++]; - // TODO: Validate some rules about the identifierName? - var identifier = clientIdSpan[firstPeriod..]; // The identifier is required to be non-empty @@ -56,6 +54,7 @@ internal class DynamicClientStore : IClientStore return Task.FromResult(null); } + // Once identifierName is proven valid, materialize the string var clientBuilder = _serviceProvider.GetKeyedService(identifierName.ToString()); if (clientBuilder == null) diff --git a/src/Identity/IdentityServer/ServiceCollectionExtensions.cs b/src/Identity/IdentityServer/ServiceCollectionExtensions.cs index fc97fb8e45..2402ebb7f9 100644 --- a/src/Identity/IdentityServer/ServiceCollectionExtensions.cs +++ b/src/Identity/IdentityServer/ServiceCollectionExtensions.cs @@ -4,15 +4,23 @@ namespace Microsoft.Extensions.DependencyInjection; public static class ServiceCollectionExtensions { + /// + /// Registers a custom for the given identifier to be called when a client id with + /// the identifier is attempting authentication. + /// + /// Your custom implementation of . + /// The service collection to add services to. + /// + /// The identifier to be used to invoke your client provider if a client_id is prefixed with your identifier + /// then your implementation will be invoked with the data after the seperating .. + /// + /// The for additional chaining. public static IServiceCollection AddClientProvider(this IServiceCollection services, string identifier) where T : class, IClientProvider { ArgumentNullException.ThrowIfNull(services); ArgumentException.ThrowIfNullOrWhiteSpace(identifier); - // TODO: Track name so that if they register the same one twice it's an error? - - // TODO: We could allow customization of service lifetime services.AddKeyedTransient(identifier); return services;