totp

package
v4.38.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTOTPOptionsFromSchema added in v4.38.0

func NewTOTPOptionsFromSchema(config schema.TOTP) *model.TOTPOptions

Types

type Context added in v4.38.0

type Context interface {
	context.Context

	GetClock() clock.Provider
	GetRandom() random.Provider
}

func NewContext added in v4.38.0

func NewContext(ctx context.Context, clock clock.Provider, random random.Provider) Context

type Provider

type Provider interface {
	Generate(ctx Context, username string) (config *model.TOTPConfiguration, err error)
	GenerateCustom(ctx Context, username string, algorithm, secret string, digits, period, secretSize uint) (config *model.TOTPConfiguration, err error)
	Validate(ctx Context, token string, config *model.TOTPConfiguration) (valid bool, step uint64, err error)
	Options() model.TOTPOptions
}

Provider for TOTP functionality.

type SimpleContext added in v4.38.0

type SimpleContext struct {
	context.Context
	// contains filtered or unexported fields
}

func (*SimpleContext) GetClock added in v4.38.0

func (c *SimpleContext) GetClock() clock.Provider

func (*SimpleContext) GetRandom added in v4.38.0

func (c *SimpleContext) GetRandom() random.Provider

type TimeBased

type TimeBased struct {
	// contains filtered or unexported fields
}

TimeBased totp.Provider for production use.

func NewTimeBasedProvider

func NewTimeBasedProvider(config schema.TOTP) (provider *TimeBased)

NewTimeBasedProvider creates a new totp.TimeBased which implements the totp.Provider.

func (TimeBased) Generate

func (p TimeBased) Generate(ctx Context, username string) (config *model.TOTPConfiguration, err error)

Generate generates a TOTP with default options.

func (TimeBased) GenerateCustom

func (p TimeBased) GenerateCustom(ctx Context, username, algorithm, secret string, digits, period, secretSize uint) (config *model.TOTPConfiguration, err error)

GenerateCustom generates a TOTP with custom options.

func (TimeBased) Options added in v4.38.0

func (p TimeBased) Options() model.TOTPOptions

Options returns the configured options for this provider.

func (TimeBased) Validate

func (p TimeBased) Validate(ctx Context, token string, config *model.TOTPConfiguration) (valid bool, step uint64, err error)

Validate the token against the given configuration.

Jump to

Keyboard shortcuts

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