mirror of
https://github.com/bitwarden/server.git
synced 2025-04-24 14:26:38 -05:00

* scim project stub * some scim models and v2 controllers * implement some v2 scim endpoints * fix spacing * api key auth * EC-261 - SCIM Org API Key and connection type config * EC-261 - Fix lint errors/formatting * updates for okta implementation testing * fix var ref * updates from testing with Okta * implement scim context via provider parsing * support single and list of ids for add/remove groups * log ops not handled * touch up scim context * group list filtering * EC-261 - Additional SCIM provider types * EC-265 - UseScim flag and license update * EC-265 - SCIM provider type of default (0) * EC-265 - Add Scim URL and update connection validation * EC-265 - Model validation and cleanup for SCIM keys * implement scim org connection * EC-265 - Ensure ServiceUrl is not persisted to DB * EC-265 - Exclude provider type from DB if not configured * EC-261 - EF Migrations for SCIM * add docker builds for scim * EC-261 - Fix failing permissions tests * EC-261 - Fix unit tests and pgsql migrations * Formatting fixes from linter * EC-265 - Remove service URL from scim config * EC-265 - Fix unit tests, removed wayward validation * EC-265 - Require self-hosted for billing sync org conn * EC-265 - Fix formatting issues - whitespace * EC-261 - PR feedback and cleanup * scim constants rename * no scim settings right now * update project name * delete package lock * update appsettings configs for scim * use default scim provider for context Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com>
67 lines
3.6 KiB
C#
67 lines
3.6 KiB
C#
using Bit.Core.Enums;
|
|
using Bit.Core.Repositories;
|
|
using Bit.Infrastructure.EntityFramework.Repositories;
|
|
using LinqToDB.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Bit.Infrastructure.EntityFramework
|
|
{
|
|
public static class EntityFrameworkServiceCollectionExtensions
|
|
{
|
|
public static void AddEFRepositories(this IServiceCollection services, bool selfHosted, string connectionString,
|
|
SupportedDatabaseProviders provider)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(connectionString))
|
|
{
|
|
throw new Exception($"Database provider type {provider} was selected but no connection string was found.");
|
|
}
|
|
LinqToDBForEFTools.Initialize();
|
|
services.AddAutoMapper(typeof(UserRepository));
|
|
services.AddDbContext<DatabaseContext>(options =>
|
|
{
|
|
if (provider == SupportedDatabaseProviders.Postgres)
|
|
{
|
|
options.UseNpgsql(connectionString);
|
|
// Handle NpgSql Legacy Support for `timestamp without timezone` issue
|
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
|
}
|
|
else if (provider == SupportedDatabaseProviders.MySql)
|
|
{
|
|
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
|
|
}
|
|
});
|
|
services.AddSingleton<ICipherRepository, CipherRepository>();
|
|
services.AddSingleton<ICollectionCipherRepository, CollectionCipherRepository>();
|
|
services.AddSingleton<ICollectionRepository, CollectionRepository>();
|
|
services.AddSingleton<IDeviceRepository, DeviceRepository>();
|
|
services.AddSingleton<IEmergencyAccessRepository, EmergencyAccessRepository>();
|
|
services.AddSingleton<IFolderRepository, FolderRepository>();
|
|
services.AddSingleton<IGrantRepository, GrantRepository>();
|
|
services.AddSingleton<IGroupRepository, GroupRepository>();
|
|
services.AddSingleton<IInstallationRepository, InstallationRepository>();
|
|
services.AddSingleton<IMaintenanceRepository, MaintenanceRepository>();
|
|
services.AddSingleton<IOrganizationRepository, OrganizationRepository>();
|
|
services.AddSingleton<IOrganizationApiKeyRepository, OrganizationApiKeyRepository>();
|
|
services.AddSingleton<IOrganizationConnectionRepository, OrganizationConnectionRepository>();
|
|
services.AddSingleton<IOrganizationSponsorshipRepository, OrganizationSponsorshipRepository>();
|
|
services.AddSingleton<IOrganizationUserRepository, OrganizationUserRepository>();
|
|
services.AddSingleton<IPolicyRepository, PolicyRepository>();
|
|
services.AddSingleton<ISendRepository, SendRepository>();
|
|
services.AddSingleton<ISsoConfigRepository, SsoConfigRepository>();
|
|
services.AddSingleton<ISsoUserRepository, SsoUserRepository>();
|
|
services.AddSingleton<ITaxRateRepository, TaxRateRepository>();
|
|
services.AddSingleton<ITransactionRepository, TransactionRepository>();
|
|
services.AddSingleton<IUserRepository, UserRepository>();
|
|
services.AddSingleton<IProviderRepository, ProviderRepository>();
|
|
services.AddSingleton<IProviderUserRepository, ProviderUserRepository>();
|
|
services.AddSingleton<IProviderOrganizationRepository, ProviderOrganizationRepository>();
|
|
|
|
if (selfHosted)
|
|
{
|
|
services.AddSingleton<IEventRepository, EventRepository>();
|
|
}
|
|
}
|
|
}
|
|
}
|