Skip to content
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

Implement password update support #566

Merged
merged 2 commits into from
Jan 31, 2024
Merged

Implement password update support #566

merged 2 commits into from
Jan 31, 2024

Conversation

dani-garcia
Copy link
Member

Type of change

- [ ] Bug fix
- [x] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

Support re-encrypting the user key with the new password.

@dani-garcia dani-garcia requested a review from Hinton January 31, 2024 11:46
@bitwarden-bot
Copy link

bitwarden-bot commented Jan 31, 2024

Logo
Checkmarx One – Scan Summary & Details4bad733f-6629-4194-afa2-3f2a159404c4

No New Or Fixed Issues Found

Copy link

codecov bot commented Jan 31, 2024

Codecov Report

Attention: 23 lines in your changes are missing coverage. Please review.

Comparison is base (3064ac5) 51.65% compared to head (947a425) 52.30%.

Files Patch % Lines
crates/bitwarden-uniffi/src/crypto.rs 0.00% 10 Missing ⚠️
crates/bitwarden/src/mobile/crypto.rs 92.85% 7 Missing ⚠️
crates/bitwarden/src/mobile/client_crypto.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #566      +/-   ##
==========================================
+ Coverage   51.65%   52.30%   +0.65%     
==========================================
  Files         163      163              
  Lines        8202     8316     +114     
==========================================
+ Hits         4237     4350     +113     
- Misses       3965     3966       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

UserLoginMethod::Username { email, kdf, .. }
| UserLoginMethod::ApiKey { email, kdf, .. },
) => MasterKey::derive(new_password.as_bytes(), email.as_bytes(), kdf)?,
_ => return Err(Error::NotAuthenticated),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have another error type for these scenarios. You technically are authenticated it's just not compatible with the current operation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I went with this one because it was used in other places too, but this should probably be Error::InvalidAuthentication or something. We can change it but it's going to affect other places too, so I can leave it for another PR right after this one.

.await
.unwrap();

let new_password_response = update_password(&mut client, "123412341234".into()).unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to validate the new password hash too? We have a validate_password that could be used.

Copy link
Member Author

@dani-garcia dani-garcia Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, validate_password is validating a LocalAuthorization hash, while we would be returning a ServerAuthorization hash from the update_password function, right?

Edit: Just used hash_password directly and compared the outputs.

@dani-garcia dani-garcia merged commit 878cd4a into main Jan 31, 2024
57 checks passed
@dani-garcia dani-garcia deleted the ps/update-password branch January 31, 2024 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants