twofactor

package
v0.0.0-...-a5fc328 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTwoFactorAlreadyActive = errors.New("2FA already active on account")
	ErrTwoFactorNotActive     = errors.New("2FA is not active on account")
	ErrTwoFactorUnableToSetup = errors.New("Unable to generate new 2FA secret")
	ErrTwoFactorInvalidCode   = errors.New("Authentication code is invalid")
)

Functions

func Disable

func Disable(verification Verification, user account.User) (err error)

func Enable

func Enable(verification Verification, user account.User) (err error)

func Verify

func Verify(secret *string, code string, lastUsed *int) (bool, int, error)

Types

type Controller

type Controller struct{}

func (*Controller) DisableTwoFactor

func (controller *Controller) DisableTwoFactor(c *gin.Context)

func (*Controller) EnableTwoFactor

func (controller *Controller) EnableTwoFactor(c *gin.Context)

func (*Controller) GetTwoFactorSecret

func (controller *Controller) GetTwoFactorSecret(c *gin.Context)

type Otp

type Otp struct {
	Secret  string `json:"secret"`
	OtpAuth string `json:"otpauth"`
}

func GetSecret

func GetSecret(accountName string, user account.User) (otp Otp, err error)

type Verification

type Verification struct {
	Code     string  `json:"code"`
	Secret   *string `json:"secret"`
	LastUsed *int    `json:"-"`
}

Jump to

Keyboard shortcuts

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