mfa

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearUserMfaKeyInDb

func ClearUserMfaKeyInDb[T string | primitive.ObjectID](uid T, cb SaveMfaKeyToDbCb[T]) error

func GenerateMfaKey

func GenerateMfaKey(account, issuer string) (*otp.Key, error)

func GenerateRecCode

func GenerateRecCode(key *otp.Key) (string, error)

func GenerateRecCodes

func GenerateRecCodes(key *otp.Key, count int) []string

func GetMfaKeyPngBytes

func GetMfaKeyPngBytes(key *otp.Key) ([]byte, error)

func SaveMfaKeyToDb

func SaveMfaKeyToDb[T string | primitive.ObjectID](key *otp.Key, uid T, recCodes []string, cb SaveMfaKeyToDbCb[T]) error

Types

type LoginParam

type LoginParam struct {
	MfaLoginParam
	Username  string `json:"username,omitempty"`
	Password  string `json:"password,omitempty"`
	GrantType string `json:"grant_type,omitempty"` // 'password' | 'mfa' | 'captcha'; // default is password
}

type MfaLoginCallbackFunc

type MfaLoginCallbackFunc func(core.Context, *jwt.CustomClaims)

type MfaLoginParam

type MfaLoginParam struct {
	MfaToken string `json:"mfa_token,omitempty"`
	MfaCode  string `json:"mfa_code,omitempty"`
	MfaBind  bool   `json:"mfa_bind,omitempty"` // bind mfa when login, for enforcement mode
}

type MfaPatchData

type MfaPatchData struct {
	UpdatedAt   time.Time
	MfaEnabled  bool
	MfaKey      string
	MfaRecCodes string
	MfaSecret   string
}

type MfaType

type MfaType = string
const (
	MFA_TYPE_OTP   MfaType = "OTP"
	MFA_TYPE_SMS   MfaType = "SMS"
	MFA_TYPE_EMAIL MfaType = "EMAIL"
)

type SaveMfaKeyToDbCb

type SaveMfaKeyToDbCb[T string | primitive.ObjectID] func(uid T, data *MfaPatchData) error

Jump to

Keyboard shortcuts

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