otpauth

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const PrefixOTPAuth = "otpauth:"

Variables

View Source
var ErrNotFound = errors.New("no otp key found")
View Source
var (
	ErrUnsupportedAlgorithm = errors.New("unsupported algorithm")
)

Functions

func GenerateRecoveryCode

func GenerateRecoveryCode() string

Types

type KeyWrapper

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

func NewKeyWrapper

func NewKeyWrapper(issuer, userID, algorithm, secret string, digits int) (*KeyWrapper, error)

func NewKeyWrapperFromURI

func NewKeyWrapperFromURI(otpauthURI string) (*KeyWrapper, error)

func (KeyWrapper) Algorithm

func (k KeyWrapper) Algorithm() string

func (KeyWrapper) Digits

func (k KeyWrapper) Digits() int

func (KeyWrapper) PNG

func (k KeyWrapper) PNG() (string, error)

func (KeyWrapper) Secret

func (k KeyWrapper) Secret() string

func (KeyWrapper) URI

func (k KeyWrapper) URI() string

func (KeyWrapper) VerifyCode

func (k KeyWrapper) VerifyCode(code string) bool

type Store

type Store interface {
	Lookup(userID string) (*KeyWrapper, error)
	Put(userID string, keyWrapper KeyWrapper) (string, error)
	VerifyRecoveryCode(userID, recoveryCode string) bool
	Delete(userID string) error
	Ping() error
	ReadOnly() bool
}

func NewInMemoryStore

func NewInMemoryStore(users map[string]people.AuthenticPerson) Store

func NewSqlStore

func NewSqlStore(users map[string]people.AuthenticPerson, dbs map[string]*sql.DB, settings *StoreSettings) (Store, error)

type StoreSettings

type StoreSettings struct {
	URI               string `json:"uri,omitempty"`
	Query             string `json:"query,omitempty"`
	RecoveryCodeQuery string `json:"recovery_code_query,omitempty"`
	Update            string `json:"update,omitempty"`
	Delete            string `json:"delete,omitempty"`
}

Jump to

Keyboard shortcuts

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