Files
server/util/Migrator/DbScripts/2026-02-28_00_AlterUserAddMasterPasswordSalt.sql
Ike 0d88aa1ca1 [PM-21925] Add MasterPasswordSalt Column to User Table (#6950)
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
2026-03-05 11:47:08 -05:00

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