mirror of
https://github.com/bitwarden/server
synced 2025-12-21 18:53:41 +00:00
Add validation to URI Match Default Policy for Single Org prerequisite (#6454)
* Add validation to URI Match Default Policy for Single Org prerequisite Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Remove nullable enable; Replace Task.FromResult(0) with Task.CompletedTask Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Add unit test for our new validator Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Improve comments and whitespace for unit test Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Remove unnecessary whitespace in unit test Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Remove unneccessary unit tets Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Re-add using NSubstitute Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Revert unintended changes to AccountControllerTest.cs Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Revert unintended changes to AccountControllerTest.cs Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Revert unintended changes to HubHelpersTest.cs Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Add IEnforceDependentPoliciesEvent interface to UriMatchDefaultPolicyValidator Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> --------- Signed-off-by: Ben Brooks <bbrooks@bitwarden.com>
This commit is contained in:
@@ -33,6 +33,7 @@ public static class PolicyServiceCollectionExtensions
|
||||
services.AddScoped<IPolicyValidator, RequireSsoPolicyValidator>();
|
||||
services.AddScoped<IPolicyValidator, ResetPasswordPolicyValidator>();
|
||||
services.AddScoped<IPolicyValidator, MaximumVaultTimeoutPolicyValidator>();
|
||||
services.AddScoped<IPolicyValidator, UriMatchDefaultPolicyValidator>();
|
||||
services.AddScoped<IPolicyValidator, FreeFamiliesForEnterprisePolicyValidator>();
|
||||
}
|
||||
|
||||
@@ -51,6 +52,7 @@ public static class PolicyServiceCollectionExtensions
|
||||
services.AddScoped<IPolicyUpdateEvent, MaximumVaultTimeoutPolicyValidator>();
|
||||
services.AddScoped<IPolicyUpdateEvent, FreeFamiliesForEnterprisePolicyValidator>();
|
||||
services.AddScoped<IPolicyUpdateEvent, OrganizationDataOwnershipPolicyValidator>();
|
||||
services.AddScoped<IPolicyUpdateEvent, UriMatchDefaultPolicyValidator>();
|
||||
}
|
||||
|
||||
private static void AddPolicyRequirements(this IServiceCollection services)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Bit.Core.AdminConsole.Entities;
|
||||
using Bit.Core.AdminConsole.Enums;
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.Models;
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyUpdateEvents.Interfaces;
|
||||
|
||||
namespace Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyValidators;
|
||||
|
||||
public class UriMatchDefaultPolicyValidator : IPolicyValidator, IEnforceDependentPoliciesEvent
|
||||
{
|
||||
public PolicyType Type => PolicyType.UriMatchDefaults;
|
||||
public IEnumerable<PolicyType> RequiredPolicies => [PolicyType.SingleOrg];
|
||||
public Task<string> ValidateAsync(PolicyUpdate policyUpdate, Policy? currentPolicy) => Task.FromResult("");
|
||||
public Task OnSaveSideEffectsAsync(PolicyUpdate policyUpdate, Policy? currentPolicy) => Task.CompletedTask;
|
||||
}
|
||||
Reference in New Issue
Block a user