twofactor

package
v0.0.0-...-4c48337 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateBackupCodes

func GenerateBackupCodes(count int) []string

func HashBackupCodes

func HashBackupCodes(codes []string) []string

func VerifyBackupCode

func VerifyBackupCode(hashedCodes []string, code string) bool

Types

type BackupCodeStore

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

func NewBackupCodeStore

func NewBackupCodeStore() *BackupCodeStore

func (*BackupCodeStore) RemainingCodes

func (s *BackupCodeStore) RemainingCodes(userID uint) int

func (*BackupCodeStore) SetCodes

func (s *BackupCodeStore) SetCodes(userID uint, codes []string)

func (*BackupCodeStore) VerifyCode

func (s *BackupCodeStore) VerifyCode(userID uint, code string) bool

type Service

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

func NewService

func NewService() *Service

func (*Service) EnableTwoFactor

func (s *Service) EnableTwoFactor(accountID uint, accountName, phone string) (*TwoFactorSecret, error)

func (*Service) VerifyToken

func (s *Service) VerifyToken(secret, token string) bool

type TwoFactorConfig

type TwoFactorConfig struct {
	Issuer          string
	Algorithm       string
	Digits          int
	Period          int
	RequireForLogin bool
	RequireForStaff bool
}

type TwoFactorSecret

type TwoFactorSecret struct {
	AccountName string
	Issuer      string
	Secret      string
	QRCodeURL   string
	CreatedAt   time.Time
}

func GenerateSecret

func GenerateSecret(accountName, issuer string) (*TwoFactorSecret, error)

Jump to

Keyboard shortcuts

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