Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrEmptyIssuer value for issuer is required ErrEmptyIssuer = errors.New("issuer cannot be empty") // ErrEmptyAccountName value for account name is required ErrEmptyAccountName = errors.New("account name cannot be empty") // ErrInvalidAlgorithm invalid or unsupported algorithm ErrInvalidAlgorithm = errors.New("invalid or unsupported algorithm") // ErrInvalidDigits invalid or unsupported digits, supported values are from 1 to 10 ErrInvalidDigits = errors.New("invalid or unsupported digits") // ErrInvalidPeriod invalid period value ErrInvalidPeriod = errors.New("period cannot be empty") // ErrInvalidSecret invalid secret value ErrInvalidSecret = errors.New("secret is not a valid base32") )
Functions ¶
This section is empty.
Types ¶
type QR ¶
type QR struct {
// Base64 encoded string of the QR code.
Base64 string
// Decoded image data of the QR code.
Image image.Image
}
QR represents a QR code.
type TOTP ¶
type TOTP struct {
// Name of the account associated with the TOTP. Required.
AccountName string
// Issuer or the service provider of the TOTP. Required.
Issuer string
// Hashing function of the TOTP. Default value is AlgorithmSHA1.
// The commonly supported value by most authenticator app is AlgorithmSHA1, other hash functions might get ignored or unsupported by some authenticator app.
Algorithm Algorithm
// Number of digits of the TOTP. Default value is 6.
// Valid values are from 1 to 10.
// The commonly supported values by most authenticator app are 6 and 8, other value might get ignored or unsupported by some authenticator app.
Digits uint8
// Time period (seconds) of the TOTP. Default value is 30.
// The commonly supported values my some authenticator app are 30 and 60, other value might get ignored or unsupported by most authenticator app.
Period uint64
// Base32 encoded shared secret key of the TOTP.
Secret string
}
TOTP represents parameters of a Time-based One-Time Password.
func New ¶ added in v2.2.1
New creates a new TOTP with a randomly generated shared secret, default value will be used if null.
func (TOTP) GetQR ¶
GetQR generates a QR code image for the TOTP with optional recovery level. Default value for recovery level is qrcode.Medium.
See https://pkg.go.dev/github.com/skip2/go-qrcode@v0.0.0-20200617195104-da1b6568686e#RecoveryLevel for additional details on QR code recovery level.
type Validator ¶
type Validator struct {
// Hashing function of the TOTP.
Algorithm Algorithm
// Number of digits of the TOTP.
Digits uint8
// Skew defines the number of periods before and after the current period that are considered valid.
// This is used to account for slight differences in time between the client and the server.
Skew uint
// Time period (seconds) of the TOTP
Period uint64
// Base32 encoded shared secret key of the TOTP.
Secret string
}
Validator defines the structure used for TOTP validation
Click to show internal directories.
Click to hide internal directories.