How to use the webauthn.WebAuthnCredential 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 pypa / warehouse / warehouse / utils / webauthn.py View on Github external
from webauthn.webauthn import (
    AuthenticationRejectedException as _AuthenticationRejectedException,
    RegistrationRejectedException as _RegistrationRejectedException,
)


class AuthenticationRejectedException(Exception):
    pass


class RegistrationRejectedException(Exception):
    pass


WebAuthnCredential = pywebauthn.WebAuthnCredential


def _get_webauthn_users(user, *, rp_id):
    """
    Returns a webauthn.WebAuthnUser instance corresponding
    to the given user model, with properties suitable for
    usage within the webauthn API.
    """
    return [
        pywebauthn.WebAuthnUser(
            str(user.id),
            user.username,
            user.name,
            None,
            credential.credential_id,
            credential.public_key,