Documentation ¶
Overview ¶
Package mfa provides supports for Multi-Factor authentication modules
Index ¶
- func GenerateQRCodeFromURL(url string, width, height int) ([]byte, error)
- func GenerateTOTPSecret(configName, username string) (string, *otp.Key, []byte, error)
- func GetAvailableTOTPConfigNames() []string
- func ValidateTOTPPasscode(configName, passcode, secret string) (bool, error)
- type Config
- type ServiceStatus
- type TOTPConfig
- type TOTPHMacAlgo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateQRCodeFromURL ¶ added in v2.6.0
GenerateQRCodeFromURL generates a QR code from a TOTP URL
func GenerateTOTPSecret ¶
GenerateTOTPSecret generates a new TOTP secret and QR code for the given username using the configuration with configName
func GetAvailableTOTPConfigNames ¶
func GetAvailableTOTPConfigNames() []string
GetAvailableTOTPConfigNames returns the available TOTP config names
func ValidateTOTPPasscode ¶
ValidateTOTPPasscode validates a TOTP passcode using the given secret and configName
Types ¶
type Config ¶
type Config struct { // Time-based one time passwords configurations TOTP []TOTPConfig `json:"totp" mapstructure:"totp"` }
Config defines configuration parameters for Multi-Factor authentication modules
func (*Config) Initialize ¶
Initialize configures the MFA support
type ServiceStatus ¶
type ServiceStatus struct { IsActive bool `json:"is_active"` TOTPConfigs []TOTPConfig `json:"totp_configs"` }
ServiceStatus defines the service status
type TOTPConfig ¶
type TOTPConfig struct { Name string `json:"name" mapstructure:"name"` Issuer string `json:"issuer" mapstructure:"issuer"` Algo TOTPHMacAlgo `json:"algo" mapstructure:"algo"` // contains filtered or unexported fields }
TOTPConfig defines the configuration for a Time-based one time password
func GetAvailableTOTPConfigs ¶
func GetAvailableTOTPConfigs() []*TOTPConfig
GetAvailableTOTPConfigs returns the available TOTP configs
type TOTPHMacAlgo ¶
type TOTPHMacAlgo = string
TOTPHMacAlgo is the enumerable for the possible HMAC algorithms for Time-based one time passwords
const ( TOTPAlgoSHA1 TOTPHMacAlgo = "sha1" TOTPAlgoSHA256 TOTPHMacAlgo = "sha256" TOTPAlgoSHA512 TOTPHMacAlgo = "sha512" )
supported TOTP HMAC algorithms