Skip to content

Commit

Permalink
Fix dataclass usage for extension outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Oct 28, 2024
1 parent 3e914e6 commit 8722a89
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def request_uv(self, permissions, rd_id):
credentials = [auth_data.credential_data]

# PRF result:
sign_result = result.extension_results.get("sign")
sign_result = result.extension_results.sign
print("CREATE sign result", sign_result)
sign_key = sign_result.generated_key
if not sign_key:
Expand Down Expand Up @@ -163,7 +163,7 @@ def request_uv(self, permissions, rd_id):
# Only one cred in allowCredentials, only one response.
result = result.get_response(0)

sign_result = result.extension_results["sign"]
sign_result = result.extension_results.sign
print("GET sign result", sign_result)

print("Test verify signature", sign_result.get("signature"))
Expand Down
6 changes: 3 additions & 3 deletions fido2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def do_make_credential(
return AuthenticatorAttestationResponse(
client_data,
AttestationObject.create(att_obj.fmt, att_obj.auth_data, att_obj.att_stmt),
{},
ClientExtensionOutputs({}),
)

def do_get_assertion(
Expand Down Expand Up @@ -1103,7 +1103,7 @@ def make_credential(self, options, **kwargs):

logger.info("New credential registered")
return AuthenticatorAttestationResponse(
client_data, AttestationObject(result), extensions
client_data, AttestationObject(result), ClientExtensionOutputs(extensions)
)

def get_assertion(self, options, **kwargs):
Expand Down Expand Up @@ -1151,5 +1151,5 @@ def get_assertion(self, options, **kwargs):
user=user,
)
],
extensions,
ClientExtensionOutputs(extensions),
)
14 changes: 14 additions & 0 deletions fido2/webauthn.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,13 @@ def from_dict(cls, data: Optional[Mapping[str, Any]]):
data = value
return super().from_dict(data)

@classmethod
def _parse_value(cls, t, value):
if t == Optional[Mapping[str, Any]]:
# Don't convert extension_results
return value
return super()._parse_value(t, value)


@dataclass(eq=False, frozen=True)
class AuthenticatorAssertionResponse(_WebAuthnDataObject):
Expand All @@ -596,6 +603,13 @@ def from_dict(cls, data: Optional[Mapping[str, Any]]):
data = value
return super().from_dict(data)

@classmethod
def _parse_value(cls, t, value):
if t == Optional[Mapping[str, Any]]:
# Don't convert extension_results
return value
return super()._parse_value(t, value)


@dataclass(eq=False, frozen=True)
class RegistrationResponse(_WebAuthnDataObject):
Expand Down

0 comments on commit 8722a89

Please sign in to comment.