Integrate with the API for adding and getting webauthn creds

This links up the `get_webauthn_credentials_for_user` and
`create_webauthn_credential_for_user` methods of the user api client to
notifications-api.

To send data to the API we need strings to be unicode, so we call
decode('utf-8') on base64 objects.

Co-authored-by: Leo Hemsted <leo.hemsted@digital.cabinet-office.gov.uk>
This commit is contained in:
Katie Smith
2021-05-13 15:54:05 +01:00
parent 362189d562
commit bafcc02b7d
7 changed files with 60 additions and 24 deletions

View File

@@ -32,15 +32,15 @@ class WebAuthnCredential(JSONModel):
'name': 'Unnamed key',
'credential_data': base64.b64encode(
cbor.encode(auth_data.credential_data),
),
).decode('utf-8'),
'registration_response': base64.b64encode(
cbor.encode(response),
)
).decode('utf-8')
})
def to_credential_data(self):
return AttestedCredentialData(
cbor.decode(base64.b64decode(self.credential_data))
cbor.decode(base64.b64decode(self.credential_data.encode()))
)
def serialize(self):