8000 [PM-14983] Support Optic ID and any future biometric authentication types by bunnyhero · Pull Request #1146 · bitwarden/ios · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[PM-14983] Support Optic ID and any future biometric authentication types #1146

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

Merged
merged 11 commits into from
Jan 29, 2025

Conversation

bunnyhero
Copy link
Contributor

🎟️ Tracking

📔 Objective

Support Optic ID and any future biometric authentication types.

📸 Screenshots

ezgif-2-88c91a6784

⏰ 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

# Conflicts:
#	BitwardenShared/UI/Platform/Application/Support/Localizations/en.lproj/Localizable.strings
@CLAassistant
Copy link
CLAassistant commented Nov 17, 2024

CLA assistant check
All committers have signed the CLA.

@bitwarden-bot
Copy link

Thank you for your contribution! We've added this to our internal Community PR board for review.
ID: PM-14983

@bitwarden-bot bitwarden-bot changed the title Optic [PM-14983] Optic Nov 17, 2024
@bunnyhero bunnyhero changed the title [PM-14983] Optic [PM-14983] Support Optic ID and any future biometric authentication types Nov 17, 2024
Copy link
Contributor
@KatherineInCode KatherineInCode left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I've left a quick note about some comments, but will try to give this the fuller attention it deserves when I get a chance.

@KatherineInCode
Copy link
Contributor

Hi! 👋🏻 It looks like there's a conflict in the strings file; can you please resolve that?

Copy link
codecov bot commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 10 lines in your changes missing coverage. Please review.

Project coverage is 89.46%. Comparing base (f50ef9b) to head (72b7be3).
Report is 51 commits behind head on main.

Files with missing lines Patch % Lines
...e/Auth/Services/Biometrics/BiometricsService.swift 0.00% 6 Missing ⚠️
.../Auth/VaultUnlockSetup/VaultUnlockSetupState.swift 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1146      +/-   ##
==========================================
+ Coverage   89.42%   89.46%   +0.03%     
==========================================
  Files         724      740      +16     
  Lines       45773    46452     +679     
==========================================
+ Hits        40933    41558     +625     
- Misses       4840     4894      +54     

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

Copy link
Contributor
github-actions bot commented Dec 31, 2024

Logo
Checkmarx One – Scan Summary & Details0222d0dc-97aa-401d-8959-328d3098faba

Great job, no security vulnerabilities found in this Pull Request

Copy link
Contributor
@KatherineInCode KatherineInCode left a comment

Choose a reason for hiding this comment

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

Thank you again for your contribution! On the whole this looks good, just a lot of little things to get it in line with our typical code organization.

I'm not sure what the best solution for the capitalization of "biometrics" for the unknown case is, though. I would say it may make more sense to leave it out as a default case, but it looks like that's an error as of Swift 6, which is reasonable. We may need a string specifically for when the generic biometrics is used in a larger string, like this; it's probably worth investigating how we handle this elsewhere in the app, I just don't know it offhand.

case opticID

/// Unknown other biometric authentication
case biometrics
Copy link
Contributor

Choose a reason for hiding this comment

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

🎨 I think this case would be better named unknown, in line with its comment. Based on the type we already know it's biometrics, and it'd be better to be clear that it's a type unknown to us currently. That said, I think keeping it the generic "Use biometrics to unlock" in the strings file is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have renamed the case to unknown.

@@ -129,6 +129,30 @@ class VaultUnlockSetupProcessorTests: BitwardenTestCase {
XCTAssertEqual(subject.state.unlockMethods, [.biometrics(.touchID), .pin])
}

/// `perform(_:)` with `.loadData` fetches the biometrics unlock status for a device with Optic ID.
Copy link
Contributor

Choose a reason for hiding this comment

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

🎨 We prefer tests to be alphabetized if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have alphabetized the added tests.

case .opticID:
Localizations.unlockWith(Localizations.opticID)
case .biometrics:
Localizations.unlockWith(Localizations.biometrics)
Copy link
Contributor

Choose a reason for hiding this comment

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

🎨 When this shows up on the Vault Unlock Setup screen, it produces the sentence "Unlock with Biometrics", and I'm not sure that's how we want to capitalize that:
Screenshot 2024-12-31 at 11 08 05 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a new localization string entry for unknownBiometrics that is lowercased.

case .opticID:
Localizations.pinRequireBioOrMasterPasswordRestart(Localizations.opticID)
case .biometrics:
Localizations.pinRequireBioOrMasterPasswordRestart(Localizations.biometrics)
Copy link
Contributor

Choose a reason for hiding this comment

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

🎨 This is another case where "Biometrics" being capitalized looks weird.

@@ -222,6 +222,28 @@ class AlertSettingsTests: BitwardenTestCase {
XCTAssertEqual(subject.message, Localizations.pinRequireBioOrMasterPasswordRestart(Localizations.touchID))
}

/// `unlockWithPINCodeAlert(action)` constructs an `Alert` with the correct title, message, Yes and No buttons
/// when `biometricType` is `opticID`.
func test_unlockWithPINAlert_opticID() {
Copy link
Contributor

Choose a reason for hiding this comment

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

🎨 We prefer tests to be in alphabetical order

case .opticID:
return Localizations.unlockWith(Localizations.opticID)
case .biometrics:
return Localizations.unlockWith(Localizations.biometrics)
Copy link
Contributor

Choose a reason for hiding this comment

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

🎨 This is another case where the capitalization gets us

Copy link
Contributor
@KatherineInCode KatherineInCode left a comment

Choose a reason for hiding this comment

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

Looks good! Just a few more small things!

return .none
case .touchID:
return .touchID
case .faceID:
return .faceID
case .opticID:
Copy link
Contributor

Choose a reason for hiding this comment

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

🎨 We prefer cases in a switch to be alphabetized; we must have missed .faceID being in the wrong place before

@@ -195,6 +195,10 @@ struct VaultUnlockView: View {
Text(Localizations.useFaceIDToUnlock)
case .touchID:
Text(Localizations.useFingerprintToUnlock)
case .opticID:
Copy link
Contributor

Choose a reason for hiding this comment

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

🎨 We prefer cases in a switch to be alphabetized

@@ -1059,6 +1059,9 @@
"CopyPrivateKey" = "Copy private key";
"CopyFingerprint" = "Copy fingerprint";
"SSHKeys" = "SSH keys";
"OpticID" = "Optic ID";
"UseOpticIDToUnlock" = "Use Optic ID To Unlock";
"UnknownBiometrics" = "biometrics";
Copy link
Contributor

Choose a reason for hiding this comment

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

🎨 I can't find any other good examples of where we have both an uppercased and lowercased version of a string like this, or where we're doing the casing manually. I feel like it would be better for us to have an UnlockWithBiometrics string, and to use that in VaultUnlockSetupState.UnlockMethod.title specifically for the .unknown case instead of Localizations.unlockWith(...). This would also match how UnlockWithPIN works, I feel.

XCTAssertEqual(subject.alertActions.count, 2)
XCTAssertEqual(subject.preferredStyle, .alert)
XCTAssertEqual(subject.title, Localizations.unlockWithPIN)
XCTAssertEqual(subject.message, Localizations.pinRequireBioOrMasterPasswordRestart(Localizations.unknownBiometrics))
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This got updated in the Strings file, but this test currently doesn't compile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that! Forgot to run the tests. Should be fixed now.

@KatherineInCode
Copy link
Contributor

👍🏻 Thank you again for your contribution! This looks good to me, and I'm going to start pushing it along to our QA.

@KatherineInCode KatherineInCode merged commit c746146 into bitwarden:main Jan 29, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0