server

package
v0.0.0-...-c031a3e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2020 License: BSD-3-Clause Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const Timeout = 5 * time.Second

Timeout is the number of seconds to attempt a graceful shutdown, or for timing out read/write operations

Variables

View Source
var ErrCredentialCloned = errors.New("credential appears to have been cloned")

ErrCredentialCloned occurs when an authenticator provides a sign count during assertion that is lower than the previously recorded sign count, as this would indicate that the authenticator may have been cloned.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

Option is an option that sets a particular value for the server

func WithWebAuthn

func WithWebAuthn(w *webauthn.WebAuthn) Option

WithWebAuthn sets the webauthn configuration for the server

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a configurable HTTP server that implements a demo of the WebAuthn specification

func NewServer

func NewServer(config *config.Config, opts ...Option) (*Server, error)

NewServer returns a new instance of a Server configured with the provided configuration

func (*Server) CreateUser

func (ws *Server) CreateUser(w http.ResponseWriter, r *http.Request)

CreateUser adds a new user to the database

func (*Server) DeleteCredential

func (ws *Server) DeleteCredential(w http.ResponseWriter, r *http.Request)

DeleteCredential deletes a credential from the db

func (*Server) GetAssertion

func (ws *Server) GetAssertion(w http.ResponseWriter, r *http.Request)

GetAssertion - assemble the data we need to make an assertion against a given user and authenticator

func (*Server) GetCredentials

func (ws *Server) GetCredentials(w http.ResponseWriter, r *http.Request)

GetCredentials gets a user's credentials from the db

func (*Server) Index

func (ws *Server) Index(w http.ResponseWriter, r *http.Request)

Index renders the dashboard index page, displaying the created credential as well as any other credentials previously registered by the authenticated user.

func (*Server) Login

func (ws *Server) Login(w http.ResponseWriter, r *http.Request)

Login renders the login/registration page.

func (*Server) LoginRequired

func (ws *Server) LoginRequired(next http.HandlerFunc) http.HandlerFunc

LoginRequired sets a context variable with the user loaded from the user ID stored in the session cookie

func (*Server) MakeAssertion

func (ws *Server) MakeAssertion(w http.ResponseWriter, r *http.Request)

MakeAssertion validates the assertion data provided by the authenticator and responds whether or not it was successful alongside the relevant credential.

func (*Server) MakeNewCredential

func (ws *Server) MakeNewCredential(w http.ResponseWriter, r *http.Request)

MakeNewCredential attempts to make a new credential given an authenticator's response

func (*Server) RequestNewCredential

func (ws *Server) RequestNewCredential(w http.ResponseWriter, r *http.Request)

RequestNewCredential begins a Credential Registration Request, returning a PublicKeyCredentialCreationOptions object

func (*Server) Shutdown

func (ws *Server) Shutdown() error

Shutdown attempts to gracefully shutdown the underlying HTTP server.

func (*Server) Start

func (ws *Server) Start() error

Start starts the underlying HTTP server

func (*Server) UserExists

func (ws *Server) UserExists(w http.ResponseWriter, r *http.Request)

UserExists returns a boolean indicating if the user exists or not.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL