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-10947: Handle key connector unlock for existing user #842

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

matt-livefront
Copy link
Collaborator

@matt-livefront matt-livefront commented Aug 19, 2024

🎟️ Tracking

PM-10947

📔 Objective

This handles vault unlock for an existing user who uses key connector. If the identity token response has a key connector URL, we use the existence of that to fetch the user's key from key connector and unlock the vault.

📸 Screenshots

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-08-19.at.13.41.38.mp4

⏰ 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 Aug 19, 2024

Logo
Checkmarx One – Scan Summary & Details4e207949-c256-4ede-b5ae-2b16f615e384

No New Or Fixed Issues Found

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.57%. Comparing base (6cba789) to head (70fe2a6).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #842      +/-   ##
==========================================
+ Coverage   88.51%   88.57%   +0.05%     
==========================================
  Files         606      607       +1     
  Lines       30262    30299      +37     
==========================================
+ Hits        26787    26836      +49     
+ Misses       3475     3463      -12     

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

Comment on lines 660 to 668
if try await canUnlockWithDeviceKey(response) {
return nil
return .deviceKey
}

// Return the account if the vault still needs to be unlocked.
return try await stateService.getActiveAccount()
if try await canUnlockWithKeyConnectorKey(response) {
return .keyConnector
}

return try await .masterPassword(stateService.getActiveAccount())
Copy link
Member

Choose a reason for hiding this comment

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

🎨 I see this is repeated on func loginWithSingleSignOn(code: String, email: String) async throws -> LoginUnlockMethod. Could we extract this to its own func to be reused?
🎨 Additionally, it seems Codecov is not finding tests for the .deviceKey path and I'm not finding them neither, could a test be added for that case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good callout, I'll extract this and add a test for the device key flow!

Comment on lines 738 to 739
guard response.keyConnectorUrl != nil ||
response.userDecryptionOptions?.keyConnectorOption?.keyConnectorUrl != nil
Copy link
Member

Choose a reason for hiding this comment

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

🎨 In MAUI code we're also checking that this url is not empty.

Comment on lines +254 to +255
try await services.authRepository.unlockVaultWithDeviceKey()
coordinator.navigate(to: .complete)
Copy link
Member

Choose a reason for hiding this comment

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

🎨 It seems a test is missing for .deviceKey flow.

@matt-livefront matt-livefront merged commit 9d00511 into main Aug 20, 2024
9 checks passed
@matt-livefront matt-livefront deleted the matt/PM-10947-key-connector-existing-user branch August 20, 2024 17:58
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