mirror of
https://github.com/bitwarden/server.git
synced 2026-04-12 00:31:55 -05:00
feat: add MasterPasswordSalt column to User table - Add MasterPasswordSalt column to User table in both Dapper and EF implementations - Update User stored procedures (Create, Update, UpdateMasterPassword) to handle salt column - Add EF migrations and update UserView with dependent views - Set MaxLength constraint on MasterPasswordSalt column - Update UserRepository implementations to manage salt field - Add comprehensive test coverage for salt handling and normalization
70 lines
1.9 KiB
Transact-SQL
70 lines
1.9 KiB
Transact-SQL
IF COL_LENGTH('[dbo].[User]', 'MasterPasswordSalt') IS NULL
|
|
BEGIN
|
|
ALTER TABLE [dbo].[User] ADD [MasterPasswordSalt] NVARCHAR(256) NULL;
|
|
END
|
|
GO
|
|
|
|
-- Update UserView to include MasterPasswordSalt
|
|
CREATE OR ALTER VIEW [dbo].[UserView]
|
|
AS
|
|
SELECT
|
|
[Id],
|
|
[Name],
|
|
[Email],
|
|
[EmailVerified],
|
|
[MasterPassword],
|
|
[MasterPasswordHint],
|
|
[Culture],
|
|
[SecurityStamp],
|
|
[TwoFactorProviders],
|
|
[TwoFactorRecoveryCode],
|
|
[EquivalentDomains],
|
|
[ExcludedGlobalEquivalentDomains],
|
|
[AccountRevisionDate],
|
|
[Key],
|
|
[PublicKey],
|
|
[PrivateKey],
|
|
[Premium],
|
|
[PremiumExpirationDate],
|
|
[RenewalReminderDate],
|
|
[Storage],
|
|
COALESCE([MaxStorageGbIncreased], [MaxStorageGb]) AS [MaxStorageGb],
|
|
[Gateway],
|
|
[GatewayCustomerId],
|
|
[GatewaySubscriptionId],
|
|
[ReferenceData],
|
|
[LicenseKey],
|
|
[ApiKey],
|
|
[Kdf],
|
|
[KdfIterations],
|
|
[KdfMemory],
|
|
[KdfParallelism],
|
|
[CreationDate],
|
|
[RevisionDate],
|
|
[ForcePasswordReset],
|
|
[UsesKeyConnector],
|
|
[FailedLoginCount],
|
|
[LastFailedLoginDate],
|
|
[AvatarColor],
|
|
[LastPasswordChangeDate],
|
|
[LastKdfChangeDate],
|
|
[LastKeyRotationDate],
|
|
[LastEmailChangeDate],
|
|
[VerifyDevices],
|
|
[SecurityState],
|
|
[SecurityVersion],
|
|
[SignedPublicKey],
|
|
[V2UpgradeToken],
|
|
[MasterPasswordSalt]
|
|
FROM
|
|
[dbo].[User]
|
|
GO
|
|
|
|
-- Refresh views that depend on UserView to ensure they include the new MasterPasswordSalt column
|
|
EXEC sp_refreshview N'[dbo].[EmergencyAccessDetailsView]';
|
|
EXEC sp_refreshview N'[dbo].[OrganizationUserUserDetailsView]';
|
|
EXEC sp_refreshview N'[dbo].[ProviderUserUserDetailsView]';
|
|
EXEC sp_refreshview N'[dbo].[UserEmailDomainView]';
|
|
EXEC sp_refreshview N'[dbo].[UserPremiumAccessView]';
|
|
GO
|