-
Notifications
You must be signed in to change notification settings - Fork 1k
Attestation on confirmation #5762
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
Conversation
…getting the state out of sync
MockAppAttestService.swift:47 warning: Function 'setAttestationDelay(_:)' is unused
MockAppAttestService.swift:51 warning: Function 'setAssertionDelay(_:)' is unused
ConfirmationChallenge.swift:18 warning: Function 'setTimeout(timeout:)' is unusedThis dead code check has been bypassed with the ℹ️ If this comment appears to be left in error, double check that the flagged code is actually used and/or make sure your branch is up-to-date with [find-dead-code] |
| A3B2F2B82CF1343F00C0E88C /* SavedPaymentMethodFormFactory+USBankAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B2F2B72CF1343F00C0E88C /* SavedPaymentMethodFormFactory+USBankAccount.swift */; }; | ||
| A3B2F2BA2CF134B500C0E88C /* SavedPaymentMethodFormFactory+SEPADebit.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B2F2B92CF134B500C0E88C /* SavedPaymentMethodFormFactory+SEPADebit.swift */; }; | ||
| A3BE1C242D4161DC0061632C /* RemoveButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BE1C232D4161DC0061632C /* RemoveButton.swift */; }; | ||
| A3DA75572EB20ECE00FFFCC9 /* AttestationChallenge.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3DA75562EB20ECE00FFFCC9 /* AttestationChallenge.swift */; }; |
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.
You can remove these changes, the xcodeproj will now pull in source files automatically
…/confirmation-challenge
… but check attestation cancellation since we do not want to attest unnecessarily
…tripe-ios into joyceqin/confirmation-challenge
| if let keyId = storedKeyID { | ||
| return keyId | ||
| } | ||
| // Check if another task is already generating a key |
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.
Found a race condition— if you initialize AttestationChallenge and immediately try to fetch the assertion, both the prepareAttestation() and assert() functions will read a nil stored key and try and generate a key, overwriting each other and leading to a state mismatch later (client thinks we've attested because we did for one key, but the other key fetches the challenge from the server and gets that it needs to be attested)
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.
Yes, good catch!
| attestationUsingDevelopmentEnvironment = value | ||
| } | ||
|
|
||
| func setAttestationDelay(_ delay: TimeInterval) async { |
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.
Test-only to inject delays to force timeout
Summary
Add an AttestationChallenge wrapper around StripeAttest that prewarms attestation on init and fetches an assertion with a timeout.
Wrap PassiveCaptchaChallenge and AttestationChallenge in ConfirmationChallenge. Anywhere we previously passed PassiveCaptchaChallenge, we now pass in ConfirmationChallenge. ConfirmationChallenge creates the passive captcha and attestation challenges asynchronously in parallel and fetches their tokens with timeout in parallel and creates the radar options for the requests.
Added playground switch so that we can test with/without attestation, similar to the passive captcha switch. Will be removed on release.
Moved PassiveCaptchaChallenge into StripePaymentSheet, @_spi(STP) HCaptcha
Motivation
Attestation support for HCaptcha project
Testing
Added tests
Example request: https://admin.corp.stripe.com/request-log/req_YXMjaq42sec9gb
Changelog
N/A