diff --git a/src/Api/Models/Response/Organizations/OrganizationDomainSsoDetailsResponseModel.cs b/src/Api/Models/Response/Organizations/OrganizationDomainSsoDetailsResponseModel.cs index 44c4acea90..d995cc5f8d 100644 --- a/src/Api/Models/Response/Organizations/OrganizationDomainSsoDetailsResponseModel.cs +++ b/src/Api/Models/Response/Organizations/OrganizationDomainSsoDetailsResponseModel.cs @@ -16,13 +16,11 @@ public class OrganizationDomainSsoDetailsResponseModel : ResponseModel SsoAvailable = data.SsoAvailable; DomainName = data.DomainName; OrganizationIdentifier = data.OrganizationIdentifier; - SsoRequired = data.SsoRequired; VerifiedDate = data.VerifiedDate; } public bool SsoAvailable { get; private set; } public string DomainName { get; private set; } public string OrganizationIdentifier { get; private set; } - public bool SsoRequired { get; private set; } public DateTime? VerifiedDate { get; private set; } } diff --git a/src/Core/Models/Data/Organizations/OrganizationDomainSsoDetailsData.cs b/src/Core/Models/Data/Organizations/OrganizationDomainSsoDetailsData.cs index 1a87db792e..b188f9403a 100644 --- a/src/Core/Models/Data/Organizations/OrganizationDomainSsoDetailsData.cs +++ b/src/Core/Models/Data/Organizations/OrganizationDomainSsoDetailsData.cs @@ -1,6 +1,4 @@ -using Bit.Core.Enums; - -namespace Bit.Core.Models.Data.Organizations; +namespace Bit.Core.Models.Data.Organizations; public class OrganizationDomainSsoDetailsData { @@ -9,8 +7,6 @@ public class OrganizationDomainSsoDetailsData public string DomainName { get; set; } public bool SsoAvailable { get; set; } public string OrganizationIdentifier { get; set; } - public bool SsoRequired { get; set; } - public PolicyType? PolicyType { get; set; } public DateTime? VerifiedDate { get; set; } public bool OrganizationEnabled { get; set; } } diff --git a/src/Infrastructure.EntityFramework/Repositories/OrganizationDomainRepository.cs b/src/Infrastructure.EntityFramework/Repositories/OrganizationDomainRepository.cs index 8b453d5e5e..64438bf704 100644 --- a/src/Infrastructure.EntityFramework/Repositories/OrganizationDomainRepository.cs +++ b/src/Infrastructure.EntityFramework/Repositories/OrganizationDomainRepository.cs @@ -1,6 +1,5 @@ using System.Net.Mail; using AutoMapper; -using Bit.Core.Enums; using Bit.Core.Models.Data.Organizations; using Bit.Core.Repositories; using Bit.Infrastructure.EntityFramework.Models; @@ -78,19 +77,14 @@ public class OrganizationDomainRepository : Repository p.Type == PolicyType.RequireSso) on o.Id - equals p.OrganizationId into pJoin - from p in pJoin.DefaultIfEmpty() where od.DomainName == domainName && o.Enabled select new OrganizationDomainSsoDetailsData { OrganizationId = o.Id, OrganizationName = o.Name, SsoAvailable = o.SsoConfigs.Any(sc => sc.Enabled), - SsoRequired = p != null && p.Enabled, OrganizationIdentifier = o.Identifier, VerifiedDate = od.VerifiedDate, - PolicyType = p.Type, DomainName = od.DomainName }) .AsNoTracking() diff --git a/src/Sql/dbo/Stored Procedures/OrganizationDomainSsoDetails_ReadByEmail.sql b/src/Sql/dbo/Stored Procedures/OrganizationDomainSsoDetails_ReadByEmail.sql index b1e4ae7679..5cc47213d6 100644 --- a/src/Sql/dbo/Stored Procedures/OrganizationDomainSsoDetails_ReadByEmail.sql +++ b/src/Sql/dbo/Stored Procedures/OrganizationDomainSsoDetails_ReadByEmail.sql @@ -12,20 +12,15 @@ BEGIN O.Id AS OrganizationId, O.[Name] AS OrganizationName, S.Enabled AS SsoAvailable, - P.Enabled AS SsoRequired, O.Identifier AS OrganizationIdentifier, OD.VerifiedDate, - P.[Type] AS PolicyType, OD.DomainName FROM [dbo].[OrganizationView] O INNER JOIN [dbo].[OrganizationDomainView] OD ON O.Id = OD.OrganizationId - LEFT JOIN [dbo].[PolicyView] P - ON O.Id = P.OrganizationId LEFT JOIN [dbo].[Ssoconfig] S ON O.Id = S.OrganizationId WHERE OD.DomainName = @Domain AND O.Enabled = 1 - AND (P.Id is NULL OR (P.Id IS NOT NULL AND P.[Type] = 4)) -- SSO Type END \ No newline at end of file diff --git a/util/Migrator/DbScripts/2023-03-30_00_RemovePolicyCheckOrganizationDomainSsoDetais.sql b/util/Migrator/DbScripts/2023-03-30_00_RemovePolicyCheckOrganizationDomainSsoDetais.sql new file mode 100644 index 0000000000..4a037c47ee --- /dev/null +++ b/util/Migrator/DbScripts/2023-03-30_00_RemovePolicyCheckOrganizationDomainSsoDetais.sql @@ -0,0 +1,26 @@ +CREATE OR ALTER PROCEDURE [dbo].[OrganizationDomainSsoDetails_ReadByEmail] + @Email NVARCHAR(256) +AS +BEGIN + SET NOCOUNT ON + + DECLARE @Domain NVARCHAR(256) + +SELECT @Domain = SUBSTRING(@Email, CHARINDEX( '@', @Email) + 1, LEN(@Email)) + +SELECT + O.Id AS OrganizationId, + O.[Name] AS OrganizationName, + S.Enabled AS SsoAvailable, + O.Identifier AS OrganizationIdentifier, + OD.VerifiedDate, + OD.DomainName +FROM + [dbo].[OrganizationView] O +INNER JOIN [dbo].[OrganizationDomainView] OD + ON O.Id = OD.OrganizationId +LEFT JOIN [dbo].[Ssoconfig] S + ON O.Id = S.OrganizationId +WHERE OD.DomainName = @Domain + AND O.Enabled = 1 +END \ No newline at end of file