twothy

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: Unlicense Imports: 21 Imported by: 0

README

Twothy

Build Status GitHub tag License GitHub issues Contributions welcome GitHub pull requests Website

Twothy is a Two-factor authenticator for CLI. The project is a reference implementation of RFC 6238 and is compatible with Google Authenticator. The project was born out of frustration to get OTP from my Mobile and lack of control over and backup of Secrets. With a simple configuration, twothy can work across multiple devices without the need to regenerate the secrets for each 2FA enabled accounts. More here

Getting Started

Installation assumes that you have Go environment configured.

Installing

Go get the project with following command

go get -u github.com/vedhavyas/twothy/cmd/twothy/...

Running the tests

Once inside project' folder, simply run make test to run the tests.

Usage
Configuring twothy

Twothy requires you to provide a path to store the accounts. Configuration can be triggered by

>> twothy configure
Welcome to twothy!!
Enter the path to store your 2FA accounts.
I will create 'twothy_accounts' folder at the provided path.
If you are restoring accounts, provide path to 'twothy_accounts'.
Path(/Users/vedhavyas):

Once you enter path, which defaults to user's home directory if not given, twothy will store all the accounts there. Configure will be triggered if any other action is called ex: add

Adding an account

Adding account requires Issuer, Label and the secret Key.

>> twothy add google test MZZWCLDCOZSGMYTKONSGM===
Password(to encrypt the account):
test@google: 168339
Generating OTPs

Generating OTP for all accounts

>> twothy otp
Password(to decrypt the account):
test@google: 772912

Generating OTPs for all accounts belonging to an issuer

>> twothy otp google
Password(to decrypt the account):
test@google: 017934

Generating OTP for an account matching issuer and label

>> twothy otp google test
Password(to decrypt the account):
test@google: 917472

Security

Twothy uses AES to encrypt your accounts. It doesn't cache any passwords and requires password to add account and generate OTP.

Backup

I use google drive to backup my 2FA accounts by configuring twothy to save accounts inside Google Drive folder. You are free to use your favourite backup service to achieve something similar

Built With

  • Go
  • Glide - Dependency Management
  • HomeDir - Used to get User's home directory
  • Crypto - Used to get password from terminal securely

Contributing

PRs, Issues, and Feedback are very welcome and appreciated.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the Unlicense - see the LICENSE file for details

Documentation

Index

Constants

View Source
const (
	// DefaultStepTime as per RFC 6238 is 30 seconds
	DefaultStepTime = 30

	// DefaultT0 as per RFC 6238 is 0
	DefaultT0 = 0

	// DefaultDigits as per RFC 6238 is 6 digits
	DefaultDigits = 6
)

Variables

This section is empty.

Functions

func CreateOTP

func CreateOTP(a Account, time int64) (otp string, err error)

CreateOTP creates opt for account at given time

func ExecOp

func ExecOp(cmd string, args ...string) (result string, err error)

ExecOp executes the given operation

func SaveAccount

func SaveAccount(c Config, a Account, pwd []byte) error

SaveAccount writes account info to twothy folder

Types

type Account

type Account struct {
	Issuer   string `json:"issuer"`
	Label    string `json:"label"`
	T0       int    `json:"t_0"`
	StepTime int    `json:"step_time"`
	Digits   int    `json:"digits"`
	Key      string `json:"key"`
}

Account represents a single 2fa activated account Issuer and Label together provides a unique account even for same service. Ex: google with multiple accounts

func LoadAccounts

func LoadAccounts(c Config, issuer, label string, pwd []byte) (accounts []Account, err error)

LoadAccounts will a load accounts matching issuer and label if label is empty, loads all the accounts matching issuer if issuer and label are empty, all th accounts are returned

func NewAccount

func NewAccount(issuer, label, key string) Account

NewAccount returns a new 2fa account with default values

type Config

type Config struct {
	AccountsFolder string `json:"accounts_folder"`
}

Config holds the path of the accounts

func Configure

func Configure(homeDir string) (config Config, err error)

Configure configures twothy

func GetConfig

func GetConfig() (config Config, err error)

GetConfig returns twothy config

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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