How to use the webauthn.webauthn.WebAuthnUser function in webauthn

To help you get started, we’ve selected a few webauthn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duo-labs / py_webauthn / webauthn / webauthn.py View on Github external
def assertion_dict(self):
        if not isinstance(self.webauthn_users, list) or len(self.webauthn_users) < 1:
            raise AuthenticationRejectedException('Invalid user list.')
        if len(set([u.rp_id for u in self.webauthn_users])) != 1:
            raise AuthenticationRejectedException('Invalid (mutliple) RP IDs in user list.')
        for user in self.webauthn_users:
            if not isinstance(user, WebAuthnUser):
                raise AuthenticationRejectedException('Invalid user type.')
            if not user.credential_id:
                raise AuthenticationRejectedException('Invalid credential ID.')
        if not self.challenge:
            raise AuthenticationRejectedException('Invalid challenge.')

        acceptable_credentials = []
        for user in self.webauthn_users:
            acceptable_credentials.append({
                'type': 'public-key',
                'id': user.credential_id,
                'transports': ['usb', 'nfc', 'ble', 'internal'],
            })

        assertion_dict = {
            'challenge': self.challenge,