-
Notifications
You must be signed in to change notification settings - Fork 35
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
Don't show key icon for empty passwords #890
Changes from 6 commits
e787b78
d7e2be1
f80eb8c
33f02f7
4bd80d2
a213b0b
164d487
9c42c2b
963cc0f
a088eb3
e2c90d9
74e99cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ public protocol AutofillSecureVault: SecureVault { | |
func hasAccountFor(username: String?, domain: String?) throws -> Bool | ||
func updateLastUsedFor(accountId: Int64) throws | ||
|
||
func websiteCredentialsFor(domain: String) throws -> [SecureVaultModels.WebsiteCredentials] | ||
func websiteCredentialsFor(accountId: Int64) throws -> SecureVaultModels.WebsiteCredentials? | ||
@discardableResult | ||
func storeWebsiteCredentials(_ credentials: SecureVaultModels.WebsiteCredentials) throws -> Int64 | ||
|
@@ -309,6 +310,31 @@ public class DefaultAutofillSecureVault<T: AutofillDatabaseProvider>: AutofillSe | |
|
||
// MARK: - Credentials | ||
|
||
public func websiteCredentialsFor(domain: String) throws -> [SecureVaultModels.WebsiteCredentials] { | ||
lock.lock() | ||
defer { | ||
lock.unlock() | ||
} | ||
|
||
do { | ||
let credentials = try self.providers.database.websiteCredentialsForDomain(domain) | ||
return try credentials.map(decryptCredentials(_:)) | ||
} catch { | ||
let error = error as? SecureStorageError ?? SecureStorageError.databaseError(cause: error) | ||
throw error | ||
} | ||
} | ||
|
||
private func decryptCredentials(_ credentials: SecureVaultModels.WebsiteCredentials) throws -> SecureVaultModels.WebsiteCredentials { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe move this down to the |
||
if let password = credentials.password { | ||
let decryptedPassword = try self.l2Decrypt(data: password) | ||
return .init(account: credentials.account, | ||
password: decryptedPassword) | ||
} else { | ||
return credentials | ||
} | ||
} | ||
|
||
public func websiteCredentialsFor(accountId: Int64) throws -> SecureVaultModels.WebsiteCredentials? { | ||
lock.lock() | ||
defer { | ||
|
@@ -318,14 +344,8 @@ public class DefaultAutofillSecureVault<T: AutofillDatabaseProvider>: AutofillSe | |
do { | ||
var decryptedCredentials: SecureVaultModels.WebsiteCredentials? | ||
if let credentials = try self.providers.database.websiteCredentialsForAccountId(accountId) { | ||
if let password = credentials.password { | ||
decryptedCredentials = .init(account: credentials.account, | ||
password: try self.l2Decrypt(data: password)) | ||
} else { | ||
decryptedCredentials = credentials | ||
} | ||
decryptedCredentials = try decryptCredentials(credentials) | ||
} | ||
|
||
return decryptedCredentials | ||
} catch { | ||
let error = error as? SecureStorageError ?? SecureStorageError.databaseError(cause: error) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ extension SecureVaultManager: AutofillSecureVaultDelegate { | |
|
||
public func autofillUserScript(_: AutofillUserScript, | ||
didRequestAutoFillInitDataForDomain domain: String, | ||
completionHandler: @escaping ([SecureVaultModels.WebsiteAccount], | ||
completionHandler: @escaping ([SecureVaultModels.WebsiteCredentials], | ||
[SecureVaultModels.Identity], | ||
[SecureVaultModels.CreditCard], | ||
SecureVaultModels.CredentialsProvider) -> Void) { | ||
|
@@ -167,16 +167,13 @@ extension SecureVaultManager: AutofillSecureVaultDelegate { | |
} | ||
|
||
if delegate.secureVaultManagerIsEnabledStatus(self, forType: .password) { | ||
getAccounts(for: domain, | ||
from: vault, | ||
or: passwordManager, | ||
withPartialMatches: includePartialAccountMatches) { [weak self] accounts, error in | ||
getCredentials(forDomain: domain, from: vault, or: passwordManager) { [weak self] credentials, error in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @graeme there is a regression here since
|
||
guard let self = self else { return } | ||
if let error = error { | ||
os_log(.error, "Error requesting autofill init data: %{public}@", error.localizedDescription) | ||
completionHandler([], [], [], self.credentialsProvider) | ||
} else { | ||
completionHandler(accounts, identities, cards, self.credentialsProvider) | ||
completionHandler(credentials, identities, cards, self.credentialsProvider) | ||
} | ||
} | ||
} else { | ||
|
@@ -790,6 +787,23 @@ extension SecureVaultManager: AutofillSecureVaultDelegate { | |
} | ||
} | ||
|
||
private func getCredentials(forDomain domain: String, | ||
from vault: any AutofillSecureVault, | ||
or passwordManager: PasswordManager?, | ||
completion: @escaping ([SecureVaultModels.WebsiteCredentials], Error?) -> Void) { | ||
if let passwordManager = passwordManager, | ||
passwordManager.isEnabled { | ||
passwordManager.websiteCredentialsFor(domain: domain, completion: completion) | ||
} else { | ||
do { | ||
let credentials = try vault.websiteCredentialsFor(domain: domain) | ||
completion(credentials, nil) | ||
} catch { | ||
completion([], error) | ||
} | ||
} | ||
} | ||
|
||
private func existingCredentialsInPasswordManager(with autofillData: AutofillUserScript.DetectedAutofillData, | ||
domain: String, | ||
vault: any AutofillSecureVault) -> SecureVaultModels.WebsiteCredentials? { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might worth checking with the team before upgrading this (and
SubscriptionTests.xcscheme
below)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I'll revert before merging as this isn't really the place.