Code Monkey home page Code Monkey logo

webauthn_demo's Introduction

Webauthn Simple Demo - GoLang

Example of WebAuthn for a presentation. For Golang.

Preview

What is WebAuthn?

  • The Web Authentication API gives Web applications user-agent-mediated access to authenticators – which are often hardware tokens accessed over USB/BLE/NFC or modules built directly into the platform – for the purposes of generating and challenging application-scoped (eTLD+k) public-key credentials. This enables a variety of use-cases, such as:
    • Low friction and phishing-resistant 2FA (to be used in conjunction with a password)
    • Passwordless, biometrics-based re-authorization
    • Low friction and phishing-resistant 2FA without a password (to be used for passwordless accounts)

Browser Status (2019 March)

  • Web Authentication is only partially included in
  • Chrome 67,
  • Firefox 60
  • Edge build 17723 or newer versions.
  • Safari not support.

Enabling WebAuthn in Chrome

Chrome has flags that my need to be enabled. Paste this into the omnibar:

chrome://flags/#enable-web-authentication-api

MacOS Touch ID: chrome://flags/#enable-web-authentication-touch-id

How Register works

  • required params
    • userid (server side)
    • challenge (The challenge is produced by the server; see the Security Considerations)
  • challenge is generate on server
  • As a cryptographic protocol, Web Authentication is dependent upon randomized challenges to avoid replay attacks. Therefore, the values of both PublicKeyCredentialCreationOptions.challenge and PublicKeyCredentialRequestOptions.challenge MUST be randomly generated by Relying Parties in an environment they trust (e.g., on the server-side), and the returned challenge value in the client’s response MUST match what was generated.
  • In order to prevent replay attacks, the challenges MUST contain enough entropy to make guessing them infeasible. Challenges SHOULD therefore be at least 16 bytes long.
  • After a successful registration, the server stores the "credentialId" it receives from the browser
  • credentialId has a timeout period
  • The browser is stored inside, it can not be seen

How login works

  • challenge is generate on server
  • id (credentialId)

Example Code

navigator.credentials
  .get({
    publicKey: {
      challenge: base64url.decode("<%= challenge %>"),
      allowCredentials: [
        {
          id: base64url.decode("<%= id %>"),
          type: "public-key"
        }
      ],
      timeout: 15000,
      authenticatorSelection: { userVerification: "preferred" }
    }
  })
  .then(res => {
      .....

All step Simulations

webauthn.me

  1. Register Your User
  2. Touch Your Authenticator
  3. Your New Credential
  4. Authenticate With Your Credential
  5. Touch Your Authenticator
  6. Login Successful

Spec Variables

https://w3c.github.io/webauthn/#idl-index

Other Demos

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.