totp

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: BSD-3-Clause Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIssuer added in v0.9.8

func GetIssuer(r *http.Request) string

func InitModels

func InitModels()

InitModels initializes models in mongo, if required.

Types

type Manager

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

Manager stores and validates passwords

func NewManager

func NewManager(r *http.Request) *Manager

NewManager creates a new Manager

func (*Manager) GetSecret

func (pwm *Manager) GetSecret(username string) (err error, secret userSecret)

func (*Manager) HasTOTP

func (pwm *Manager) HasTOTP(username string) (hastoken bool, err error)

func (*Manager) IsErrNotFound added in v0.9.14

func (pwm *Manager) IsErrNotFound(err error) bool

IsErrNotFound checks if an error is a mgo.ErrNotFound

func (*Manager) Remove

func (pwm *Manager) Remove(username string) error

func (*Manager) Save

func (pwm *Manager) Save(username, secret string) error

Save stores a secret for a specific username.

func (*Manager) Validate

func (pwm *Manager) Validate(username, securityCode string) (bool, error)

Validate checks the totp code for a specific username

type Token

type Token struct {
	Provider string
	User     string
	Secret   string
}

Token represents a totp token with a base32 encoded secret

func NewToken

func NewToken() (*Token, error)

NewToken creates a new totp token with a random base32 encoded secret

func TokenFromSecret

func TokenFromSecret(secret string) *Token

TokenFromSecret creates a totp token from an existing base32 encoded secret

func (*Token) URL

func (token *Token) URL() string

URL creates a the Key Uri Format url (otpauth://... )to enable users to pick this up in the totp applications

func (*Token) Validate

func (token *Token) Validate(securityCode string) (valid bool)

Validate checks a securityCode against a totp token

Jump to

Keyboard shortcuts

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