Documentation ¶
Index ¶
Constants ¶
View Source
const ( // TOTPDefaultPeriod is the default time period to use if none is provided by the caller. TOTPDefaultPeriod = 30 // TOTPDefaultDelay is the default acceptable delay window. A value of 1 // means the OTP will be valid if it coincides with the calculated token for // the current time step, the next one or the one before. TOTPDefaultDelay = 1 )
View Source
const ( // HOTPDefaultLeeway is the default acceptable look-ahead look-behind window. // A value of 1 means the OTP will be valid if it coincides with the // calculated token for the current counter, the next one or the one before. HOTPDefaultLeeway uint64 = 1 )
View Source
const RandomKeyLength = 64
RandomKeyLength is the recommended length for the key used to generate OTPs. This length will be used to generate default keys (in HOTP.ensureKey and TOTP.ensureKey), when the caller does not provide one explicitly.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorInvalidKey ¶
type ErrorInvalidKey struct {
// contains filtered or unexported fields
}
The ErrorInvalidKey represents an invalid key used to generate OTPs.
func (ErrorInvalidKey) Error ¶
func (eik ErrorInvalidKey) Error() string
type HOTP ¶
type HOTP struct { Key string `json:"key"` // Secret base32 encoded string Counter uint64 `json:"counter"` // Current value to calculate around Leeway uint64 `json:"leeway"` // Acceptable steps for sync error Algorithm config.HmacAlgorithm `json:"algorithm"` // Hash algorithm to use in the calculation Length config.Length `json:"length"` // Length of the resulting code }
The HOTP type used to generate HMAC-Based One-Time Passwords.
func (*HOTP) AsUrlValues ¶
AsUrlValues returns the HOTP parameters represented as url.Values.
type TOTP ¶
type TOTP struct { Key string `json:"key"` // Secret base32 encoded string Period int `json:"period"` // Number of seconds the TOTP is valid Delay int `json:"delay"` // Acceptable steps for network delay Algorithm config.HmacAlgorithm `json:"algorithm"` // Hash algorithm to use in the calculation Length config.Length `json:"length"` // Length of the resulting code }
The TOTP type used to generate Time-Based One-Time Passwords.
func (*TOTP) AsUrlValues ¶
AsUrlValues returns the TOTP parameters represented as url.Values.
func (*TOTP) KeyUri ¶
func (t *TOTP) KeyUri(accountName, issuer string) *authenticator.KeyUri
KeyUri return an authenticator.KeyUri configured with the current TOTP params.
- accountName is the username or email of the account
- issuer is the site or org
Click to show internal directories.
Click to hide internal directories.