mirror of
https://github.com/bitwarden/server
synced 2025-12-24 20:23:21 +00:00
* Update ProviderUserOrganizationDetailsView to include SSO configuration data * Updated the ProviderUserOrganizationDetailsViewQuery to join with SsoConfigs and select SSO-related fields. * Modified the SQL view to reflect the inclusion of SSO configuration data. * Added a new migration script for the updated view structure. * Add SSO configuration properties to ProviderUserOrganizationDetails model * Add SSO configuration handling to ProfileProviderOrganizationResponseModel * Introduced properties for SSO configuration, including SSO enabled status and KeyConnector details. * Implemented deserialization of SSO configuration data to populate new fields in the response model. * Add integration tests for ProviderUserRepository.GetManyOrganizationDetailsByUserAsync * Add BaseUserOrganizationDetails model to encapsulate common properties * Introduced a new abstract class to define shared properties for organization users and provider organization users * Add BaseProfileOrganizationResponseModel to encapsulate organization response properties * Introduced a new abstract class that ensures all properties are fully populated for profile organization responses. * Update ProviderUserOrganizationDetailsViewQuery to include missing ProviderUserId * Refactor OrganizationUserOrganizationDetails and ProviderUserOrganizationDetails to inherit from BaseUserOrganizationDetails * Updated both models to extend BaseUserOrganizationDetails, promoting code reuse and ensure they have the same base properties * Refactor ProfileOrganizationResponseModel and ProfileProviderOrganizationResponseModel to inherit from BaseProfileOrganizationResponseModel * Refactor ProviderUserRepositoryTests to improve organization detail assertions * Consolidated assertions for organization details into a new method, AssertProviderOrganizationDetails, enhancing code readability and maintainability. * Updated test cases to verify all relevant properties for organizations with and without SSO configurations. * Add integration test for GetManyDetailsByUserAsync to verify SSO properties * Implemented a new test case to ensure that the SSO properties are correctly populated for organizations with and without SSO configurations. * The test verifies the expected behavior of the method when interacting with the user and organization repositories, including cleanup of created entities after the test execution. * Add unit tests for ProfileOrganizationResponseModel and ProfileProviderOrganizationResponseModel * Introduced tests to validate the constructors of ProfileOrganizationResponseModel and ProfileProviderOrganizationResponseModel, ensuring that all properties are populated correctly based on the provided organization details. * Verified expected behavior for both organization and provider models, including SSO configurations and relevant properties. * Update SyncControllerTests.Get_ProviderPlanTypeProperlyPopulated to nullify SSO configurations in provider user organization details * Refactor BaseProfileOrganizationResponseModel and ProfileOrganizationResponseModel for null safety Updated properties in BaseProfileOrganizationResponseModel and ProfileOrganizationResponseModel to support null safety by introducing nullable types where appropriate. * Enhance null safety in BaseUserOrganizationDetails and OrganizationUserOrganizationDetails Updated properties in BaseUserOrganizationDetails and OrganizationUserOrganizationDetails to support null safety by introducing nullable types where appropriate, ensuring better handling of potential null values. * Move common properties from ProfileOrganizationResponseModel to BaseProfileOrganizationResponseModel * Refactor organization details: Remove BaseUserOrganizationDetails and introduce IProfileMemberOrganizationDetails interface for improved structure and clarity in organization user data management. * Enhance OrganizationUserOrganizationDetails: Implement IProfileMemberOrganizationDetails interface * Refactor ProviderUserOrganizationDetails: Implement IProfileMemberOrganizationDetails interface * Refactor ProfileOrganizationResponseModelTests and ProfileProviderOrganizationResponseModelTests: Update constructors to utilize Organization and ProviderUserOrganizationDetails, enhancing property population and test coverage. * Enhance ProviderUserOrganizationDetails: Add UseResetPassword, UseSecretsManager, and UsePasswordManager properties to the query and SQL views * Update BaseProfileOrganizationResponseModel documentation: Clarify purpose and usage of organization properties for OrganizationUsers and ProviderUsers. * Rename ProfileOrganizationResponseModel to ProfileMemberOrganizationResponseModel, update references and update related test names * Add XML documentation for ProfileMemberOrganizationResponseModel and ProfileProviderOrganizationResponseModel to clarify their purpose and relationships * Remove unnecessary cleanup code from OrganizationUserRepositoryTests * Remove unnecessary cleanup code from ProviderUserRepositoryTests * Rename test method in ProviderUserRepositoryTests to improve clarity on property population * Add CreateFullOrganization method to ProviderUserRepositoryTests for improved organization setup in tests * Refactor organization creation in tests to use CreateTestOrganizationAsync for consistency and improved setup * Rename IProfileMemberOrganizationDetails to IProfileOrganizationDetails * Rename ProfileMemberOrganizationResponseModel back to ProfileOrganizationResponseModel * Refactor organization response models to remove Family Sponsorship properties from BaseProfileOrganizationResponseModel and reintroduce them in ProfileOrganizationResponseModel. Update related interfaces and tests accordingly. * Bump date on migration script * Update OrganizationUserOrganizationDetailsViewQuery to include UseAutomaticUserConfirmation property
82 lines
4.5 KiB
C#
82 lines
4.5 KiB
C#
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
|
|
|
|
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
|
|
|
public class OrganizationUserOrganizationDetailsViewQuery : IQuery<OrganizationUserOrganizationDetails>
|
|
{
|
|
public IQueryable<OrganizationUserOrganizationDetails> Run(DatabaseContext dbContext)
|
|
{
|
|
var query = from ou in dbContext.OrganizationUsers
|
|
join o in dbContext.Organizations on ou.OrganizationId equals o.Id
|
|
join su in dbContext.SsoUsers on new { ou.UserId, OrganizationId = (Guid?)ou.OrganizationId } equals new { UserId = (Guid?)su.UserId, su.OrganizationId } into su_g
|
|
from su in su_g.DefaultIfEmpty()
|
|
join po in dbContext.ProviderOrganizations on o.Id equals po.OrganizationId into po_g
|
|
from po in po_g.DefaultIfEmpty()
|
|
join p in dbContext.Providers on po.ProviderId equals p.Id into p_g
|
|
from p in p_g.DefaultIfEmpty()
|
|
join ss in dbContext.SsoConfigs on ou.OrganizationId equals ss.OrganizationId into ss_g
|
|
from ss in ss_g.DefaultIfEmpty()
|
|
join os in dbContext.OrganizationSponsorships on ou.Id equals os.SponsoringOrganizationUserId into os_g
|
|
from os in os_g.DefaultIfEmpty()
|
|
select new OrganizationUserOrganizationDetails
|
|
{
|
|
UserId = ou.UserId,
|
|
OrganizationId = ou.OrganizationId,
|
|
OrganizationUserId = ou.Id,
|
|
Name = o.Name,
|
|
Enabled = o.Enabled,
|
|
PlanType = o.PlanType,
|
|
UsePolicies = o.UsePolicies,
|
|
UseSso = o.UseSso,
|
|
UseKeyConnector = o.UseKeyConnector,
|
|
UseScim = o.UseScim,
|
|
UseGroups = o.UseGroups,
|
|
UseDirectory = o.UseDirectory,
|
|
UseEvents = o.UseEvents,
|
|
UseTotp = o.UseTotp,
|
|
Use2fa = o.Use2fa,
|
|
UseApi = o.UseApi,
|
|
UseResetPassword = o.UseResetPassword,
|
|
UseSecretsManager = o.UseSecretsManager,
|
|
SelfHost = o.SelfHost,
|
|
UsersGetPremium = o.UsersGetPremium,
|
|
UseCustomPermissions = o.UseCustomPermissions,
|
|
Seats = o.Seats,
|
|
MaxCollections = o.MaxCollections,
|
|
MaxStorageGb = o.MaxStorageGb,
|
|
Identifier = o.Identifier,
|
|
Key = ou.Key,
|
|
ResetPasswordKey = ou.ResetPasswordKey,
|
|
PublicKey = o.PublicKey,
|
|
PrivateKey = o.PrivateKey,
|
|
Status = ou.Status,
|
|
Type = ou.Type,
|
|
SsoExternalId = su.ExternalId,
|
|
Permissions = ou.Permissions,
|
|
ProviderId = p.Id,
|
|
ProviderName = p.Name,
|
|
ProviderType = p.Type,
|
|
SsoEnabled = ss.Enabled,
|
|
SsoConfig = ss.Data,
|
|
FamilySponsorshipFriendlyName = os.FriendlyName,
|
|
FamilySponsorshipLastSyncDate = os.LastSyncDate,
|
|
FamilySponsorshipToDelete = os.ToDelete,
|
|
FamilySponsorshipValidUntil = os.ValidUntil,
|
|
AccessSecretsManager = ou.AccessSecretsManager,
|
|
UsePasswordManager = o.UsePasswordManager,
|
|
SmSeats = o.SmSeats,
|
|
SmServiceAccounts = o.SmServiceAccounts,
|
|
LimitCollectionCreation = o.LimitCollectionCreation,
|
|
LimitCollectionDeletion = o.LimitCollectionDeletion,
|
|
AllowAdminAccessToAllCollectionItems = o.AllowAdminAccessToAllCollectionItems,
|
|
UseRiskInsights = o.UseRiskInsights,
|
|
UseAdminSponsoredFamilies = o.UseAdminSponsoredFamilies,
|
|
LimitItemDeletion = o.LimitItemDeletion,
|
|
IsAdminInitiated = os.IsAdminInitiated,
|
|
UseOrganizationDomains = o.UseOrganizationDomains,
|
|
UseAutomaticUserConfirmation = o.UseAutomaticUserConfirmation
|
|
};
|
|
return query;
|
|
}
|
|
}
|