twofactor

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package twofactor allows authentication via one time passwords

Index

Constants

View Source
const (
	DataRecoveryCode     = "recovery_code"
	DataRecoveryCodes    = "recovery_codes"
	DataNumRecoveryCodes = "n_recovery_codes"
)

Data constants

View Source
const (
	PageRecovery2FA = "recovery2fa"
)

Page constants

Variables

This section is empty.

Functions

func BCryptRecoveryCodes

func BCryptRecoveryCodes(codes []string) ([]string, error)

BCryptRecoveryCodes hashes each recovery code given and return them in a new slice.

func DecodeRecoveryCodes

func DecodeRecoveryCodes(codes string) []string

DecodeRecoveryCodes is an alias for strings.Split(",")

func EncodeRecoveryCodes

func EncodeRecoveryCodes(codes []string) string

EncodeRecoveryCodes is an alias for strings.Join(",")

func GenerateRecoveryCodes

func GenerateRecoveryCodes() ([]string, error)

GenerateRecoveryCodes creates 10 recovery codes of the form: abd34-1b24do (using alphabet, of length recoveryCodeLength).

func UseRecoveryCode

func UseRecoveryCode(codes []string, inputCode string) ([]string, bool)

UseRecoveryCode deletes the code that was used from the string slice and returns it, the bool is true if a code was used

Types

type Recovery

type Recovery struct {
	*authboss.Authboss
}

Recovery for two-factor authentication is handled by this type

func (*Recovery) GetRegen

func (rc *Recovery) GetRegen(w http.ResponseWriter, r *http.Request) error

GetRegen shows a button that enables a user to regen their codes as well as how many codes are currently remaining.

func (*Recovery) PostRegen

func (rc *Recovery) PostRegen(w http.ResponseWriter, r *http.Request) error

PostRegen regenerates the codes

func (*Recovery) Setup

func (rc *Recovery) Setup() error

Setup the module to provide recovery regeneration routes

type User

type User interface {
	authboss.User

	GetEmail() string
	PutEmail(string)

	// GetRecoveryCodes retrieves a CSV string of bcrypt'd recovery codes
	GetRecoveryCodes() string
	// PutRecoveryCodes uses a single string to store many
	// bcrypt'd recovery codes
	PutRecoveryCodes(codes string)
}

User interface

Directories

Path Synopsis
Package sms2fa implements two factor auth using sms-transmitted one time passwords.
Package sms2fa implements two factor auth using sms-transmitted one time passwords.
Package totp2fa implements two factor auth using time-based one time passwords.
Package totp2fa implements two factor auth using time-based one time passwords.

Jump to

Keyboard shortcuts

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