2024-10-22 09:18:34 +10:00
|
|
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.Implementations;
|
2025-02-14 21:05:49 +10:00
|
|
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
|
2025-10-10 11:23:02 -04:00
|
|
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyUpdateEvents;
|
|
|
|
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyUpdateEvents.Interfaces;
|
2024-10-22 09:18:34 +10:00
|
|
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyValidators;
|
|
|
|
|
|
using Bit.Core.AdminConsole.Services;
|
|
|
|
|
|
using Bit.Core.AdminConsole.Services.Implementations;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.AdminConsole.OrganizationFeatures.Policies;
|
|
|
|
|
|
|
|
|
|
|
|
public static class PolicyServiceCollectionExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
public static void AddPolicyServices(this IServiceCollection services)
|
|
|
|
|
|
{
|
|
|
|
|
|
services.AddScoped<IPolicyService, PolicyService>();
|
|
|
|
|
|
services.AddScoped<ISavePolicyCommand, SavePolicyCommand>();
|
2025-10-10 11:23:02 -04:00
|
|
|
|
services.AddScoped<IVNextSavePolicyCommand, VNextSavePolicyCommand>();
|
2025-02-14 21:05:49 +10:00
|
|
|
|
services.AddScoped<IPolicyRequirementQuery, PolicyRequirementQuery>();
|
2025-10-10 11:23:02 -04:00
|
|
|
|
services.AddScoped<IPolicyEventHandlerFactory, PolicyEventHandlerHandlerFactory>();
|
2024-10-22 09:18:34 +10:00
|
|
|
|
|
2025-02-14 21:05:49 +10:00
|
|
|
|
services.AddPolicyValidators();
|
|
|
|
|
|
services.AddPolicyRequirements();
|
2025-09-10 10:13:04 -04:00
|
|
|
|
services.AddPolicySideEffects();
|
2025-10-16 10:18:37 +01:00
|
|
|
|
services.AddPolicyUpdateEvents();
|
2025-02-14 21:05:49 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-16 10:18:37 +01:00
|
|
|
|
[Obsolete("Use AddPolicyUpdateEvents instead.")]
|
2025-02-14 21:05:49 +10:00
|
|
|
|
private static void AddPolicyValidators(this IServiceCollection services)
|
|
|
|
|
|
{
|
2024-10-22 09:18:34 +10:00
|
|
|
|
services.AddScoped<IPolicyValidator, TwoFactorAuthenticationPolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyValidator, SingleOrgPolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyValidator, RequireSsoPolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyValidator, ResetPasswordPolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyValidator, MaximumVaultTimeoutPolicyValidator>();
|
2024-11-19 17:37:01 +01:00
|
|
|
|
services.AddScoped<IPolicyValidator, FreeFamiliesForEnterprisePolicyValidator>();
|
2025-09-10 10:13:04 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-16 10:18:37 +01:00
|
|
|
|
[Obsolete("Use AddPolicyUpdateEvents instead.")]
|
2025-09-10 10:13:04 -04:00
|
|
|
|
private static void AddPolicySideEffects(this IServiceCollection services)
|
|
|
|
|
|
{
|
|
|
|
|
|
services.AddScoped<IPostSavePolicySideEffect, OrganizationDataOwnershipPolicyValidator>();
|
2024-10-22 09:18:34 +10:00
|
|
|
|
}
|
2025-02-14 21:05:49 +10:00
|
|
|
|
|
2025-10-16 10:18:37 +01:00
|
|
|
|
private static void AddPolicyUpdateEvents(this IServiceCollection services)
|
|
|
|
|
|
{
|
|
|
|
|
|
services.AddScoped<IPolicyUpdateEvent, RequireSsoPolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyUpdateEvent, TwoFactorAuthenticationPolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyUpdateEvent, SingleOrgPolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyUpdateEvent, ResetPasswordPolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyUpdateEvent, MaximumVaultTimeoutPolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyUpdateEvent, FreeFamiliesForEnterprisePolicyValidator>();
|
|
|
|
|
|
services.AddScoped<IPolicyUpdateEvent, OrganizationDataOwnershipPolicyValidator>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-14 21:05:49 +10:00
|
|
|
|
private static void AddPolicyRequirements(this IServiceCollection services)
|
|
|
|
|
|
{
|
2025-03-11 10:46:09 +10:00
|
|
|
|
services.AddScoped<IPolicyRequirementFactory<IPolicyRequirement>, DisableSendPolicyRequirementFactory>();
|
|
|
|
|
|
services.AddScoped<IPolicyRequirementFactory<IPolicyRequirement>, SendOptionsPolicyRequirementFactory>();
|
2025-03-21 10:07:55 -04:00
|
|
|
|
services.AddScoped<IPolicyRequirementFactory<IPolicyRequirement>, ResetPasswordPolicyRequirementFactory>();
|
2025-06-24 10:29:09 -04:00
|
|
|
|
services.AddScoped<IPolicyRequirementFactory<IPolicyRequirement>, OrganizationDataOwnershipPolicyRequirementFactory>();
|
2025-04-23 15:43:36 +01:00
|
|
|
|
services.AddScoped<IPolicyRequirementFactory<IPolicyRequirement>, RequireSsoPolicyRequirementFactory>();
|
2025-05-29 07:40:30 +01:00
|
|
|
|
services.AddScoped<IPolicyRequirementFactory<IPolicyRequirement>, RequireTwoFactorPolicyRequirementFactory>();
|
2025-07-25 11:55:34 -04:00
|
|
|
|
services.AddScoped<IPolicyRequirementFactory<IPolicyRequirement>, MasterPasswordPolicyRequirementFactory>();
|
2025-02-14 21:05:49 +10:00
|
|
|
|
}
|
2024-10-22 09:18:34 +10:00
|
|
|
|
}
|