All Projects → koesie10 → Webauthn

koesie10 / Webauthn

Licence: mit
Go package for easy WebAuthn integration

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Webauthn

Joomla External Login
The External Login project allows Joomla! to manage external Authentication Servers
Stars: ✭ 24 (-81.68%)
Mutual labels:  authentication, login
Mern Stack Authentication
Secure MERN Stack CRUD Web Application using Passport.js Authentication
Stars: ✭ 60 (-54.2%)
Mutual labels:  authentication, login
Craft Twofactorauthentication
Craft plugin for two-factor or two-step login using Time Based OTP.
Stars: ✭ 31 (-76.34%)
Mutual labels:  authentication, login
Aura.auth
Provides a unified interface to local and remote authentication systems.
Stars: ✭ 121 (-7.63%)
Mutual labels:  authentication, login
Spring Security React Ant Design Polls App
Full Stack Polls App built using Spring Boot, Spring Security, JWT, React, and Ant Design
Stars: ✭ 1,336 (+919.85%)
Mutual labels:  authentication, login
Kratos Selfservice Ui React Native
A reference implementation of an app using ORY Kratos for auth (login), sign up (registration), profile settings (update password), MFA/2FA, account recovery (password reset), and more for React Native. This repository is available as an expo template!
Stars: ✭ 24 (-81.68%)
Mutual labels:  authentication, login
Gortas
Gortas is an API based authentication service, allows adding authentication to your site or service with minimum efforts.
Stars: ✭ 48 (-63.36%)
Mutual labels:  authentication, 2fa
Authelia
The Single Sign-On Multi-Factor portal for web apps
Stars: ✭ 11,094 (+8368.7%)
Mutual labels:  authentication, 2fa
Securelogin
This version won't be maintained!
Stars: ✭ 1,259 (+861.07%)
Mutual labels:  authentication, 2fa
Totp Cli
A cli-based pass-backed TOTP app
Stars: ✭ 76 (-41.98%)
Mutual labels:  authentication, 2fa
Fastify Esso
The easiest authentication plugin for Fastify, with built-in support for Single sign-on
Stars: ✭ 20 (-84.73%)
Mutual labels:  authentication, login
Spring Webmvc Pac4j
Security library for Spring Web MVC: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 110 (-16.03%)
Mutual labels:  authentication, login
Auth0.js
Auth0 headless browser sdk
Stars: ✭ 755 (+476.34%)
Mutual labels:  authentication, login
Mean Angular5 Passport Authentication
Securing MEAN Stack (Angular 5) Web Application using Passport Authentication
Stars: ✭ 24 (-81.68%)
Mutual labels:  authentication, login
Php Auth
Authentication for PHP. Simple, lightweight and secure.
Stars: ✭ 713 (+444.27%)
Mutual labels:  authentication, login
Privacyidea
🔐 multi factor authentication system (2FA, MFA, OTP Server)
Stars: ✭ 1,027 (+683.97%)
Mutual labels:  authentication, 2fa
Cloudfront Auth
An AWS CloudFront [email protected] function to authenticate requests using Google Apps, Microsoft, Auth0, OKTA, and GitHub login
Stars: ✭ 471 (+259.54%)
Mutual labels:  authentication, login
Google2fa Laravel
A One Time Password Authentication package, compatible with Google Authenticator for Laravel
Stars: ✭ 618 (+371.76%)
Mutual labels:  authentication, 2fa
Flexiblelogin
A Sponge minecraft server plugin for second factor authentication
Stars: ✭ 73 (-44.27%)
Mutual labels:  authentication, 2fa
Appy Backend
A user system to bootstrap your app.
Stars: ✭ 96 (-26.72%)
Mutual labels:  authentication, login

webauthn : Web Authentication API in Go

Overview GoDoc Build Status

This project provides a low-level and a high-level API to use the Web Authentication API (WebAuthn).

Demo

Install

go get github.com/koesie10/webauthn

Attestation

By default, this library does not support any attestation statement formats. To use the default attestation formats, you will need to import github.com/koesie10/webauthn/attestation or any of its subpackages if you would just like to support some attestation statement formats.

Please note that the Android SafetyNet attestation statement format depends on gopkg.in/square/go-jose.v2, which means that this package will be imported when you import either github.com/koesie10/webauthn/attestation or github.com/koesie10/webauthn/attestation/androidsafetynet.

High-level API

The high-level API can be used with the net/http package and simplifies the low-level API. It is located in the webauthn subpackage. It is intended for use with e.g. fetch or XMLHttpRequest JavaScript clients.

First, make sure your user entity implements User. Then, create a new entity implements Authenticator that stores each authenticator the user registers.

Then, either make your existing repository implement AuthenticatorStore or create a new repository.

Finally, you can create the main WebAuthn struct supplying the Config options:

w, err := webauthn.New(&webauthn.Config{
    // A human-readable identifier for the relying party (i.e. your app), intended only for display.
    RelyingPartyName:   "webauthn-demo",
    // Storage for the authenticator.
    AuthenticatorStore: storage,
})		

Then, you can use the methods defined, such as StartRegistration to handle registration and login. Every handler requires a Session, which stores intermediate registration/login data. If you use gorilla/sessions, use webauthn.WrapMap(session.Values). Read the documentation for complete information on what parameters need to be passed and what values are returned.

For example, a handler for finishing the registration might look like this:

func (r *http.Request, rw http.ResponseWriter) {
    ctx := r.Context()

    // Get the user in some way, in this case from the context
    user, ok := UserFromContext(ctx)
    if !ok {
        rw.WriteHeader(http.StatusForbidden)
        return
    }

    // Get or create a session in some way, in this case from the context
    sess := SessionFromContext(ctx)

    // Then call FinishRegistration to register the authenticator to the user
    h.webauthn.FinishRegistration(r, rw, user, webauthn.WrapMap(sess))
}

A complete demo application using the high-level API which implements all of these interfaces and stores data in memory is available here.

JavaScript examples

This class is an example that can be used to handle the registration and login phases. It can be used as follows:

const w = new WebAuthn();

// Registration
w.register().then(() => {
    alert('This authenticator has been registered.');
}).catch(err => {
    console.error(err);
    alert('Failed to register: ' + err);
});

// Login
w.login().then(() => {
    alert('You have been logged in.');
}).catch(err => {
    console.error(err);
    alert('Failed to login: ' + err);
});

Or, with latest async/await paradigm:

const w = new WebAuthn();

// Registration
try {
    await w.register();
    alert('This authenticator has been registered.');
} catch (err) {
    console.error(err)
    alert('Failed to register: ' + err);
}

// Login
try {
    await w.login();
    alert('You have been logged in.');
} catch(err) {
    console.error(err);
    alert('Failed to login: ' + err);
}

Low-level API

The low-level closely resembles the specification and the high-level API should be preferred. However, if you would like to use the low-level API, the main entry points are:

License

MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].