twofactor

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: MIT Imports: 12 Imported by: 1

README

twofactor

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyPassword = errors.New("empty password")
View Source
var ErrInvalid2FACode = errors.New("invalid two factor authentication code")
View Source
var ErrInvalidResetCode = errors.New("invalid reset code")
View Source
var ErrPasswordTooSimple = errors.New("password too simple")
View Source
var ErrTwoFactorNotConfigured = errors.New("two factor authentication not configured")

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Password         string     `json:"password"`
	ResetCode        *string    `json:"reset_code"`
	ResetCodeExpires *time.Time `json:"reset_code_expires"`
	TwoFactor        *TwoFactor `json:"two_factor"`
	InitTwoFactor    *TwoFactor `json:"init_two_factor"`
	// contains filtered or unexported fields
}

func NewAuth

func NewAuth(password string, inputs ...string) (*Auth, error)

func (*Auth) Check2FA

func (a *Auth) Check2FA(code string) error

func (*Auth) CheckPassword

func (a *Auth) CheckPassword(password string) error

func (*Auth) CheckResetCode

func (a *Auth) CheckResetCode(code string) error

func (*Auth) Complete2FA

func (a *Auth) Complete2FA(code string) error

func (*Auth) Configure2FA

func (a *Auth) Configure2FA(username, domain string) (uri string, recoveryKeys []string, err error)

func (*Auth) Get2FACode added in v0.0.2

func (a *Auth) Get2FACode() string

func (*Auth) Has2FA added in v0.0.2

func (a *Auth) Has2FA() bool

func (*Auth) IsDirty

func (a *Auth) IsDirty() bool

func (*Auth) ResetPassword

func (a *Auth) ResetPassword(dur time.Duration) (string, error)

func (*Auth) Scan

func (a *Auth) Scan(value interface{}) error

func (*Auth) SetPassword

func (a *Auth) SetPassword(password string, inputs ...string) error

func (*Auth) Value

func (a *Auth) Value() (driver.Value, error)

type TwoFactor

type TwoFactor struct {
	Secret       string   `json:"secret"`
	RecoveryKeys []string `json:"recovery_keys"`
}

func NewTwoFactor

func NewTwoFactor() (*TwoFactor, error)

func (*TwoFactor) Auth

func (tf *TwoFactor) Auth(code string) error

func (*TwoFactor) Complete

func (tf *TwoFactor) Complete(code string) error

func (*TwoFactor) Configure

func (tf *TwoFactor) Configure(username, domain string) string

func (*TwoFactor) ConsumeRecoveryKey

func (tf *TwoFactor) ConsumeRecoveryKey(code string) bool

func (*TwoFactor) GenCode

func (tf *TwoFactor) GenCode() string

Jump to

Keyboard shortcuts

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