1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-26 03:31:34 +01:00

[Require SSO] Added service layer dependent policy check (#977)

* Added service layer dependent policy check

* Updated to SingleOrg
This commit is contained in:
Vincent Salucci 2020-10-27 14:08:19 -05:00 committed by GitHub
parent 0eccfb8784
commit a5db233e51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,6 +44,24 @@ namespace Bit.Core.Services
{
throw new BadRequestException("This organization cannot use policies.");
}
// Handle dependent policy checks
switch(policy.Type)
{
case PolicyType.RequireSso:
if (policy.Enabled)
{
var singleOrg = await _policyRepository.GetByOrganizationIdTypeAsync(org.Id, PolicyType.SingleOrg);
if (singleOrg?.Enabled != true)
{
throw new BadRequestException("Single Organization policy not enabled.");
}
}
break;
default:
break;
}
var now = DateTime.UtcNow;
if (policy.Id == default(Guid))