* Migrate Duo Two Factor Configuration to support both v2 and v4
* Postgres Migrations
* SQLite migrations
* comment updates for SQLite; Query changes for consistency;
* comment clean up; formatting
* Changes to make all teams and ent plan visible
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Resolve the typeo
---------
Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
* Add HasVerifiedDomainsAsync method to IOrganizationDomainService
* Add GetManagedUserIdsByOrganizationIdAsync method to IOrganizationUserRepository and the corresponding queries
* Fix case on the sproc OrganizationUser_ReadManagedIdsByOrganizationId parameter
* Update the EF query to use the Email from the User table
* dotnet format
* Fix IOrganizationDomainService.HasVerifiedDomainsAsync by checking that domains have been Verified and add unit tests
* Rename IOrganizationUserRepository.GetManagedUserIdsByOrganizationAsync
* Fix domain queries
* Add OrganizationUserRepository integration tests
* Add summary to IOrganizationDomainService.HasVerifiedDomainsAsync
* chore: Rename IOrganizationUserRepository.GetManagedUserIdsByOrganizationAsync to GetManyIdsManagedByOrganizationIdAsync
* Add IsManagedByAnyOrganizationAsync method to IUserRepository
* Add integration tests for UserRepository.IsManagedByAnyOrganizationAsync
* Refactor to IUserService.IsManagedByAnyOrganizationAsync and IOrganizationService.GetUsersOrganizationManagementStatusAsync
* chore: Refactor IsManagedByAnyOrganizationAsync method in UserService
* Refactor IOrganizationService.GetUsersOrganizationManagementStatusAsync to return IDictionary<Guid, bool>
* Extract IOrganizationService.GetUsersOrganizationManagementStatusAsync into a query
* Update comments in OrganizationDomainService to use proper capitalization
* Move OrganizationDomainService to AdminConsole ownership and update namespace
* feat: Add support for organization domains in enterprise plans
* feat: Add HasOrganizationDomains property to OrganizationAbility class
* refactor: Update GetOrganizationUsersManagementStatusQuery to use IApplicationCacheService
* Remove HasOrganizationDomains and use UseSso to check if Organization can have Verified Domains
* Refactor UserService.IsManagedByAnyOrganizationAsync to simply check the UseSso flag
* Add TODO comment for replacing 'UseSso' organization ability on user verified domain checks
* Bump date on migration script
* Add indexes to OrganizationDomain table
* Bump script migration date; Remove WITH ONLINE = ON from data migration.
* Added invoices and transaction history endpoints. Added cursor paging for each
* Removed try/catch since it's handled by middleware. Updated condition to use pattern matching
* Added unit tests for PaymentHistoryService
* Removed organizationId from account billing controller endpoints
* Add SQL script to migrate custom users with specific permissions to User type
Remove 'editAssignedCollections' and 'deleteAssignedCollections' properties from Permissions in OrganizationUser table. Migrate custom users who only have these permissions to the User type.
* Add MySQL migration to migrate custom users with specific permissions to User type
* Add Postgres migration to migrate custom users with specific permissions to User type
* Add Sqlite migration to migrate custom users with specific permissions to User type
* Update AutoFixture usage in tests to resolve creating ILogger mock instances
* Update EF integration tests database contexts to use each respective Migrations assembly. Configure Sqlite instance
* Add RunMigration method to BaseEntityFrameworkRepository
* Add FinalFlexibleCollectionsDataMigrationsTests
* Improve data migration efficiency by using OPENJSON instead of multiple JSON_EXTRACT
* Add batching to the sql data migrations
* Update DbMigrator to run a specific script based on its name
* Update DatabaseDataAttribute to be able to test a specific migration
* Add reference to the migration projects to Infrastructure.IntegrationTest
* Add integration test to test the migration FinalFlexibleCollectionsDataMigrations
* Remove EFIntegration tests and remove RunMigration method from BaseEntityFrameworkRepository
* Add IMigrationTesterService and implementations for SQL and EF migrations
* Add FinalFlexibleCollectionsDataMigrationsTests and remove test from OrganizationUserRepositoryTests
* Update sql data migration script based on performance feedback
* Bump date on EF migration scripts
* Add xmldoc comments to IMigrationTesterService and each implementation
* Bump up the date on the EF migration scripts
* Bump up dates on EF migrations
* Added tests to assert no unwanted changes are made to the permissions json. Refactor tests.
* Revert changes made to DbMigrator and refactor SqlMigrationTesterService to not use it.
* Add method description
* Fix test to assert no changes are made to custom user
* Remove unnecessary COALESCE and SELECT CASE
* Unident lines on SQL script
* Update DatabaseDataAttribute MigrationName property to be nullable
* Fix null reference checks
* Remove unnecessary COALESCE from Postgres script
* Bump dates on migration scripts
* Bump up dates on EF migrations
* Add migration tests for handling null
* Add test for non json values
* Fix test
* Remove migrations
* Recreate EF migrations
* Update Postgres data migration script to check for valid JSON in Permissions column
---------
Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
* [PM-10589] Update database defaults for collection management settings
* Update default values for 'LimitCollectionCreationDeletion' and 'AllowAdminAccessToAllCollectionItems' in Organization table
* Add checks before column constraint drop and constraint creation
* feat: Add stored procedure for reading organization user details with premium access by organization ID
The code changes include:
- Addition of a new stored procedure [dbo].[OrganizationUserUserDetailsWithPremiumAccess_ReadByOrganizationId] to read organization user details with premium access by organization ID
- Modification of the IUserService interface to include an optional parameter for checking two-factor authentication with premium access
- Modification of the UserService class to handle the new optional parameter in the TwoFactorIsEnabledAsync method
- Addition of a new method GetManyDetailsWithPremiumAccessByOrganizationAsync in the IOrganizationUserRepository interface to retrieve organization user details with premium access by organization ID
- Addition of a new view [dbo].[OrganizationUserUserDetailsWithPremiumAccessView] to retrieve organization user details with premium access
* Add IUserRepository.SearchDetailsAsync that includes the field HasPremiumAccess
* Check the feature flag on Admin.UsersController to see if the optimization runs
* Modify PolicyService to run query optimization if the feature flag is enabled
* Refactor the parameter check on UserService.TwoFactorIsEnabledAsync
* Run query optimization on public MembersController if feature flag is enabled
* Restore refactor
* Reverted change used for development
* Add unit tests for OrganizationService.RestoreUser
* Separate new CheckPoliciesBeforeRestoreAsync optimization into new method
* Add more unit tests
* Apply refactor to bulk restore
* Add GetManyDetailsAsync method to IUserRepository. Add ConfirmUsersAsync_vNext method to IOrganizationService
* Add unit tests for ConfirmUser_vNext
* Refactor the optimization to use the new TwoFactorIsEnabledAsync method instead of changing the existing one
* Removed unused sql scripts and added migration script
* Remove unnecessary view
* chore: Remove unused SearchDetailsAsync method from IUserRepository and UserRepository
* refactor: Use UserDetails constructor in UserRepository
* Add summary to IUserRepository.GetManyDetailsAsync
* Add summary descriptions to IUserService.TwoFactorIsEnabledAsync
* Remove obsolete annotation from IUserRepository.UpdateUserKeyAndEncryptedDataAsync
* refactor: Rename UserDetails to UserWithCalculatedPremium across the codebase
* Extract IUserService.TwoFactorIsEnabledAsync into a new TwoFactorIsEnabledQuery class
* Add unit tests for TwoFactorIsEnabledQuery
* Update TwoFactorIsEnabledQueryTests to include additional provider types
* Refactor TwoFactorIsEnabledQuery
* Refactor TwoFactorIsEnabledQuery and update tests
* refactor: Update TwoFactorIsEnabledQueryTests to include test for null TwoFactorProviders
* refactor: Improve TwoFactorIsEnabledQuery and update tests
* refactor: Improve TwoFactorIsEnabledQuery and update tests
* Remove empty <returns> from summary
* Update User_ReadByIdsWithCalculatedPremium stored procedure to accept JSON array of IDs
* Updated org edit form scripts to dynamically update expected values
* Added script to update null values on organization table
* Updated script to only add MaxStorageGb for premium tiers. Removed setting of seats since it's not a valid edge case
* Updated GetPlansHelper() to not use annonymous properties
* Remove Organization.FlexibleCollections from code
* Drop Organization.FlexibleCollections column in EF databases
(MSSQL column to be retained for 1 additional deployment to support rollback in cloud)
These sprocs were used to remove AccessAll from
cipher access logic. Now the original sprocs have been
updated with the new logic, these v2 sprocs are unused
and are being dropped to complete the EDD cycle.
These updated sprocs removed AccessAll from cipher access logic.
The non-versioned sprocs have been updated with the new logic and
these v2 copies are now unused. They are being dropped to complete
the EDD cycle.
Final removal of AccessAll logic in CollectionCipher sprocs. We had v2 sprocs already
containing this updated logic that were never used; copy the v2 logic back to the
original sprocs so that we start using it. v2 sprocs will be dropped later.
* Sql-backed IDistributedCache
* sqlserver cache table
* remove unused using
* setup EF entity
* cache indexes
* add back cipher
* revert SetupEntityFramework change
* ef cache
* EntityFrameworkCache
* IServiceScopeFactory for db context
* implement EntityFrameworkCache
* move to _serviceScopeFactory
* move to config file
* ef migrations
* fixes
* datetime and error codes
* revert migrations
* migrations
* format
* static and namespace fix
* use time provider
* Move SQL migration and remove EF one for the moment
* Add clean migration of just the new table
* Formatting
* Test Custom `IDistributedCache` Implementation
* Add Back Logging
* Remove Double Logging
* Skip Test When Not EntityFrameworkCache
* Format
---------
Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
* Added check for revoked users
* removed check for users as any user status with can manage access should hide the add access badge
* updated comments
* [deps] DbOps: Update EntityFrameworkCore to v8
* Only Run EnsureDeleted If Factory Owns Connection
This only worked because of a bug in dotnet/efcore#33930 that was fixed in 8.0.
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
* Moved AccountsBilling controller to be owned by Billing
* Added org billing history endpoint
* Updated GetBillingInvoicesAsync to only retrieve paid, open, and uncollectible invoices, and added option to limit results
* Removed invoices and transactions from GetBillingAsync
* Limiting the number of invoices and transactions returned
* Moved Billing models to Billing namespace
* Split billing info and billing history objects
* Removed billing method GetBillingBalanceAndSourceAsync
* Removed unused using
* Cleaned up BillingInfo a bit
* Update migration scripts to use `CREATE OR ALTER` instead of checking for the `OBJECT_ID`
* Applying limit to aggregated invoices after they return from Stripe
* inital changes
* add provider GatewayType migrations
* db provider migrations
* removed duo migrations added v2 metadata to duo response
* removed helper scripts
* remove signature from org duo
* added backward compatibility for Duo v2
* added tests for duo request + response models
* refactors to TwoFactorController
* updated test methods to be compartmentalized by usage
* fix organization add duo
* Assert.Empty() fix for validator