generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 53
[PM-8828] Fido2 autofill without user interaction #744
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
fedemkr
merged 9 commits into
main
from
mobiletf/pm-8828/fido2-autofill-without-user-interaction
Jul 19, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b175417
PM-8361 Added logic to know if the user interacted with the app to un…
fedemkr d1adc22
PM-8828 Start provide credential without user interaction
fedemkr 1020367
PM-8828 Fix autofill without user interaction, added unit tests and d…
fedemkr a6b859c
PM-8361 Address PR feedback, mainly changing the name hasBeenUnlocked…
fedemkr 4c17b89
Merge branch 'mobiletf/pm-8361/fido2-has-unlocked-current-transaction…
fedemkr a3b1fcc
Merge branch 'main' into mobiletf/pm-8828/fido2-autofill-without-user…
fedemkr fbc5dca
PM-8828 Addressed PR feedback
fedemkr f639b61
Merge branch 'main' into mobiletf/pm-8828/fido2-autofill-without-user…
fedemkr c294056
PM-8828 Addressed PR feedback
fedemkr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
BitwardenShared/Core/Autofill/Models/Fido2CredentialAutofillView+Extensions.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import AuthenticationServices | ||
import BitwardenSdk | ||
|
||
@available(iOSApplicationExtension 17.0, *) | ||
extension Fido2CredentialAutofillView { | ||
/// Converts this credential view into an `ASPasskeyCredentialIdentity`. | ||
/// - Returns: A `ASPasskeyCredentialIdentity` from the values of this object. | ||
func toFido2CredentialIdentity() -> ASPasskeyCredentialIdentity { | ||
ASPasskeyCredentialIdentity( | ||
relyingPartyIdentifier: rpId, | ||
userName: safeUsernameForUi, | ||
credentialID: credentialId, | ||
userHandle: userHandle, | ||
recordIdentifier: cipherId | ||
) | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
BitwardenShared/Core/Autofill/Models/Fido2CredentialAutofillViewExtensionsTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import BitwardenSdk | ||
import XCTest | ||
|
||
@testable import BitwardenShared | ||
|
||
class Fido2CredentialAutofillViewExtensionsTests: BitwardenTestCase { // swiftlint:disable:this type_name | ||
// MARK: Tests | ||
|
||
/// `toFido2CredentialIdentity()` returns the converted `ASPasskeyCredentialIdentity`. | ||
func test_toFido2CredentialIdentity() throws { | ||
let subject = Fido2CredentialAutofillView( | ||
credentialId: Data(repeating: 1, count: 16), | ||
cipherId: "1", | ||
rpId: "myApp.com", | ||
userNameForUi: "username", | ||
userHandle: Data(repeating: 1, count: 16) | ||
) | ||
let identity = subject.toFido2CredentialIdentity() | ||
XCTAssertTrue( | ||
identity.relyingPartyIdentifier == subject.rpId | ||
&& identity.userName == subject.userNameForUi | ||
&& identity.credentialID == subject.credentialId | ||
&& identity.userHandle == subject.userHandle | ||
&& identity.recordIdentifier == subject.cipherId | ||
) | ||
} | ||
|
||
/// `toFido2CredentialIdentity()` returns the converted `ASPasskeyCredentialIdentity` | ||
/// when `userNameForUI` is `nil`. | ||
func test_toFido2CredentialIdentity_userNameForUINil() throws { | ||
let subject = Fido2CredentialAutofillView( | ||
credentialId: Data(repeating: 1, count: 16), | ||
cipherId: "1", | ||
rpId: "myApp.com", | ||
userNameForUi: nil, | ||
userHandle: Data(repeating: 1, count: 16) | ||
) | ||
let identity = subject.toFido2CredentialIdentity() | ||
XCTAssertTrue( | ||
identity.relyingPartyIdentifier == subject.rpId | ||
&& identity.userName == Localizations.unknownAccount | ||
&& identity.credentialID == subject.credentialId | ||
&& identity.userHandle == subject.userHandle | ||
&& identity.recordIdentifier == subject.cipherId | ||
) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode cha
1E0A
racters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
BitwardenShared/Core/Autofill/Utilities/Fido2DebuggingReportBuilder.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#if DEBUG | ||
|
||
import BitwardenSdk | ||
import Foundation | ||
|
||
/// Report with traceability about Fido2 flows. | ||
public struct Fido2DebuggingReport { | ||
var allCredentialsResult: Result<[BitwardenSdk.CipherView], Error>? | ||
var findCredentialsResult: Result<[BitwardenSdk.CipherView], Error>? | ||
var getAssertionRequest: GetAssertionRequest? | ||
var getAssertionResult: Result<GetAssertionResult, Error>? | ||
var saveCredentialCipher: Result<BitwardenSdk.Cipher, Error>? | ||
} | ||
|
||
/// Fido2 builder for debugging report. | ||
public struct Fido2DebuggingReportBuilder { | ||
/// Builder for Fido2 debugging report. | ||
public static var builder = Fido2DebuggingReportBuilder() | ||
|
||
var report = Fido2DebuggingReport() | ||
|
||
/// Gets the report for Fido2 debugging. | ||
/// - Returns: Fido2 report. | ||
public func getReport() -> Fido2DebuggingReport? { | ||
report | ||
} | ||
|
||
mutating func withAllCredentialsResult(_ result: Result<[BitwardenSdk.CipherView], Error>) { | ||
report.allCredentialsResult = result | ||
} | ||
|
||
mutating func withFindCredentialsResult(_ result: Result<[BitwardenSdk.CipherView], Error>) { | ||
report.findCredentialsResult = result | ||
} | ||
|
||
mutating func withGetAssertionRequest(_ request: GetAssertionRequest) { | ||
report.getAssertionRequest = request | ||
} | ||
|
||
mutating func withGetAssertionResult(_ result: Result<GetAssertionResult, Error>) { | ||
report.getAssertionResult = result | ||
} | ||
|
||
mutating func withSaveCredentialCipher(_ credential: Result<BitwardenSdk.Cipher, Error>) { | ||
report.saveCredentialCipher = credential | ||
} | ||
} | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.