1
0
mirror of https://github.com/bitwarden/server synced 2026-02-20 11:23:37 +00:00
Files
server/util/SeederUtility/Configuration/ServiceCollectionExtension.cs
Mick Letofsky 507c3a105c Refactoring structure of the CLI to be more maintainable long-term (#7042)
* Refactoring structure of the CLI to be more maintainable long-term
* Remove obvious comments & put back XML comments
2026-02-19 18:40:48 +01:00

42 lines
1.3 KiB
C#

using Bit.Core.Entities;
using Bit.Seeder.Services;
using Bit.SharedWeb.Utilities;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
namespace Bit.SeederUtility.Configuration;
public static class ServiceCollectionExtension
{
public static void ConfigureServices(ServiceCollection services, bool enableMangling = false)
{
var globalSettings = GlobalSettingsFactory.GlobalSettings;
services.AddLogging(builder =>
{
builder.AddConsole();
builder.SetMinimumLevel(LogLevel.Warning);
builder.AddFilter("Microsoft.EntityFrameworkCore.Model.Validation", LogLevel.Error);
});
services.AddSingleton(globalSettings);
services.AddSingleton<IPasswordHasher<User>, PasswordHasher<User>>();
services.TryAddSingleton<ISeedReader, SeedReader>();
services.AddDataProtection().SetApplicationName("Bitwarden");
services.AddDatabaseRepositories(globalSettings);
if (enableMangling)
{
services.TryAddScoped<IManglerService, ManglerService>();
}
else
{
services.TryAddSingleton<IManglerService, NoOpManglerService>();
}
}
}