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

Add require_user_presence option to verify_registration_response #236

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions webauthn/registration/verify_registration_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def verify_registration_response(
expected_challenge: bytes,
expected_rp_id: str,
expected_origin: Union[str, List[str]],
require_user_presence: bool = True,
require_user_verification: bool = False,
supported_pub_key_algs: List[COSEAlgorithmIdentifier] = default_supported_pub_key_algs,
pem_root_certs_bytes_by_fmt: Optional[Mapping[AttestationFormat, List[bytes]]] = None,
Expand All @@ -85,6 +86,8 @@ def verify_registration_response(
registration options.
- `expected_origin`: The domain, with HTTP protocol (e.g. "https://domain.here"), on which
the registration should have occurred. Can also be a list of expected origins.
- (optional) `require_user_presence`: Whether or not to require that the user was present
during the registration. Should be False during auto registration.
- (optional) `require_user_verification`: Whether or not to require that the authenticator
verified the user.
- (optional) `supported_pub_key_algs`: A list of public key algorithm IDs the RP chooses to
Expand Down Expand Up @@ -160,8 +163,8 @@ def verify_registration_response(
if auth_data.rp_id_hash != expected_rp_id_hash_bytes:
raise InvalidRegistrationResponse("Unexpected RP ID hash")

if not auth_data.flags.up:
raise InvalidRegistrationResponse("User was not present during attestation")
if require_user_presence and not auth_data.flags.up:
raise InvalidRegistrationResponse("User presence was required, but was not present during attestation")

if require_user_verification and not auth_data.flags.uv:
raise InvalidRegistrationResponse(
Expand Down
Loading