totp

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidOTP is an error to be returned if the supplied OTP code is not valid.
	ErrInvalidOTP = fmt.Errorf("invalid otp code format")
	// Window OTP validity stepping window. Set this between 2 to 6. Above that is not secure
	Window = 3
)

Functions

func Authenticate

func Authenticate(secret Secret, suppliedOTP string, inUTC bool) (bool, error)

Authenticate will validate the supplied OTP toward user's secrets.

func MakeTotpQrImage

func MakeTotpQrImage(secret Secret, issuer, user string) ([]byte, error)

MakeTotpQrImage will produce a PNG image bytes to be scanned by OTP apps.

Types

type Secret

type Secret []byte

Secret is a secret data that represent user's secret.

func MakeSecret

func MakeSecret() Secret

MakeSecret will create a random 10 bytes (80 bits) secret.

func SecretFromBase32

func SecretFromBase32(base32string string) Secret

SecretFromBase32 will create a secret data from its base32 format.

func (Secret) Base32

func (s Secret) Base32() string

Base32 will create the Base32 string representation of this secret (eg. for storing into db)

func (Secret) IsValid

func (s Secret) IsValid() bool

IsValid validate this key. if its 10 bytes than its valid.

func (Secret) ProvisionURL

func (s Secret) ProvisionURL(issuer, user string) string

ProvisionURL will create provisioning URL to be generated into QR or Bar Codes. https://github.com/google/google-authenticator/wiki/Key-Uri-Format

Jump to

Keyboard shortcuts

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