otp

package
v0.0.0-...-e1c9297 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OTP

type OTP interface {
	// Authenticate verifies the OTP userCode.
	Authenticate(userCode string) bool
	// GetUserCode returns the current OTP userCode.
	GetUserCode() (string, time.Duration)
	// MaxDuration return the maximum duration a userCode might be valid
	MaxDuration() time.Duration
	GetEncodedSecret() string
	SetEncodedSecret(secret string) error
	// GetURL returns otpauth url
	GetURL() *url.URL
}

func ParseURL

func ParseURL(urlStr string) (OTP, error)

type TOTP

type TOTP struct {
	Time     func() time.Time
	Tries    []int64
	TimeStep time.Duration
	Digits   uint8
	Hash     func() hash.Hash
	Label    string
	Issuer   string
	// contains filtered or unexported fields
}

TOTP contains the different configurable values for a given TOTP invocation.

func NewTOTP

func NewTOTP(secretKey []byte) *TOTP

NewTOTP creates a time based OTP from a secret with default options

func (*TOTP) Authenticate

func (o *TOTP) Authenticate(userCode string) bool

func (*TOTP) GetEncodedSecret

func (o *TOTP) GetEncodedSecret() string

func (*TOTP) GetURL

func (o *TOTP) GetURL() *url.URL

func (*TOTP) GetUserCode

func (o *TOTP) GetUserCode() (string, time.Duration)

func (*TOTP) MaxDuration

func (o *TOTP) MaxDuration() time.Duration

func (*TOTP) SetEncodedSecret

func (o *TOTP) SetEncodedSecret(secret string) error

Jump to

Keyboard shortcuts

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