wallix / webauthn

node.js webauthn framework
Apache License 2.0
105 stars 23 forks source link

Choose platform #23

Closed rayauxey closed 4 years ago

rayauxey commented 4 years ago

Hey I'm Raymond from Kenya. I luckily got to see your blog post on how you were able to come up with a back-end implementation of WebAuthn for NodeJs. Thanks for embracing open source by sharing your efforts with other developers.

I've added the option for specifying the authenticator from the back-end since my use-case involves using WebAuthn for smartphones with bio-metric recognition features such as a 'Fingerprint Sensor'. I've given the parameter a default value ('cross-platform') to prevent breaking changes. I've also added a validator to make sure values passed for authenticator and attestation are valid, if not, they are set to their corresponding defaults.

Example Usage:

// api.js

app.post('/request-register', (req, res) => {
    const { id, email } = req.body;

    const challengeResponse = generateRegistrationChallenge({
        relyingParty: { name: 'ACME' },
        user: { id, name: email },
        authenticator: 'platform' // Here is where you choose the authenticator
    });

    userRepository.create({
        id,
        email,
        challenge: challengeResponse.challenge,
    })

    res.send(challengeResponse);
});

Yours Sincerely, Raymond Nyaga (rayauxey@gmail.com)

Kmaschta commented 4 years ago

Thanks!