u2f

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2018 License: GPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindU2FContext

func BindU2FContext(u2fModule *Controller) func(ctx *u2fApiCtx, rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)

BindU2FContext Helper middleware to bind module to API context

Types

type CompletedHandler

type CompletedHandler interface {
	SecondFactorCompleted(userid, action string)
}

CompletedHandler Callback for 2fa signature completion

type Controller

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

Controller U2F controller instance storage

func NewController

func NewController(url string, u2fStore Storer, emitter events.Emitter) *Controller

NewController creates a new U2F controller U2F tokens are issued against the provided url, the browser will reject any u2f requests not from this domain. A CompletedHandler is required for completion of authorization actions, as well as a Storer to provide underlying storage to the U2F module

func (*Controller) AddToken

func (u2fModule *Controller) AddToken(userid, name, keyHandle, publicKey, certificate string, counter uint) error

AddToken Adds a token to a provided user id

func (*Controller) BindAPI

func (u2fModule *Controller) BindAPI(router *web.Router)

BindAPI Binds the API for the u2f module to the provided router

func (*Controller) GetChallenge

func (u2fModule *Controller) GetChallenge(userid string) (*u2f.Challenge, error)

GetChallenge Fetches a U2F challenge for a given user

func (*Controller) IsSupported

func (u2fModule *Controller) IsSupported(userid string) bool

IsSupported Checks whether u2f is supported for a given user by userid This is required to implement the generic 2fa interface for binding into the core module.

func (*Controller) ListTokens

func (u2fModule *Controller) ListTokens(userid string) ([]interface{}, error)

ListTokens lists tokens for a given user

func (*Controller) RemoveToken

func (u2fModule *Controller) RemoveToken(userid, tokenID string) (bool, error)

RemoveToken removes a token by matching user and token external IDs

func (*Controller) ValidateRegistration

func (u2fModule *Controller) ValidateRegistration(userid, tokenName string, challenge *u2f.Challenge, resp *u2f.RegisterResponse) (bool, error)

ValidateRegistration Validates and saves a u2f registration Returns ok, err indicating registration validity and forwarding errors

func (*Controller) ValidateSignature

func (u2fModule *Controller) ValidateSignature(userid string, challenge *u2f.Challenge, resp *u2f.SignResponse) (bool, error)

ValidateSignature validates a u2f signature response

type Storer

type Storer interface {
	// Fetch a user instance by user id (should be able to remove this)
	GetUserByExtID(userid string) (interface{}, error)
	// Add a fido token to a given user
	AddFidoToken(userid, name, keyHandle, publicKey, certificate string, counter uint) (interface{}, error)
	// Fetch fido tokens for a given user
	GetFidoTokens(userid string) ([]interface{}, error)
	// Update a provided fido token
	UpdateFidoToken(token interface{}) (interface{}, error)
	// Remove the provided fido token
	RemoveFidoToken(token interface{}) error
}

Storer U2F Token store interface This must be implemented by a storage module to provide persistence to the module

type TokenInterface

type TokenInterface interface {
	GetExtID() string
	GetName() string
	GetKeyHandle() string
	GetPublicKey() string
	GetCertificate() string
	GetCounter() uint
	SetCounter(uint)
	GetLastUsed() time.Time
	SetLastUsed(time.Time)
}

TokenInterface Token instance interface This must be implemented by the token storage implementation

Jump to

Keyboard shortcuts

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