mfa

package
v0.0.0-...-36ecd39 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidTwoFactorCode = errors.New("invalid two-factor code")

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(cfg ClientConfig) (*Client, error)

func (*Client) ConsumePendingSetup

func (c *Client) ConsumePendingSetup(ctx context.Context, userID, token string) (string, error)

func (*Client) ConsumeRecoveryCode

func (c *Client) ConsumeRecoveryCode(ctx context.Context, userID, code string) (bool, error)

func (*Client) CreateRecoveryCodes

func (c *Client) CreateRecoveryCodes(ctx context.Context, userID string) ([]string, error)

func (*Client) GenerateTOTPSetup

func (c *Client) GenerateTOTPSetup(accountLabel string) (*otp.Key, error)

func (*Client) HasTwoFactorEnabled

func (c *Client) HasTwoFactorEnabled(ctx context.Context, userID string) (bool, error)

func (*Client) LoadPendingSetupSecret

func (c *Client) LoadPendingSetupSecret(ctx context.Context, userID, token string) (string, error)

func (*Client) LoadUserTOTPSecret

func (c *Client) LoadUserTOTPSecret(ctx context.Context, userID string) (string, error)

func (*Client) StartPendingSetup

func (c *Client) StartPendingSetup(ctx context.Context, userID, secret string) (string, error)

func (*Client) UpsertUserTOTPSecret

func (c *Client) UpsertUserTOTPSecret(ctx context.Context, userID, secret string) error

func (*Client) VerifyTOTPCode

func (c *Client) VerifyTOTPCode(secret, code string, now time.Time) bool

type ClientConfig

type ClientConfig struct {
	DB                *sql.DB
	EncryptionKey     []byte
	Issuer            string
	PendingSetupTTL   time.Duration
	RecoveryCodeCount int
}

Jump to

Keyboard shortcuts

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