mfa

package
v2.0.0-...-83f77b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package mfa provides supports for Multi-Factor authentication modules

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTOTPSecret

func GenerateTOTPSecret(configName, username string) (string, string, string, []byte, error)

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

func ValidateTOTPPasscode(configName, passcode, secret string) (bool, error)

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

func (c *Config) Initialize() error

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

func GetStatus

func GetStatus() ServiceStatus

GetStatus returns 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL