-
Notifications
You must be signed in to change notification settings - Fork 15
[PM-24051] MasterPasswordUnlockData model with response mapping and adds it to identity success response model #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #376 +/- ##
==========================================
+ Coverage 74.19% 74.35% +0.16%
==========================================
Files 253 255 +2
Lines 21897 22120 +223
==========================================
+ Hits 16247 16448 +201
- Misses 5650 5672 +22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments, some of these are required, some are idiomatic (but probably required since the quality bar for SDK seems to be set much higher).
I'd like a review from someone with more rust experience such as @Hinton or @dani-garcia too. I believe specifically the request parsing is something that has not existed in the SDK so far, and there may be a better way to do this that we're unaware of.
crates/bitwarden-wasm-internal/src/key_management/master_password.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty nice now! Some more smaller items that improve usability by teams unfamiliar with the code (docs / error names)
crates/bitwarden-wasm-internal/src/key_management/user_decryption.rs
Outdated
Show resolved
Hide resolved
This tightly couples consumers of the SDK to the server generated bindings which is somewhat dangerous. We've previously addressed this by wrapping requests/responses in a manner that more accurately represents the action from the SDK's perspective. There be dragons here and we should consider this a bit. Do we expect to do similar things to other request/responses? If not I think we should simply wrap the logic with our own struct, while it's a few lines of boilerplate it reduces the complexity.
There is no UniFFI support here. |
crates/bitwarden-wasm-internal/src/key_management/user_decryption.rs
Outdated
Show resolved
Hide resolved
crates/bitwarden-api-api/src/models/master_password_unlock_response_model.rs
Outdated
Show resolved
Hide resolved
…ption-options-to-identity-sync-response
…r and docs improvements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: The PR title mentions sync response, there is nothing touching sync here.
We should be careful about introducing public objects that are not consumed. Once something is public it's technically a breaking change to flip the visibility and if you don't know fully what needs to be public it's easy to accidentally leave public remnants that should be private.
In these case just making items private and going back later and flipping the visibility where necessary can be useful. Which can also assist with documentation since documentation should be written from the consumers standpoint which is hard when you don't have the interfaces making it public.
crates/bitwarden-core/src/auth/api/response/identity_success_response.rs
Outdated
Show resolved
Hide resolved
memory: kdf_parse_nonzero_u32( | ||
response | ||
.kdf | ||
.memory | ||
.ok_or(MasterPasswordError::KdfMalformed)?, | ||
)?, | ||
parallelism: kdf_parse_nonzero_u32( | ||
response | ||
.kdf | ||
.parallelism | ||
.ok_or(MasterPasswordError::KdfMalformed)?, | ||
)?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is there a reason for not just using require!
?
memory: kdf_parse_nonzero_u32( | |
response | |
.kdf | |
.memory | |
.ok_or(MasterPasswordError::KdfMalformed)?, | |
)?, | |
parallelism: kdf_parse_nonzero_u32( | |
response | |
.kdf | |
.parallelism | |
.ok_or(MasterPasswordError::KdfMalformed)?, | |
)?, | |
memory: kdf_parse_nonzero_u32(require!(response.kdf.memory))?, | |
parallelism: kdf_parse_nonzero_u32(require!(response.kdf.parallelism))?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quexten pointed out, that it might be better to consolidate all KDF related verification into the KdfMalformed
error. Using require!
would provide non-KDF specific error.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my side.
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-24051
📔 Objective
Adds
MasterPasswordUnlockData
model withMasterPasswordUnlockResponseModel
mapping. This wiAdds
UserDecryptionOptionsResponseModel
into the identity success token response. This model includes the master password unlock field.The
/sync
response model is autogenerated by OpenApi and already includes user decryption option and the master password unlock fields.Includes Uniffi and WASM bindings for
MasterPasswordUnlock
.In further PR's we plan to use the
MasterPasswordUnlock
inInitUserCryptoMethod
enum - this is still in discussion.⏰ Reminders before review
team
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmedissue and could potentially benefit from discussion
:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes