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

Refactor FXIOS-10788 [Logins] Apply necessary adjustments for A-S EncryptorDecryptor update #24108

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

Conversation

issammani
Copy link
Collaborator

@issammani issammani commented Jan 13, 2025

📜 Tickets

Jira ticket
Github issue

💡 Description

This PR:

  • Updates code to use Login struct instead of EncryptedLogin.
  • Removes nested struct calls ( like .secFields, .fields ) since data structures are now flat.
  • Removes LoginEntryFlattened since LoginEntry is flat in the new implementation.
  • Removes deprecated methods and imports.
  • Adds getKey to implement KeyManager interface.

⚠️ NOTE 1
I ran tests locally and the only failure is not related:
Screenshot 2025-01-13 at 17 57 10

Also tested locally adding/deleting/updating and everything seems to work correctly.

⚠️ NOTE 2
We can only merge this once this PR merges and a new A-S swift component is created. We will need to update the A-S version in this PR as well for BR to pass.

⚠️ NOTE 3
This PR is big enough. I will address other nice-to-haves in follow-ups:

  • FXIOS-11049: Use is_empty for HasSyncedLogins which doesn't require decryption.
  • FXIOS-11050: Use has_logins_by_base_domain for domain search related operations.
  • FXIOS-5603: Remove code using Deferred<Maybe<...>>() since it's hard to read and instead use completions.

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

@issammani issammani requested a review from nbhasin2 January 13, 2025 17:24
@issammani issammani requested a review from a team as a code owner January 13, 2025 17:24
@issammani issammani added the Do Not Merge ⛔️ This issue is a work in progress and is not ready to land label Jan 13, 2025
@issammani
Copy link
Collaborator Author

Adding do-not-merge label since we can only merge this once the A-S version is bumped.

@issammani issammani changed the title Refactor FXIOS-10788 [Logins] Apply necessary adjustments for A-S EncryptorDecryptor updates Refactor FXIOS-10788 [Logins] Apply necessary adjustments for A-S EncryptorDecryptor update Jan 13, 2025
Comment on lines 831 to 833
let key = rustKeys.keychain.string(forKey: rustKeys.loginPerFieldKeychainKey)
let encryptedCanaryPhrase = rustKeys.keychain.string(forKey: rustKeys.canaryPhraseKey)
return (key, encryptedCanaryPhrase)
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for background call here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had some code before that called getKeychainData in the background and removed it 😓 Looking at it now, I think it makes sense to keep it in the background still, since I am not sure how compute intensive it is. Good catch !

Comment on lines 837 to 838
let rustKeys = RustLoginEncryptionKeys()
let (key, encryptedCanaryPhrase) = getKeychainData(rustKeys: rustKeys)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let rustKeys = RustLoginEncryptionKeys()
let (key, encryptedCanaryPhrase) = getKeychainData(rustKeys: rustKeys)
let rustKeys = RustLoginEncryptionKeys()
let (key, encryptedCanaryPhrase) = getKeychainData(rustKeys: rustKeys)

strange indent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops 🙃

// This method will be called internally by rust when it needs to encrypt/decrypt logins.
// NOTE: Since this is called internally by rust and each CRUD operation will acquire a mutex lock on the db
// before doing anything we must make sure that getStoredKey is called before doing any CRUD operation in swift.
public func getKey() throws -> Data {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: should put an example somewhere or show how this works for reference

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

Copy link
Contributor

@nbhasin2 nbhasin2 left a comment

Choose a reason for hiding this comment

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

Overall looks

Copy link
Contributor

mergify bot commented Jan 20, 2025

This pull request has conflicts when rebasing. Could you fix it @issammani? 🙏

Copy link
Contributor

mergify bot commented Jan 21, 2025

This pull request has conflicts when rebasing. Could you fix it @issammani? 🙏

@issammani issammani force-pushed the feat/update-enc-dec branch from 8ee6f31 to 33af679 Compare January 21, 2025 14:50
@DonalMe
Copy link
Contributor

DonalMe commented Jan 21, 2025

@issammani #24265 is the Application Services bump that contains mozilla/application-services#6469
If you're ready with this PR?

@issammani issammani force-pushed the feat/update-enc-dec branch 3 times, most recently from 30eac48 to 8536b0c Compare January 21, 2025 17:45
@issammani issammani force-pushed the feat/update-enc-dec branch 4 times, most recently from dc81b9f to 0ce0fca Compare January 21, 2025 19:15
@issammani issammani force-pushed the feat/update-enc-dec branch from 0ce0fca to 94f9815 Compare January 21, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Do Not Merge ⛔️ This issue is a work in progress and is not ready to land
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants