Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackupCodeService ¶
type BackupCodeService struct {
Count int
PasswordService rootservices.PasswordService
}
func NewBackupCodeService ¶
func NewBackupCodeService(count int, passwordService rootservices.PasswordService) *BackupCodeService
func (*BackupCodeService) Generate ¶
func (s *BackupCodeService) Generate() ([]string, error)
Generate creates a set of cryptographically random backup codes using base32 encoding.
func (*BackupCodeService) HashCodes ¶
func (s *BackupCodeService) HashCodes(codes []string) ([]string, error)
HashCodes hashes each plaintext backup code using Argon2 via PasswordService.
func (*BackupCodeService) VerifyAndConsume ¶
func (s *BackupCodeService) VerifyAndConsume(hashedCodes []string, code string) ([]string, bool)
VerifyAndConsume checks if code matches any hashed code and returns the remaining hashes.
type TOTPService ¶
func NewTOTPService ¶
func NewTOTPService(digits, periodSeconds int) *TOTPService
func (*TOTPService) BuildURI ¶
func (s *TOTPService) BuildURI(secret, issuer, email string) string
BuildURI builds an otpauth:// URI for QR code display.
func (*TOTPService) GenerateCode ¶
GenerateCode generates a TOTP code for the given secret and time (RFC 6238).
func (*TOTPService) GenerateSecret ¶
func (s *TOTPService) GenerateSecret() (string, error)
GenerateSecret generates a 20-byte cryptographically random secret, base32 encoded.
func (*TOTPService) ValidateCode ¶
func (s *TOTPService) ValidateCode(secret, code string, t time.Time) bool
ValidateCode validates a TOTP code against the current time +/-1 window.
Click to show internal directories.
Click to hide internal directories.