u2f

package module
v0.0.0-...-8b29c78 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2014 License: BSD-3-Clause Imports: 11 Imported by: 0

README

U2F Server

Go based U2F Server (Universal 2nd Factor). Specs at fido.

API is not stable yet. Its getting close...

Docs at https://godoc.org/github.com/badalex/u2f

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	//  Priv is yours to do what you please with
	Priv      interface{}
	KeyHandle string
	PubKey    string
	Cert      string
	Challenge string
	Counter   uint32
}

Device Holds a U2F device associated with a user

type RegisterRequest

type RegisterRequest struct {
	Version   string `json:"version"`
	Challenge string `json:"challenge"`
	AppID     string `json:"appId"`
}

RegisterRequest dictionary from the fido u2f javascript api spec

type RegisterResponse

type RegisterResponse struct {
	ClientData       string `json:"clientData"`
	RegistrationData string `json:"registrationData"`
}

RegisterResponse dictionary from the fido u2f javascript api. Serves as input to RegisterFin()

type Server

type Server struct {
	Users   UserDB
	AppID   string
	Version string
}

Server

func StdServer

func StdServer(udb UserDB, appID string) Server

StdServer standard server

func (Server) Register

func (s Server) Register(u User) (r RegisterRequest, err error)

Register a user to a device. Returns a RegisterRequest Object for the device to sign. The result of which is passed to RegisterFin().

func (Server) RegisterFin

func (s Server) RegisterFin(u User, r io.Reader) error

RegisterFin finish up, validate and store a Registration. r should contain an RegisterResponse JSON Object.

func (Server) Sign

func (s Server) Sign(u User) (r []SignRequest, err error)

Sign Returns SignRequests for the device to Sign. The result should then be passed to SignFin() for validation.

func (Server) SignFin

func (s Server) SignFin(u User, r io.Reader) (sf SignFinResult, err error)

SignFin Finalize a Sign/Login operation. If this succeeds everything is good and the usb token has been validated. r should contain an SignResponse JSON Object.

type SignFinResult

type SignFinResult struct {
	Touch byte `json:"touch"`
	// Counter current counter value
	Counter uint32 `json:"counter"`
}

SignFinResult is the result of a successful SignFin operation.

type SignRequest

type SignRequest struct {
	Version   string `json:"version"`
	Challenge string `json:"challenge"`
	KeyHandle string `json:"keyHandle"`
	AppID     string `json:"appId"`
}

SignRequest dictionary from the fido u2f javascript api spec. Result of a valid Sign() operation

type SignResponse

type SignResponse struct {
	KeyHandle     string `json:"keyHandle"`
	ClientData    string `json:"clientData"`
	SignatureData string `json:"signatureData"`
}

SignResponse dictionary from the fido u2f javascript api. Serves as input to SignFin()

type User

type User struct {
	// Priv is yours to do what you please with.
	// For example, if you have an sql backend you could store the tuple or
	// primary key here to make updating easier.
	Priv interface{}

	// User contains the username
	User string

	// Enrolled holds if they have signed up
	Enrolled bool

	// A list of associated U2F devices with for this User
	Devices []Device
}

User Hold a User

type UserDB

type UserDB interface {
	// GetUser from a username. It is assumed you have done any needed
	// password authentication before this point
	GetUser(user string) (User, error)

	// PutUser Update the user
	PutUser(u User) error
}

UserDB interface

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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