Documentation
¶
Overview ¶
Package twofactor provides an opt-in Better Auth-shaped two-factor plugin.
Index ¶
Constants ¶
View Source
const (
// ModelTwoFactor is the logical adapter model contributed by this plugin.
ModelTwoFactor = "twoFactor"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Issuer string
Cipher betterauth.TokenCipher
DeliverOTP OTPDelivery
PendingCookie string
TrustedDeviceCookie string
PendingTTL time.Duration
OTPTTL time.Duration
TrustedDeviceTTL time.Duration
TOTPDigits int
TOTPPeriod time.Duration
BackupCodeCount int
BackupCodeLength int
ChallengeMaxAttempts int
AccountMaxFailedAttempts int
AccountLockoutDuration time.Duration
AllowPasswordless bool
SkipVerificationOnEnable bool
DisableTOTP bool
Schema betterauth.ModelSchema
}
Config is immutable after construction.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager exposes the plugin descriptor and the server-only backup-code API.
func NewManager ¶
NewManager returns an integration with server-only management operations.
func (*Manager) Plugin ¶
func (manager *Manager) Plugin() betterauth.Plugin
Plugin returns the immutable server plugin descriptor.
func (*Manager) ViewBackupCodes ¶
func (manager *Manager) ViewBackupCodes( ctx context.Context, database betterauth.DatabaseAdapter, userID string, ) ([]string, error)
ViewBackupCodes decrypts a user's current recovery codes for trusted server-side use. It is deliberately not an HTTP endpoint.
type OTPDelivery ¶
type OTPDelivery func(*betterauth.HookContext, betterauth.User, string) error
OTPDelivery delivers a library-generated second-factor code. Implementations must be concurrency-safe and must not retain HookContext.
Click to show internal directories.
Click to hide internal directories.