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

[PM-9527] Add PIN validation support #912

Merged
merged 3 commits into from
Jul 19, 2024
Merged

Conversation

dani-garcia
Copy link
Member

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-9527

📔 Objective

Fede mentioned on Slack some time ago that we currently don't have a simple way to validate the user's PIN like we do with the password. Instead the way to do it was to call init_crypto and check that the result is not an error.

This requires more data than needed and does a lot of unnecessary operations, so I think it makes sense to expose a simpler way to do PIN verification.

In this PR we're decrypting the PIN protected user key and comparing it with the stored user key, similar to what we're doing with validate_password_user_key.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    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 confirmed
    issue 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

Copy link
Contributor

github-actions bot commented Jul 18, 2024

Logo
Checkmarx One – Scan Summary & Details9800bb59-3070-478d-b7c7-fc52c3c4d5d1

No New Or Fixed Issues Found

Copy link

codecov bot commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 89.18919% with 8 lines in your changes missing coverage. Please review.

Project coverage is 58.07%. Comparing base (acd14e6) to head (ab5427f).

Files Patch % Lines
crates/bitwarden-core/src/auth/client_auth.rs 0.00% 3 Missing ⚠️
crates/bitwarden-uniffi/src/auth/mod.rs 0.00% 3 Missing ⚠️
crates/bitwarden-core/src/auth/pin.rs 97.05% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #912      +/-   ##
==========================================
+ Coverage   57.92%   58.07%   +0.15%     
==========================================
  Files         193      194       +1     
  Lines       13120    13194      +74     
==========================================
+ Hits         7600     7663      +63     
- Misses       5520     5531      +11     

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

@dani-garcia dani-garcia requested a review from Hinton July 18, 2024 16:50
crates/bitwarden-uniffi/src/auth/mod.rs Outdated Show resolved Hide resolved

match login_method {
UserLoginMethod::Username { email, kdf, .. }
| UserLoginMethod::ApiKey { email, kdf, .. } => {
Copy link
Member

Choose a reason for hiding this comment

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

question: Do we expect Api key logins to use pin?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so, and I'm not sure if they would need password validation either. I think this is mostly a case of copying over the match to get email and kdf. We can return an error for ApiKey if you prefer though.

@dani-garcia dani-garcia merged commit 27a71d8 into main Jul 19, 2024
104 checks passed
@dani-garcia dani-garcia deleted the ps/PM-9527-validate-pin branch July 19, 2024 12:40
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.

2 participants