authenticator

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// QRSize indicates the size of the generated image containing the QR code.
	QRSize = 256
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyUri

type KeyUri struct {
	Type       string          `json:"type"` // hotp | totp
	Label      Label           `json:"label"`
	Parameters paramsFormatter `json:"parameters"`
}

The KeyUri type holds all the config necessary to generate a valid registration URI for any authenticator app, e.g.: Google Authenticator, Authy, etc.

func (*KeyUri) QRCode

func (ku *KeyUri) QRCode() (string, error)

QRCode will encode the value returned by KeyUri.String into a base64 encoded image containing a QR code that can be displayed and then scanned by the user. The return value is the base64 encoded image data.

func (*KeyUri) String

func (ku *KeyUri) String() string

String encodes all the KeyUri info as a valid URI.

type Label

type Label struct {
	AccountName string `json:"accountName"` // Should be a username, email, etc.
	Issuer      string `json:"issuer"`      // Should be the domain, company, org that is issuing the auth
}

The Label is used to identify which account a key is associated with.

func (*Label) String

func (l *Label) String() string

The String method will encode the Label in a valid format to be included in the key URI.

Jump to

Keyboard shortcuts

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