Технология u2f, Yubico, покажите несколько простых примеров.
Сориентируйте пожалуйста в технологии FIDO U2f USB Security Key.
Ниже приведенный код работает. Но я не совсем понимаю что он делает. Например, нажав на кнопку мы делаем запрос к u2f.json - Зачем, что это за ключ? Я читал для безопасности в коде URL где-то указывается обратный домен. Но здесь я его не вижу, или я что-то путаю. /index.html <html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta content="utf-8" http-equiv="encoding"> <title>Add a auth token</title> </head> <body> <script type="text/javascript"> const userId = "some value from your application" const getCredential = async (userId) => { const response = await fetch('/u2f.json') if (!response.ok) { throw new Error('response error') } // endpoint returns a simple json-encoded string const challenge = await response.json() console.debug('Challege', challenge) const options = { rp: { name: "Example Site", }, user: { id: Uint8Array.from(userId, c => c.charCodeAt(0)), name: "user@example.com", displayName: "User Name", }, challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)), pubKeyCredParams: [{ alg: -7, type: "public-key" }], timeout: 10000, // ms authenticatorSelection: { authenticatorAttachment: "cross-platform", userVerification: "preferred", }, attestation: "direct" } console.debug('options', options) // If the user completes registration, this value will hold the data to POST to your application const credential = await navigator.credentials.create({ publicKey: options }) console.debug('credential', credential) // Format the user's `credential` and POST it to your application: const dataToSend = { rawId: new Uint8Array(credential.rawId), type: credential.type, response: { attestationObject: new Uint8Array(credential.response.attestationObject), clientDataJSON: new Uint8Array(credential.response.clientDataJSON), }, } const registerResponse = await fetch(request) console.debug('registerResponse', registerResponse) if (registerResponse.ok) { alert('token registered, go back to log in with it') } } function start() { getCredential(userId) } </script> <button onclick="start()">Click to start</button> </body> </html> /u2f.json "VvBKmmsZd2RksGdI8NimSg" |
в стандарте все написано
https://w3c.github.io/webappsec-cred...ntainer-create |
dima85, вот, может эта статейка прольет тебе свет на это...
https://habr.com/ru/post/305508/ |
Часовой пояс GMT +3, время: 17:54. |