Auth/PM-34130 - Fix DeviceAuthDetails constructor and stored procedure for EDD compliance#7416
Conversation
… EDD compliance Replace positional 14-arg Dapper constructor with parameterless constructor and property-setter mapping; rename AuthRequestCreatedAt to AuthRequestCreationDate; convert IsTrusted to a computed property; update stored procedure to use explicit column list instead of SELECT D.* for EDD-safe name-based Dapper mapping; add migration script; expand integration tests for full field mapping, IsTrusted logic, Unlock type eligibility, inactive device exclusion, and empty device list.
|
New Issues (4)Checkmarx found the following issues in this Pull Request
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7416 +/- ##
==========================================
+ Coverage 58.49% 62.99% +4.50%
==========================================
Files 2066 2066
Lines 91140 91104 -36
Branches 8111 8109 -2
==========================================
+ Hits 53308 57388 +4080
+ Misses 35924 31722 -4202
- Partials 1908 1994 +86 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
… fields Copy UserId, PushToken, RevisionDate, EncryptedPrivateKey, and Active from the source Device in the EF constructor. Previously these fields were omitted, causing IsTrusted to always return false for EF-sourced results.
Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR fixes EDD compliance issues in the Code Review DetailsNo findings. |
src/Sql/dbo/Auth/Stored Procedures/Device_ReadActiveWithPendingAuthRequestsByUserId.sql
Outdated
Show resolved
Hide resolved
src/Sql/dbo/Auth/Stored Procedures/Device_ReadActiveWithPendingAuthRequestsByUserId.sql
Outdated
Show resolved
Hide resolved
src/Sql/dbo/Auth/Stored Procedures/Device_ReadActiveWithPendingAuthRequestsByUserId.sql
Outdated
Show resolved
Hide resolved
dcb1300
…uctor-not-edd-compliant
…uctor-not-edd-compliant
|






🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-34130
📔 Objective
Device_ReadActiveWithPendingAuthRequestsByUserId— replacesSELECT D.*and a positional 14-arg Dapper constructor with an explicit column list and name-based property mapping. Note: per discussion with DbOps, the use of explicit column mapping is preferred in this scenario over the style guide's current selectD.*recommendation just to be safer regarding an alias / column name collision between the device and auth request tables.DeviceAuthDetailswhich was missing five field copies, causingIsTrustedto always returnfalsefor EF-sourced results.IsTrustedfrom a stored value to a computed property.Note: no API changes are present so there won't be any corresponding clients work.
Detailed Changes
Core Models
src/Core/Auth/Models/Data/DeviceAuthDetails.csIsTrustedto a computed property (DeviceExtensions.IsTrusted(this)) so its value is always derived from the current state of the encrypted key fields rather than depending on correct assignment in every constructor code pathDevicefields (previously missingUserId,PushToken,RevisionDate,EncryptedPrivateKey,Active)AuthRequestCreatedAt→AuthRequestCreationDate— required for Dapper name-based mapping; the property name must match the column alias returned by the stored procedure (AR.CreationDate AS AuthRequestCreationDate)src/Core/Auth/Models/Api/Response/DeviceAuthRequestResponseModel.csAuthRequestCreatedAttoAuthRequestCreationDateDatabase
src/Sql/dbo/Auth/Stored Procedures/Device_ReadActiveWithPendingAuthRequestsByUserId.sqlSELECT D.*with an explicit column list to enable name-based Dapper mapping via property setters, eliminating the positional dependency that caused silent mismatches on schema changesLEFT JOIN→LEFT OUTER JOIN— required by the Bitwarden SQL style guide (full join type names must be used)util/Migrator/DbScripts/2026-04-07_00_Alter_Device_ReadActiveWithPendingAuthRequestsByUserId.sqlCREATE OR ALTER)Tests
test/Infrastructure.IntegrationTest/Auth/Repositories/DeviceRepositoryTests.csExpanded integration test coverage for
GetManyByUserIdWithDeviceAuth:IsTrustedcomputed correctly from encrypted keys📸 Screenshots
PM-34130.-.Devices.screen.works.mov