otp

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package otp contains the implementation of the issuance of verification codes. Codes can be configured by creating an Request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAlphanumericCode added in v0.4.0

func GenerateAlphanumericCode(length uint) (string, error)

GenerateAlphanumericCode will generate an alpha numberic code. It uses the length to estimate how many bytes of randomness will base64 encode to that length string. For example 16 character string requires 12 bytes.

func GenerateCode

func GenerateCode(length uint) (string, error)

GenerateCode creates a new OTP code.

Types

type Request

type Request struct {
	DB             *database.Database
	RealmID        uint
	ShortLength    uint
	ShortExpiresAt time.Time
	LongLength     uint
	LongExpiresAt  time.Time
	TestType       string
	SymptomDate    *time.Time
	TestDate       *time.Time
	MaxSymptomAge  time.Duration
	UUID           string

	// Issuing includes information about the issuer.
	IssuingUser       *database.User
	IssuingApp        *database.AuthorizedApp
	IssuingExternalID string
}

Request represents the parameters of a verification code request.

func (*Request) Issue

func (o *Request) Issue(ctx context.Context, retryCount uint) (string, string, string, error)

Issue will generate a verification code and save it to the database, based on the paremters provided. It returns the short code, long code, a UUID for accessing the code, and any errors.

Jump to

Keyboard shortcuts

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