How to use the webauthn.WebAuthnMakeCredentialOptions 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 pretix / pretix / src / pretix / control / views / user.py View on Github external
def get_context_data(self, **kwargs):
        ctx = super().get_context_data()
        ctx['device'] = self.device

        if 'webauthn_register_ukey' in self.request.session:
            del self.request.session['webauthn_register_ukey']
        if 'webauthn_challenge' in self.request.session:
            del self.request.session['webauthn_challenge']

        challenge = generate_challenge(32)
        ukey = generate_ukey()

        self.request.session['webauthn_challenge'] = challenge
        self.request.session['webauthn_register_ukey'] = ukey

        make_credential_options = webauthn.WebAuthnMakeCredentialOptions(
            challenge,
            urlparse(settings.SITE_URL).netloc,
            urlparse(settings.SITE_URL).netloc,
            ukey,
            self.request.user.email,
            str(self.request.user),
            settings.SITE_URL
        )
        ctx['jsondata'] = json.dumps(make_credential_options.registration_dict)

        return ctx
github Integreat / cms-django / backend / cms / views / settings / mfa / mfa.py View on Github external
def get(self, request):
        challenge = generate_challenge(32)
        request.session['mfa_registration_challenge'] = challenge

        user = request.user

        make_credential_options = webauthn.WebAuthnMakeCredentialOptions(
            challenge,
            'Integreat',
            settings.HOSTNAME,
            user.id,
            user.username,
            user.first_name + " " + user.last_name,
            '')
        return JsonResponse(make_credential_options.registration_dict)
github mimming / snippets / add-a-cat-to-that / app.py View on Github external
# Select WebAuthn required values
        challenge = generate_random_string(32)
        rp_name = 'Add a Cat to That'
        rp_id = RP_ID  # localhost

        user_id = current_user['id']
        username = current_user['email']
        display_name = current_user['email']
        icon_url = ''

        timeout = 60000
        attestation = 'none'

        # Make credentials_options for our values
        credential_options = webauthn.WebAuthnMakeCredentialOptions(
            challenge,
            rp_name,
            rp_id,
            user_id,
            username,
            display_name,
            icon_url,
            timeout,
            attestation)

        # JSON encode it for use in JavaScript land
        json_credential_options = json.dumps(credential_options.registration_dict)

        # Get a list of known security keys for this user
        known_keys = {}
        if 'known_keys' in current_user:
github Integreat / cms-django / src / cms / views / settings / mfa / mfa.py View on Github external
def get(self, request):
        challenge = generate_challenge(32)
        request.session["mfa_registration_challenge"] = challenge

        user = request.user

        make_credential_options = webauthn.WebAuthnMakeCredentialOptions(
            challenge,
            "Integreat",
            settings.HOSTNAME,
            user.id,
            user.username,
            user.first_name + " " + user.last_name,
            "",
        )
        return JsonResponse(make_credential_options.registration_dict)