gauth

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: ISC Imports: 14 Imported by: 1

Documentation

Overview

Package gauth implements the time-based OTP generation scheme used by Google Authenticator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Codes

func Codes(u *otpauth.URL) (prev, curr, next string, _ error)

Codes returns the previous, current, and next codes from u.

func CodesAtTimeStep

func CodesAtTimeStep(u *otpauth.URL, timeStep uint64) (prev, curr, next string, _ error)

CodesAtTimeStep returns the previous, current, and next codes from u at the given time step value.

func IndexNow

func IndexNow() (uint64, int)

IndexNow returns the current 30-second time step, and the number of seconds remaining until it ends.

func LoadConfigFile

func LoadConfigFile(path string, getPass func() ([]byte, error)) ([]byte, error)

LoadConfigFile reads and decrypts, if necessary, the CSV config at path. The getPass function is called to obtain a password if needed.

func ParseConfig

func ParseConfig(data []byte) ([]*otpauth.URL, error)

ParseConfig parses the contents of data as a gauth configuration file. Each line of the file specifies a single configuration.

The basic configuration format is:

name:secret

where "name" is the site name and "secret" is the base32-encoded secret. This represents a default Google authenticator code with 6 digits and a 30-second refresh.

Otherwise, a line must be a URL in the format:

otpauth://TYPE/LABEL?PARAMETERS

func ReadConfigFile added in v1.3.0

func ReadConfigFile(path string) ([]byte, bool, error)

ReadConfigFile reads the config file at path and returns its contents and whether it is encrypted or not

func WriteConfigFile added in v1.3.0

func WriteConfigFile(path string, passwd []byte, newConfig []byte) error

WriteConfigFile encrypts the provided newConfig using passwd, if necessary, and writes it to path

Types

This section is empty.

Jump to

Keyboard shortcuts

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