Giter Club home page Giter Club logo

demo-webauthn-pubkey's Introduction

WebAuthn API with PubKey Demo

An application that utilizes the WebAuthn API to implement secure user authentication using public key cryptography. All backend data is stored in RDBMS (PostgreSQL or MariaDB/MySQL). Both the frontend and backend sides are developed using vanilla JavaScript.

These npm packages are used to handle authentication data:

This application is a demo for the "PublicKeyCredential in Web Apps" post.

Install

$ git clone https://github.com/flancer64/demo-webauthn-pubkey.git
$ cd ./demo-webauthn-pubkey
$ npm install

Setup

This app uses Knex.js to connect to PostgreSQL or MariaDB/MySQL databases.

Create Database

PostgreSQL:

$ sudo -u postgres psql
...
postgres=# create user webauthn_pubkey password '...';
postgres=# create database webauthn_pubkey owner webauthn_pubkey;
postgres=# \q

MariaDB/MySQL:

root@host:/# mariadb
...
MariaDB [(none)]> CREATE DATABASE webauthn_pubkey;
MariaDB [(none)]> CREATE USER webauthn_pubkey@localhost IDENTIFIED BY '...';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON webauthn_pubkey.* TO webauthn_pubkey@localhost;
MariaDB [(none)]> FLUSH PRIVILEGES;

Configure the Application

Create a local configuration file and set up the connection to the database and the port to be listened to by the web server:

$ cd ./cfg/
$ cp init.json local.json
$ nano local.json

Inside local.json, add the following configuration:

{
  "@teqfw/db": {
    "client": "pg|mysql2",
    "connection": {
      "host": "127.0.0.1",
      "user": "...",
      "password": "...",
      "database": "..."
    }
  },
  "@teqfw/web": {
    "server": {
      "port": 8080
    }
  }
}

Run the Application

$ npm run db-reset
$ npm start

Then go to http://localhost:8080 (or the configured port) and sign up as a new user with a platform authenticator ( see "PublicKeyCredential in Web Apps"):

Sign Up screen

Try this demo with Android/iPhone/Desktop.

demo-webauthn-pubkey's People

Contributors

flancer64 avatar

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.