The core infrastructure backend (API, database, Docker, etc).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
1.3 KiB

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>();
}
}
}