diff options
author | Matthew Miller <matthew@millerti.me> | 2020-05-22 11:56:20 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-05-22 11:56:20 -0700 |
commit | 32c3f2e6d9382a9bc38e660e11853f45fbee387f (patch) | |
tree | 74125727a226658fd86b72fb703c3dbd315ffa0c /example/index.js | |
parent | 8a0f0d9696ff34d9886e157a6b7dab51358e9b14 (diff) |
Wire up an endpoint for attestation options
Diffstat (limited to 'example/index.js')
-rw-r--r-- | example/index.js | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/example/index.js b/example/index.js index 1a3b72d..574bd8c 100644 --- a/example/index.js +++ b/example/index.js @@ -1,11 +1,47 @@ const path = require('path'); const express = require('express'); +const { + // Registration ("Attestation") + generateAttestationOptions, + verifyAssertionResponse, + // Login ("Assertion") + generateAssertionOptions, + verifyAttestationResponse, +} = require('@webauthntine/server'); + const app = express(); -const port = 3000; +const host = '0.0.0.0'; +const port = 80; app.use(express.static('./public/')); +app.use(express.json()); + +// Domain where the WebAuthn interactions are expected to occur +const origin = 'dev.millerti.me:3000'; +// GENERATE A NEW VALUE FOR THIS EVERY TIME! The server needs to temporarily remember this value, +// so don't lose it until after you verify +const randomChallenge = 'totallyUniqueValueEveryTime'; +// Your internal, _unique_ ID for the user (uuid, etc...). Avoid using identifying information here, +// like an email address +const userId = 'internalUserId'; +// A username for the user +const username = 'user@webauthntine.foo'; + +app.get('/generate-attestation-options', (req, res) => { + res.send(generateAttestationOptions( + 'WebAuthntine Example', + 'dev.millerti.me:3000', + randomChallenge, + userId, + username, + )); +}); + +app.post('/verify-registration', (req, res) => { + const { body } = req; +}); -app.listen(port, () => { - console.log(`🚀 Server ready at http://localhost:${port}`); +app.listen(port, host, () => { + console.log(`🚀 Server ready at http://${host}:${port}`); }); |