services

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

type TOTPService struct {
	Digits        int
	PeriodSeconds int
}

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

func (s *TOTPService) GenerateCode(secret string, t time.Time) (string, error)

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.

Jump to

Keyboard shortcuts

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