feat: authenticate with a hardware security key - #174
Open
epheterson wants to merge 2 commits into
Open
Conversation
Apple stops offering a 6-digit code once security keys are enrolled on an
Apple ID and returns an fsaChallenge instead, so validate_2fa_code has
nothing to validate and such an account cannot complete 2FA.
Adds:
security_key_challenge the pending challenge, or None
confirm_security_key(...) sign with an attached key and submit,
or submit an assertion built elsewhere
sign_security_key_challenge() sign without submitting
build_security_key_assertion() assertion response -> Apple's payload
fido2_devices attached devices
fido2 is imported lazily and only when signing, so callers that supply an
assertion do not need it.
Two details worth noting: Apple answers an accepted assertion with 409
rather than 2xx, and the challenge in the payload is taken from clientData
so the value signed and the value declared cannot diverge.
Verified against a real account and a YubiKey.
Co-Authored-By: Claude <noreply@anthropic.com>
Owner
|
/oc please review this code. |
|
Model not found: opencode/minimax-m3-free. Did you mean: minimax-m3, hy3-free, mimo-v2.5-free? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Once security keys are enrolled on an Apple ID, Apple stops offering a 6-digit code and returns an
fsaChallenge— a WebAuthn assertion request — from every 2FA endpoint.validate_2fa_codethen has nothing to validate, and such an account cannot complete two-factor at all.New surface:
fido2is imported lazily and only on the signing path, so it stays optional and callers that supply an assertion don't need it installed.Two details that are easy to get wrong, both taken from Apple's sign-in bundle:
250is Apple's own "two-factor completed")clientData, so the value signed and the value declared can't diverge19 tests added, no network. Verified end to end against a real account and a YubiKey: one touch,
hsaTrustedBrowser=True, session trusted.Note
tests/test_account.py::test_storagefails onmainalready, unrelated to this change.