mirror of
https://github.com/bitwarden/server
synced 2025-12-25 20:53:16 +00:00
Add DynamicClientStore (#5670)
* Add DynamicClientStore * Formatting * Fix Debug assertion * Make Identity internals visible to its unit tests * Add installation client provider tests * Add internal client provider tests * Add DynamicClientStore tests * Fix namespaces after merge * Format * Add docs and remove TODO comments * Use preferred prefix for API keys --------- Co-authored-by: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com>
This commit is contained in:
28
src/Identity/IdentityServer/ServiceCollectionExtensions.cs
Normal file
28
src/Identity/IdentityServer/ServiceCollectionExtensions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Bit.Identity.IdentityServer;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers a custom <see cref="IClientProvider"/> for the given identifier to be called when a client id with
|
||||
/// the identifier is attempting authentication.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Your custom implementation of <see cref="IClientProvider"/>.</typeparam>
|
||||
/// <param name="services">The service collection to add services to.</param>
|
||||
/// <param name="identifier">
|
||||
/// The identifier to be used to invoke your client provider if a <c>client_id</c> is prefixed with your identifier
|
||||
/// then your <see cref="IClientProvider"/> implementation will be invoked with the data after the seperating <c>.</c>.
|
||||
/// </param>
|
||||
/// <returns>The <see cref="IServiceCollection"/> for additional chaining.</returns>
|
||||
public static IServiceCollection AddClientProvider<T>(this IServiceCollection services, string identifier)
|
||||
where T : class, IClientProvider
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(identifier);
|
||||
|
||||
services.AddKeyedTransient<IClientProvider, T>(identifier);
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user