* Add new feature flag for Members Get Endpoint Optimization
* Add a new version of OrganizationUser_ReadByOrganizationIdWithClaimedDomains that uses CTE for better performance
* Add stored procedure OrganizationUserUserDetails_ReadByOrganizationId_V2 for retrieving user details, group associations, and collection associations by organization ID.
* Add the sql migration script to add the new stored procedures
* Introduce GetManyDetailsByOrganizationAsync_vNext and GetManyByOrganizationWithClaimedDomainsAsync_vNext in IOrganizationUserRepository to enhance performance by reducing database round trips.
* Updated GetOrganizationUsersClaimedStatusQuery to use an optimized query when the feature flag is enabled
* Updated OrganizationUserUserDetailsQuery to use optimized queries when the feature flag is enabled
* Add integration tests for GetManyDetailsByOrganizationAsync_vNext
* Add integration tests for GetManyByOrganizationWithClaimedDomainsAsync_vNext to validate behavior with verified and unverified domains.
* Optimize performance by conditionally setting permissions only for Custom user types in OrganizationUserUserDetailsQuery.
* Create UserEmailDomainView to extract email domains from users' email addresses
* Create stored procedure Organization_ReadByClaimedUserEmailDomain_V2 that uses UserEmailDomainView to fetch Email domains
* Add GetByVerifiedUserEmailDomainAsync_vNext method to IOrganizationRepository and its implementations
* Refactor OrganizationUser_ReadByOrganizationIdWithClaimedDomains_V2 stored procedure to use UserEmailDomainView for email domain extraction, improving query efficiency and clarity.
* Enhance IOrganizationUserRepository with detailed documentation for GetManyDetailsByOrganizationAsync method, clarifying its purpose and performance optimizations. Added remarks for better understanding of its functionality.
* Fix missing newline at the end of Organization_ReadByClaimedUserEmailDomain_V2.sql to adhere to coding standards.
* Update the database migration script to include UserEmailDomainView
* Bumped the date on the migration script
* Remove GetByVerifiedUserEmailDomainAsync_vNext method and its stored procedure.
* Refactor UserEmailDomainView index creation to check for existence before creation
* Update OrganizationUser_ReadByOrganizationIdWithClaimedDomains_V2 to use CTE and add indexes
* Remove creation of unique clustered index from UserEmailDomainView and related migration script adjustments
* Update indexes and sproc
* Fix index name when checking if it already exists
* Bump up date on migration script
* Document database projects and complete EDD support
* Remove an old remnant of a now-unused 'future' state
* Sync finalization scripts
* Fix conflict
* Fix some script issues
* feat: exclude DefaultUserCollection from GetManyByOrganizationIdWithPermissionsAsync
Updated EF implementation, SQL procedure, and unit test to verify that default user collections are filtered from results
* Update the public CollectionsController.Get method to return a NotFoundResult for collections of type DefaultUserCollection.
* Add unit tests for the public CollectionsController
* Update ICollectionRepository.GetManyByOrganizationIdAsync to exclude results of the type DefaultUserCollection
Modified the SQL stored procedure and the EF query to reflect this change and added a new integration test to ensure the functionality works as expected.
* Refactor CollectionsController to remove unused IApplicationCacheService dependency
* Update IOrganizationUserRepository.GetDetailsByIdWithCollectionsAsync to exclude DefaultUserCollections
* Update IOrganizationUserRepository.GetManyDetailsByOrganizationAsync to exclude DefaultUserCollections
* Undo change to GetByIdWithCollectionsAsync
* Update integration test to verify exclusion of DefaultUserCollection in OrganizationUserRepository.GetDetailsByIdWithCollectionsAsync
* Clarify documentation in ICollectionRepository to specify that GetManyByOrganizationIdWithAccessAsync returns only shared collections belonging to the organization.
* Add Arrange, Act, and Assert comments to CollectionsControllerTests
* Add Config Option For Disabling Built In MSSQL Container
* fix: flip bool condition and make it nullable
* fake commit to kick off an ephemeral environment
* Revert "fake commit to kick off an ephemeral environment"
This reverts commit 818f65f4d2.
* Changed the new setting to not be nullable.
---------
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Co-authored-by: Todd Martin <tmartin@bitwarden.com>
* Feat(pm-20348):
* Add migration scripts for Read Pending Auth Requests by UserId stored procedure and new `view` for pending AuthRequest.
* View only returns the most recent pending authRequest, or none at all if the most recent is answered.
* Implement stored procedure in AuthRequestRepository for both Dapper and Entity Framework.
* Update AuthRequestController to query the new View to get a user's most recent pending auth requests response includes the requesting deviceId.
* Doc:
* Move summary xml comments to interface.
* Added comments for the AuthRequestService.
* Test:
* Added testing for AuthRequestsController.
* Added testing for repositories.
* Added integration tests for multiple auth requests but only returning the most recent.
* mark all notifications associated with a security task as deleted when the task is completed
* fix spelling
* formatting
* refactor "Active" to "NonDeleted"
* refactor "Active" to "NonDeleted" for stored procedure
* only send notifications per user for each notification
* move notification status updates into the DB layer to save on multiple queries and insertions from the C#
* Only return UserIds from db layer
* omit userId from `MarkTaskAsCompletedCommand` query.
The userId from the notification will be used
* update UserIds
* consistency in comments regarding `taskId` and `UserId`
* cascade delete NotificationStatus entities
* add userId to test for foreign constraint
* add missing properties for Notification
* add check for foreign key
* [PM-17562] Add integration filter support
* Repond to PR feedback; Remove Date-related filters
* Use tables to format the filter class descriptions
* [PM-17562] Add database support for integration filters (#5988)
* [PM-17562] Add database support for integration filters
* Respond to PR review - fix database scripts
* Further database updates; fix Filters to be last in views, stored procs, etc
* Fix for missing nulls in stored procedures in main migration script
* Reorder Filters to the bottom of OrganizationIntegrationConfiguration
* Separate out the creation of filters from the IntegrationFilterService to IntegrationFIlterFactory
* Move properties to static readonly field
* Fix unit tests failing from merge
---------
Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
* PM-20574 fixing namespaces on reporting work that got moved over from tools
* PM-20574 adding tables, stored procedures, and migration files
* PM-20574 adding dapper and ef repos and migrations
* PM-20574 changing table and repo names as requested
* PM-20574 updating sql scripts to new names
* PM-20574 updating sql scripts
* PM-20574 updating migration script for org delete by id
* PM-20574 adding mysql migration
* PM-20574 updating sql migration to fix database test
* PM-20574 fixing migration script
* PM-20574 fixing migration script
* PM-20574 fixing table scripts
* PM-20574 fixing table scripts
* PM-20574 fixing migration script formatting
* PM-20574 fixing syntax in migration script
* PM-20574 fixing file names and extensions
* PM-20574 fixing sql file
* PM-20574 fixing sql
* PM-20574 fixing directory for entities and removing scripts from other databases
* PM-20574 generating new migration scripts
* PM-20574 fixed reference to a stored proc
* PM-20574 adding index in scripts and missing table
* PM-20574 fixing merge conflicts
* PM-20574 set OUTPUT param for Id property in create and update proc
* PM-20574 add CreateDate to the update proc
* PM-20574 amend update proc for OrganizationApplication by adding createDate
* PM-20574 formatted sql and updated as per PR comments
* PM-20574 updated script to fix build error
* PM-20574 fixed inconsistency in db script
* PM-20574 removed revisionDate, update procedures and used views
* PM-20574 removed RevisionDate from designer files
* PM-20574 removed revisionDate column that was missed previously
* PM-20574 added revision date back into the mix
* PM-20574 updated database script to fix build error
* PM-20574 fixed a procedure issue
* PM-20574 fix dB build error
* PM-020574 fixed additional PR comments - files cleaned up
* PM-20574 updated procedure was inconsistent
* Update 2025-06-13-00_OrganizationReport.sql
---------
Co-authored-by: voommen-livefront <voommen@livefront.com>
* implement the seat decrease error message
* Resolve the comment regarding abstraction
* Resolved the database failure
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the failing test
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the failing test
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the failing upgrade test
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the failing test
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the failing test
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Removed the unused method
* Remove the total calculation from the stored procedure
* Refactoring base on pr feedback
* Refactoring base on pr feedback
* Resolve the fauiling database
* Resolve the failing database test
* Resolve the database test
* Remove duplicate migrations
* resolve the failing test
* Removed the unneeded change
* remove this file
* Reverted Deleted migration
* revert the added space
* resolve the stored procedure name
* Rename the migration name
* Updated the stored procedure name
* Revert the changes on the sproc
* Revert unrelated changes
* Remove the unused method
* improved the xmldoc
* Add an integration testing
* Add the use of helper test class
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the failing test
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the failing test
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* remove object look up
* Resolve message rollback
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
---------
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Avoid multiple lookups in dictionaries
* Consistency in fallback to empty CollectionIds
* Readability at the cost of lines changed
* Readability
* Changes after running dotnet format
* [PM-19282] Update SsoUser ExternalId column size to 300
* [PM-19282] Add migration to update SsoUser ExternalId column size to 300 for MySQL, PostgreSQL, and SQLite
* [PM-19282] Update SsoUser ExternalId column size conditionally based on existing schema
* Bumped date on migration script name
* Changes to resolve sponsorship showing in individual vault
* Resolve the failing unit test
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the failing test
* Resolve the failing test
* Resolve the failing test
* fix make IsAdminInitiated nullable
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Add the isAdminInitiated property
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the database error
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the failing unit test
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the scan error
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the database issue
* resolve the database build error
* Resolve the database build error
* Resolve the synchronization issue
---------
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
Adds a database seeder which can be used standalone using a CLI for seeding your local development environment, or used in unit tests to seed complex scenarios.
---------
Co-authored-by: Robert Y <rkac@bitwarden.com>
* Admin initiated sponsorships now use seats similarly to inviting an organization user
* Updated f4e endpoint to not expect a user ID, and instead just send a boolean
* Fixed failing tests
* Updated OrganizationUserReadOccupiedSeatCountByOrganizationIdQuery to ensure both left and right sides are selecting the same columns
* add cascade deletion for cipher tasks
* add migrations for cascade delete on ciphers and security tasks
* remove trailing comma
* add SQL migration for PasswordHealthReportApplication
- Allow cascade delete when an organization is deleted
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* Add `Notes` column to `OrganizationSponsorships` table
* Add feature flag to `CreateAdminInitiatedSponsorshipHandler`
* Unit tests for `CreateSponsorshipHandler`
* More tests for `CreateSponsorshipHandler`
* Forgot to add `Notes` column to `OrganizationSponsorships` table in the migration script
* `CreateAdminInitiatedSponsorshipHandler` unit tests
* Fix `CreateSponsorshipCommandTests`
* Encrypt the notes field
* Wrong business logic checking for invalid permissions.
* Wrong business logic checking for invalid permissions.
* Remove design patterns
* duplicate definition in Constants.cs
* Add the admin sponsored families to admin portal
* Add a feature flag
* Rename the migration file name
* Resolve the existing conflict and remove added file
* Add a migration for the change
* Remove the migration Because is already added
* Resolve the failing migration
---------
Co-authored-by: Jonas Hendrickx <jhendrickx@bitwarden.com>
* Copy and pasted scripts for admin initiated sponsorship to force migration in QA
* Include idempotency to ensure columns are correct if prior version of this script added them already without default value
* Ensure this script works if the default constraints already exist
* Organization integration creation, update, and deletion database logic
* Additional procs and entity tweaks
* Use check
* Couple newlines
* Forgot to script the two org procs
* WIP changes for Invite User optimization from Scim
* feature flag string
* Added plan validation to PasswordManagerInviteUserValidation. Cleaned up a few things.
* Added Secrets Manager Validations and Tests.
* Added bulk procedure for saving users, collections and groups from inviting. Added test to validate Ef and Sproc
* Created SendOrganizationInvitesCommand and moved some tests from OrgServiceTests. Fixed some tests in org service in relation to moving out SendOrgInviteCommand code.
Added side effects to InviteOrganizationUsersCommand
* First test of new command.
* Added test to verify valid request with a user calls db method and sends the invite
* Added more tests for the updates
* Added integration test around enabling feature and sending invite via scim. Did a bit of refactoring on the SM validation. Fixed couple bugs found.
* Switching over to a local factory.
* created response model and split interface out.
* switched to initialization block
* Moved to private method. Made ScimInvite inherit the single invite base model. Moved create methods to constructors. A few more CR changes included.
* Moved `FromOrganization` mapper method to a constructor
* Updated to use new pricing client. Supressed null dereference errors.
* Fixing bad merge.
* Rename of OrgDto
* undoing this
* Moved into class
* turned into a switch statement
* Separated into separate files.
* Renamed dto and added ctor
* Dto rename. Moved from static methods to ctors
* Removed unused request model
* changes from main
* missed value
* Fixed some compilation errors.
* Fixed some changes.
* Removed comment
* fixed compiler warning.
* Refactored to use new ValidationResult pattern. added mapping method.
* Added throwing of Failure as the previous implementation would have.
* Cleaned up return.
* fixing test.
* Made HasSecretsManagerStandalone return if org doesn't have sm. Added overload for lighter weight model and moved common code to private method.
* Fixed tests.
* Made public method private. added some comments.
* Refactor validation parameter to improve clarity and consistency. Added XML doc
* fixed test
* Removed test only constructor from InviteOrganization
* Separated old and new code explicitly. Moved old code checks down into new code as well. Added error and mapper to Failure<T>
* Variable/Field/Property renames
* Renamed InviteUsersValidation to InviteUsersValidator
* Rename for InvitingUserOrganizationValidation to InvitingUserOrganizationValidator
* PasswordManagerInviteUserValidation to PasswordManagerInviteUserValidator
* Moved XML comment. Added check to see if additional seats are needed.
* Fixing name.
* Updated names.
* Corrected double negation.
* Added groups and collection and users checks.
* Fixed comment. Fixed multiple enumeration. Changed variable name.
* Cleaned up DTO models. Moved some validation steps around. A few quick fixes to address CR concerns. Still need to move a few things yet.
* Fixed naming in subscription update models.
* put back in the request for now.
* Quick rename
* Added provider email addresses as well.
* Removed valid wrapper to pass in to validation methods.
* fix tests
* Code Review changes.
* Removed unused classes
* Using GetPlanOrThrow instead.
* Switches to extension method
* Made Revert and Adjust Sm methods consistent. Corrected string comparer. Added comment for revert sm.
* Fixing compiler complaint.
* Adding XML docs
* Calculated seat addition for SM.
* Fixing compiler complaints.
* Renames for organization.
* Fixing comparison issue.
* Adding error and aligning message.
* fixing name of method.
* Made extension method.
* Rearranged some things. Fixed the tests.
* Added test around validating the revert.
* Added test to validate the provider email is sent if org is managed by a provider.
* Created new errors and removed references in business code to ErrorMessages property. This aligns Invite User code to use Errors instead of ErrorMessages
* Delayed the hasSecretsManagerStandalone call as long as possible.
* Corrected model name. Corrected SM seat calculation. Added test for it.
* Corrected logic and added more tests.
* [PM-17563] Add case for PushType.PendingSecurityTasks
* [PM-17563] Add missing TaskId property to NotificationStatusDetails and NotificationResponseModel
* [PM-17563] Add migration script to re-create NotificationStatusDetailsView to include TaskId column
* [PM-17563] Select explicit columns for NotificationStatusDetailsView and fix migration script
* Moved RestoreUserAsync and RestoreUsersAsync to Command.
* Fixing the bug.
* Added test for bulk method.
* Fixing sonar cube warning.
* SonarQube warning fix.
* Excluding org users we already have.
* Fixed misspelling. Added integration test for method.
* test had the misspelling as well 🤦
* Split out interface. Added admin and confirmed constraints.
* fixed queries and added xml comments and tests.
* Refactor OrganizationUser status update procedure to use a GuidIdArray parameter and remove JSON parsing logic
* Fix OrganizationUser_SetStatusForUsersById procedure and bump script date
* Restore OrganizationUser_SetStatusForUsersById for possible server version rollback. Add new version with the name OrganizationUser_SetStatusForUsersByGuidIdArray
* Add migration script to add stored procedure OrganizationUser_SetStatusForUsersByGuidIdArray to update user status by GUID array
* feat(pm-15015) :
* Add `CountryName` column to AuthRequest Table in Database, and refreshing AuthRequestView
* Modify database stored procedures and Entity Framework migrations for AuthRequest Repositories
* Add property to `ICurrentContext` and response models.