* Removed 2FA user interface from premium method signatures
* Added some more comments for clarity and small touchups.
* Add PremiumAccessCacheCheck feature flag to Constants.cs
* Add IPremiumAccessQuery interface and PremiumAccessQuery implementation for checking user premium access status
* Add unit tests for PremiumAccessQuery to validate user premium access logic
* Add XML documentation to Premium in OrganizationUserUserDetails and User classes
* Add PremiumAccessQueries to UserServiceCollectionExtensions
* Refactor TwoFactorIsEnabledQuery to incorporate PremiumAccessQuery and feature flag for premium access checks. Enhanced user premium status retrieval logic and improved handling of user details based on feature flag state.
* Mark methods in IUserRepository and IUserService as obsolete, directing users to new methods in IPremiumAccessQuery for premium access checks.
* Rename CanAccessPremiumBulkAsync to CanAccessPremiumAsync in IPremiumAccessQuery
* Update TwoFactorIsEnabledQuery to use CanAccessPremiumAsync for premium status checks
* Refactor TwoFactorIsEnabledQuery to introduce VNextAsync methods for improved premium access checks and user detail handling. Removed obsolete feature service dependency and enhanced test coverage for new functionality.
* Refactor IPremiumAccessQuery and PremiumAccessQuery to remove the overloaded CanAccessPremiumAsync method. Update related methods to streamline premium access checks using the User object directly. Enhance test coverage by removing obsolete tests and ensuring proper functionality with the new method signatures.
* Add new sync static method to determine if TwoFactor is enabled
* Enhance XML documentation for Premium property in OrganizationUserUserDetails and User classes to clarify its usage and limitations regarding personal and organizational premium access.
* Refactor IPremiumAccessQuery and PremiumAccessQuery to replace User parameter with Guid for user ID in CanAccessPremiumAsync methods. Update related methods and tests to streamline premium access checks and improve clarity in method signatures.
* Update feature flag references in IUserRepository and IUserService to use 'PremiumAccessQuery' instead of 'PremiumAccessCacheCheck'. Adjust related XML documentation for clarity on premium access methods.
* Rename IPremiumAccessQuery to IHasPremiumAccessQuery and move to Billing owned folder
* Remove unnecessary whitespace from IHasPremiumAccessQuery interface.
* Refactor HasPremiumAccessQuery to throw NotFoundException for null users
* Add NotFoundException handling in HasPremiumAccessQuery for mismatched user counts
* Refactor TwoFactorIsEnabledQuery to optimize premium access checks and improve two-factor provider handling. Introduced bulk fetching of premium status for users with only premium providers and streamlined the logic for determining if two-factor authentication is enabled.
* Refactor TwoFactorIsEnabledQueryTests to enhance clarity and optimize test scenarios. Consolidated test cases for two-factor authentication, improved naming conventions, and ensured premium access checks are only performed when necessary.
* Add UserPremiumAccess model to represent user premium access status from personal subscriptions and memberships
* Add User_ReadPremiumAccessByIds stored procedure and UserPremiumAccessView view to enhance premium access retrieval. Updated Organization table index to include UsersGetPremium for optimized queries.
* Add SQL migration script
* Add premium access retrieval methods to IUserRepository and implementations in UserRepository classes. Introduced GetPremiumAccessByIdsAsync and GetPremiumAccessAsync methods to fetch premium status for multiple users and a single user, respectively. Updated using directives to include necessary models.
* Refactor HasPremiumAccessQuery and IHasPremiumAccessQuery to streamline premium access checks. Updated method names for clarity and improved documentation. Adjusted test cases to reflect changes in user premium access retrieval logic.
* Update IUserRepository to reflect new method names for premium access retrieval. Changed obsolete method messages to point to GetPremiumAccessByIdsAsync and GetPremiumAccessAsync. Added internal use notes for IHasPremiumAccessQuery. Improved documentation for clarity.
* Refactor TwoFactorIsEnabledQuery to utilize IFeatureService for premium access checks.
* Enhance EF UserRepository to improve premium access retrieval by including related organization data.
* Add unit tests for premium access retrieval in UserRepositoryTests.
* Optimize HasPremiumAccessQuery to eliminate duplicate user IDs before checking premium access. Updated logic to ensure accurate comparison of premium users against distinct user IDs.
* Refactor TwoFactorIsEnabledQuery to improve handling of users without two-factor providers. Added early exit for users lacking providers and streamlined premium status checks for enabled two-factor authentication.
* Update HasPremiumAccessQueryTests to use simplified exception handling and improve test clarity
* Replaced fully qualified exception references with simplified ones.
* Refactored test setup to use individual user variables for better readability.
* Ensured assertions reflect the updated user variable structure.
* Enhance TwoFactorIsEnabledQuery to throw NotFoundException for non-existent users
* Updated TwoFactorIsEnabledQuery to throw NotFoundException when a user is not found instead of returning false.
* Added a new unit test to verify that the NotFoundException is thrown when a user is not found while premium access query is enabled.
* Move premium access query to Billing owned ServiceCollectionExtensions
* Refactor IUserService to enhance premium access checks
* Updated CanAccessPremium and HasPremiumFromOrganization methods to clarify usage with the new premium access query.
* Integrated IHasPremiumAccessQuery into UserService for improved premium access handling based on feature flag.
* Adjusted method documentation to reflect changes in premium access logic.
* Update IUserRepository to clarify usage of premium access methods
* Modified Obsolete attribute messages for GetManyWithCalculatedPremiumAsync and GetCalculatedPremiumAsync to indicate that callers should use the new methods when the 'PremiumAccessQuery' feature flag is enabled.
* Enhanced documentation to improve clarity regarding premium access handling.
* Update IUserRepository and IUserService to clarify deprecation of premium access methods
* Modified Obsolete attribute messages for GetManyWithCalculatedPremiumAsync and GetCalculatedPremiumAsync in IUserRepository to indicate these methods will be removed in a future version.
* Updated Obsolete attribute message for HasPremiumFromOrganization in IUserService to reflect the same deprecation notice.
* Refactor TwoFactorIsEnabledQuery to streamline user ID retrieval
* Consolidated user ID retrieval logic to avoid redundancy.
* Ensured consistent handling of user ID checks for premium access queries.
* Improved code readability by reducing duplicate code blocks.
* Rename migration script to fix the date
* Update migration script to create the index with DROP_EXISTING = ON
* Refactor UserPremiumAccessView to use LEFT JOINs and GROUP BY for improved performance and clarity
* Update HasPremiumAccessQueryTests to return null for GetPremiumAccessAsync instead of throwing NotFoundException
* Add unit tests for premium access scenarios in UserRepositoryTests
- Implement tests for GetPremiumAccessAsync to cover various user and organization premium access combinations.
- Validate behavior when users belong to multiple organizations, including cases with and without premium access.
- Update email generation for user creation to ensure uniqueness without specific prefixes.
- Enhance assertions to verify expected premium access results across different test cases.
* Bump date on migration script
* Update OrganizationEntityTypeConfiguration to include UsersGetPremium in index properties
* Add migration scripts for OrganizationUsersGetPremiumIndex across MySQL, PostgreSQL, and SQLite
- Introduced new migration files to create the OrganizationUsersGetPremiumIndex.
- Updated the DatabaseContextModelSnapshot to include UsersGetPremium in index properties for all database types.
- Ensured consistency in index creation across different database implementations.
---------
Co-authored-by: Todd Martin <tmartin@bitwarden.com>
Co-authored-by: Patrick Pimentel <ppimentel@bitwarden.com>
* PM-28616 Add flag UsePhishingBlocker to dbo.Organization
* PM-28616 updated as per comments from claude
* PM-28616 updated ToLicense Method to copy the license file
* PM-28616 allow phishing blocker to be imported via license files for self-hosted
* PM-28616 updated PR comments - added more views to be refreshed
* PM-28616 removed proeprty from constructor as it is not used anymore. We have moved to claims based properties
* Add changes for initial migration
* Fix the failing Database test
* Fix the failing database test
* Address the pr comments
* revert some change sthat are not
* Address the remaining comments
* Remove unused object
* remove MaxStorageGbIncreased in the views
* refresh commands will ensure all stored procedures
* Fix the typo
Shift from seeded data tracking that is all server-side to play ids and x-play-id headers that are appended from the clients to track entities added by tests.
* Adding AutoConfrim and migrations.
* Add value to Admin Page and update sproc to correct name.
* Correcting license constant.
* Adding feature check back in.
* Fixing sprocs :face_palm:
* Remove Coalesce
* Adding property to plan and model constructor
* Correcting name of column. Cascading change throughout. Updating response models. Updating sprocs and views. Updating migrations
* fixing sproc
* Fixing up license stuff.
* Updating org view
* Code review changes and renames :face_palm:
* Refershing additional views
* Last two fixes.
* Adding SecretVersion table to server
* making the names singular not plural for new table
* removing migration
* fixing migration
* Adding indexes for serviceacct and orguserId
* indexes for sqllite
* fixing migrations
* adding indexes to secretVeriosn.sql
* tests
* removing tests
* adding GO
* Adding new logging for secrets
* fixing secrest controller tests
* fixing the tests
* Server side changes for adding ProjectId to Event table, adding Project event logging to projectsController
* Rough draft with TODO's need to work on EventRepository.cs, and ProjectRepository.cs
* Undoing changes to make projects soft delete, we want those to be fully deleted still. Adding GetManyTrashedSecretsByIds to secret repo so we can get soft deleted secrets, getSecrets in eventsController takes in orgdId, so that we can check the permission even if the secret was permanently deleted and doesn' thave the org Id set. Adding Secret Perm Deleted, and Restored to event logs
* db changes
* fixing the way we log events
* Trying to undo some manual changes that should have been migrations
* adding migration files
* fixing test
* setting up userid for project controller tests
* adding sql
* sql
* Rename file
* Trying to get it to for sure add the column before we try and update sprocs
* Adding code to refresh the view to include ProjectId I hope
* code improvements
* Suggested changes
* suggested changes
* trying to fix sql issues
* fixing swagger issue
* Update src/Core/SecretsManager/Repositories/Noop/NoopSecretRepository.cs
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
* Suggested changes
* Adding event logging for machine accounts
* fixing two tests
* trying to fix all tests
* trying to fix tests
* fixing test
* Migrations
* fix
* updating eps
* adding migration
* Adding missing SQL changes
* updating sql
* fixing sql
* running migration again
* fixing sql
* adding query to add grantedSErviceAccountId to event table
* Suggested improvements
* removing more migrations
* more removal
* removing all migrations to them redo them
* redoing migration
---------
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
* PM-23754 initial commit
* pm-23754 fixing controller tests
* pm-23754 adding commands and queries
* pm-23754 adding endpoints, command/queries, repositories, and sql migrations
* pm-23754 add new sql scripts
* PM-23754 adding sql scripts
* pm-23754
* PM-23754 fixing migration script
* PM-23754 fixing migration script again
* PM-23754 fixing migration script validation
* PM-23754 fixing db validation script issue
* PM-23754 fixing endpoint and db validation
* PM-23754 fixing unit tests
* PM-23754 fixing implementation based on comments and tests
* PM-23754 updating logging statements
* PM-23754 making changes based on PR comments.
* updating migration scripts
* removing old migration files
* update code based testing for whole data object for OrganizationReport and add a stored procedure.
* updating services, unit tests, repository tests
* fixing unit tests
* fixing migration script
* fixing migration script again
* fixing migration script
* another fix
* fixing sql file, updating controller to account for different orgIds in the url and body.
* updating error message in controllers without a body
* making a change to the command
* Refactor ReportsController by removing organization reports
The IDropOrganizationReportCommand is no longer needed
* will code based on PR comments.
* fixing unit test
* fixing migration script based on last changes.
* adding another check in endpoint and adding unit tests
* fixing route parameter.
* PM-23754 updating data fields to return just the column
* PM-23754 fixing repository method signatures
* PM-23754 making change to orgId parameter through out code to align with api naming
---------
Co-authored-by: Tom <144813356+ttalty@users.noreply.github.com>
* Adding new logging for secrets
* fixing secrest controller tests
* fixing the tests
* Server side changes for adding ProjectId to Event table, adding Project event logging to projectsController
* Rough draft with TODO's need to work on EventRepository.cs, and ProjectRepository.cs
* Undoing changes to make projects soft delete, we want those to be fully deleted still. Adding GetManyTrashedSecretsByIds to secret repo so we can get soft deleted secrets, getSecrets in eventsController takes in orgdId, so that we can check the permission even if the secret was permanently deleted and doesn' thave the org Id set. Adding Secret Perm Deleted, and Restored to event logs
* db changes
* fixing the way we log events
* Trying to undo some manual changes that should have been migrations
* adding migration files
* fixing test
* setting up userid for project controller tests
* adding sql
* sql
* Rename file
* Trying to get it to for sure add the column before we try and update sprocs
* Adding code to refresh the view to include ProjectId I hope
* code improvements
* Suggested changes
* suggested changes
* trying to fix sql issues
* fixing swagger issue
* Update src/Core/SecretsManager/Repositories/Noop/NoopSecretRepository.cs
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
* Suggested changes
---------
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
* Adding job to update stripe subscriptions and increment seat count when inviting a user.
* Updating name
* Added ef migrations
* Fixing script
* Fixing procedures. Added repo tests.
* Fixed set stored procedure. Fixed parameter name.
* Added tests for database calls and updated stored procedures
* Fixed build for sql file.
* fixing sproc
* File is nullsafe
* Adding view to select from instead of table.
* Updating UpdateSubscriptionStatus to use a CTE and do all the updates in 1 statement.
* Setting revision date when incrementing seat count
* Added feature flag check for the background job.
* Fixing nullable property.
* Removing new table and just adding the column to org. Updating to query and command. Updated tests.
* Adding migration script rename
* Add SyncSeats to Org.sql def
* Adding contraint name
* Removing old table files.
* Added tests
* Upped the frequency to be at the top of every 3rd hour.
* Updating error message.
* Removing extension method
* Changed to GuidIdArray
* Added xml doc and switched class to record
* [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>
* [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
* 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
* 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.
feat(NewDeviceVerification) :
* Created database migration scripts for VerifyDevices column in [dbo].[User].
* Updated DeviceValidator to check if user has opted out of device verification.
* Added endpoint to AccountsController.cs to allow editing of new User.VerifyDevices property.
* Added tests for new methods and endpoint.
* Updating queries to track [dbo].[User].[VerifyDevices].
* Updated DeviceValidator to set `User.EmailVerified` property during the New Device Verification flow.
* Add SQL files
* Add SQL Server migration
* Add Core entity
* Add Dapper repository
* Add EF repository
* Add EF migrations
* Save OrganizationInstallation during GetLicense invocation
* Run dotnet format
* PM-13236 PasswordHealthReportApplications db
* PM-13236 incorporated pr comments
* PM-13236 fixed error in SQL script
* PM-13236 resolve quality scan errors SQL71006, SQL7101, SQL70001
* PM-13236 fixed warnings on procedures
* PM-13236 added efMigrations
* PM-13236 renamed files to PasswordHealthReportApplication (singular)
* PM-13236 changed file name to more appropriate naming
* PM-13236 changed the file name singular
* PM-13236 PasswordHealthReportApplication Entities and Repos
* PM-13236 moved files under tools from core
* PM-13236 Entity PasswordHealthReportApplication namespace changed to tools/entities
* PM-13236 moved Repos and Interfaces to tools
* PM-13236 migrated model to tools namespace
* PM-13236 minor fixes to the unit tests
* PM-13236 fixed script errors during build
* PM-13236 Script to drop PasswordHealthReportApplications if it exists
* PM-13236 fixes to database snapshot
* PM-13236 updated databasesnapshots
* PM-13236 Update database model changes for Mysql
* PM-13236 update model changes for Sqlite
* PM-13236 updated the models to remove commented code
* PM-13236 added correct db snapshot for MySql
* PM-13236 updated database snapshot for Postgres
* PM-13236 updated database snapshot for Sqlite
* PM-13236 removed unwanted directive to fix linting error
* PM-13236 removed redundant script files
* Move existing Billing SQL files into dbo folder
I noticed that every other team had a nested dbo folder under their team folder while Billing did not. This change replicates that.
* Add SQL files for ClientOrganizationMigrationRecord table
* Add SQL Server migration for ClientOrganizationMigrationRecord table
* Add ClientOrganizationMigrationRecord entity and repository interface
* Add ClientOrganizationMigrationRecord Dapper repository
* Add ClientOrganizationMigrationRecord EF repository
* Add EF migrations for ClientOrganizationMigrationRecord table
* Implement migration process
* Wire up new Admin tool to migrate providers
* Run dotnet format
* Updated coupon and credit application per product request
* AC-3057-3058: Fix expiration date and enabled from webhook processing
* Run dotnet format
* AC-3059: Fix assigned seats during migration
* Updated AllocatedSeats in the case plan already exists
* Update migration scripts to reflect current date
* Add new columns to `dbo.Organization` & its references
* Feed existing data into new `dbo.Organization` column
* Update Entity Framework database definitions
* Move new EF columns out of the core entity definition
* Generate Entity Framework migrations
* Feed existing data into new `Organization` Entity Framework columns
* Add a where clause to SQL migration
* 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