issueapi

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package issueapi implements the API handler for taking a code request, assigning an OTP, saving it to the database and returning the result. This is invoked over AJAX from the Web frontend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAlphanumericCode added in v0.19.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 added in v0.19.0

func GenerateCode(length uint) (string, error)

GenerateCode creates a new OTP code.

func ScrubPhoneNumbers added in v0.19.0

func ScrubPhoneNumbers(s string) string

ScrubPhoneNumbers checks for phone numbers in known Twilio error strings that contains user phone numbers.

func ValidateDate added in v0.19.0

func ValidateDate(date, minDate, maxDate time.Time, tzOffset int) (*time.Time, error)

ValidateDate validates the date given -- returning the time or an error.

Types

type Controller

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

func New

func New(config config.IssueAPIConfig, db *database.Database, limiter limiter.Store, h render.Renderer) *Controller

New creates a new IssueAPI controller.

func (*Controller) BatchIssueWithAPIAuth added in v0.19.0

func (c *Controller) BatchIssueWithAPIAuth(w http.ResponseWriter, r *http.Request) *IssueResult

func (*Controller) BatchIssueWithUIAuth added in v0.19.0

func (c *Controller) BatchIssueWithUIAuth(w http.ResponseWriter, r *http.Request) *IssueResult

func (*Controller) BuildVerificationCode added in v0.19.0

func (c *Controller) BuildVerificationCode(ctx context.Context, request *api.IssueCodeRequest, realm *database.Realm) (*database.VerificationCode, *IssueResult)

BuildVerificationCode populates and validates a code from an issue request.

func (*Controller) CommitCode added in v0.19.0

func (c *Controller) CommitCode(ctx context.Context, vCode *database.VerificationCode, realm *database.Realm, retryCount uint) error

CommitCode 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.

func (*Controller) HandleBatchIssueAPI added in v0.19.0

func (c *Controller) HandleBatchIssueAPI() http.Handler

HandleBatchIssueAPI responds to the /batch-issue API for issuing verification codes

func (*Controller) HandleBatchIssueUI added in v0.19.0

func (c *Controller) HandleBatchIssueUI() http.Handler

HandleBatchIssueUI responds to the /batch-issue API for issuing verification codes

func (*Controller) HandleIssueAPI added in v0.19.0

func (c *Controller) HandleIssueAPI() http.Handler

HandleIssueAPI responds to the /issue API for issuing verification codes

func (*Controller) HandleIssueUI added in v0.19.0

func (c *Controller) HandleIssueUI() http.Handler

HandleIssueUI responds to the /issue API for issuing verification codes

func (*Controller) IssueCode added in v0.19.0

func (c *Controller) IssueCode(ctx context.Context, vCode *database.VerificationCode, realm *database.Realm) *IssueResult

func (*Controller) IssueMany added in v0.19.0

func (c *Controller) IssueMany(ctx context.Context, requests []*api.IssueCodeRequest) []*IssueResult

func (*Controller) IssueOne added in v0.19.0

func (c *Controller) IssueOne(ctx context.Context, request *api.IssueCodeRequest) *IssueResult

func (*Controller) IssueWithAPIAuth added in v0.19.0

func (c *Controller) IssueWithAPIAuth(w http.ResponseWriter, r *http.Request) *IssueResult

func (*Controller) IssueWithUIAuth added in v0.19.0

func (c *Controller) IssueWithUIAuth(w http.ResponseWriter, r *http.Request) *IssueResult

func (*Controller) SendSMS added in v0.19.0

func (c *Controller) SendSMS(ctx context.Context, request *api.IssueCodeRequest, result *IssueResult, realm *database.Realm) error

type IssueResult added in v0.19.0

type IssueResult struct {
	VerCode     *database.VerificationCode
	ErrorReturn *api.ErrorReturn
	HTTPCode    int
	// contains filtered or unexported fields
}

IssueResult is the response returned from IssueLogic.IssueOne or IssueMany.

func (*IssueResult) IssueCodeResponse added in v0.19.0

func (result *IssueResult) IssueCodeResponse() *api.IssueCodeResponse

Jump to

Keyboard shortcuts

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