Documentation ¶
Index ¶
- func NewTOTPStruct(cfg *platformConfig.Config, logger log.Logger) totpPkg.Totp
- type TotpStruct
- func (totp TotpStruct) EncodeQuery(v url.Values) string
- func (totp TotpStruct) Generate(opts config.GenerateOpts) (*string, *string, error)
- func (totp TotpStruct) GenerateCode(secret string, t time.Time) (string, error)
- func (totp TotpStruct) GenerateCodeCustom(secret string, t time.Time, opts config.ValidateOpts) (passcode string, err error)
- func (totp TotpStruct) Validate(passcode string, secret string) bool
- func (totp TotpStruct) ValidateCustom(passcode string, secret string, t time.Time, opts config.ValidateOpts) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTOTPStruct ¶
Types ¶
type TotpStruct ¶
type TotpStruct struct {
// contains filtered or unexported fields
}
func (TotpStruct) EncodeQuery ¶
func (totp TotpStruct) EncodeQuery(v url.Values) string
func (TotpStruct) Generate ¶
func (totp TotpStruct) Generate(opts config.GenerateOpts) (*string, *string, error)
func (TotpStruct) GenerateCode ¶
GenerateCode creates a TOTP token using the current time. A shortcut for GenerateCodeCustom, GenerateCode uses a configuration that is compatible with Google-Authenticator and most clients.
func (TotpStruct) GenerateCodeCustom ¶
func (totp TotpStruct) GenerateCodeCustom(secret string, t time.Time, opts config.ValidateOpts) (passcode string, err error)
GenerateCodeCustom takes a timepoint and produces a passcode using a secret and the provided opts. (Under the hood, this is making an adapted call to hotp.GenerateCodeCustom)
func (TotpStruct) Validate ¶
func (totp TotpStruct) Validate(passcode string, secret string) bool
Validate a TOTP using the current time. A shortcut for ValidateCustom, Validate uses a configuration that is compatible with Google-Authenticator and most clients.
func (TotpStruct) ValidateCustom ¶
func (totp TotpStruct) ValidateCustom(passcode string, secret string, t time.Time, opts config.ValidateOpts) (bool, error)
ValidateCustom validates a TOTP given a user specified time and custom options. Most users should use Validate() to provide an interpolatable TOTP experience.