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-14983] Support Optic ID and any future biometric authentication types #1146

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

bunnyhero
Copy link

🎟️ 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 58.33333% with 10 lines in your changes missing coverage. Please review.

Project coverage is 89.48%. Comparing base (a495a62) to head (ecbdb5d).
Report is 64 commits behind head on main.

Files with missing lines Patch % Lines
...e/Auth/Services/Biometrics/BiometricsService.swift 0.00% 4 Missing ⚠️
.../Auth/VaultUnlockSetup/VaultUnlockSetupState.swift 50.00% 4 Missing ⚠️
...Settings/AccountSecurity/AccountSecurityView.swift 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1146      +/-   ##
==========================================
- Coverage   89.49%   89.48%   -0.02%     
==========================================
  Files         688      688              
  Lines       43498    43519      +21     
==========================================
+ Hits        38929    38943      +14     
- Misses       4569     4576       +7     

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

Copy link
Contributor

Logo
Checkmarx One – Scan Summary & Details765bba69-2026-4afe-8153-4dd0d59143f9

No New Or Fixed Issues Found

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
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
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
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

@@ -251,6 +251,10 @@ extension Alert {
Localizations.pinRequireBioOrMasterPasswordRestart(Localizations.faceID)
case .touchID:
Localizations.pinRequireBioOrMasterPasswordRestart(Localizations.touchID)
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 statement be alphabetized

@@ -43,6 +43,10 @@ struct VaultUnlockSetupState: Equatable {
"FaceID"
case .touchID:
"TouchID"
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 be alphabetized

@@ -270,6 +270,10 @@ struct AccountSecurityView: View {
return Localizations.unlockWith(Localizations.faceID)
case .touchID:
return Localizations.unlockWith(Localizations.touchID)
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 statement to be alphabetized

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

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