Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from samblooms/master
Browse files Browse the repository at this point in the history
Add optional custom config directory $AUTHY_ROOT
  • Loading branch information
momaek authored Nov 17, 2022
2 parents 57fa55e + 8a5ebe4 commit 24bbc2d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ go get github.com/momaek/authy
8. Double click `Authy.alfredworkflow` or manual import from Alfred
9. Open Alfred and type `at {query}`

### *Optional Configuration*
By default, the authy config file (.authy.json) and cache (.authy.cache) are stored in `$HOME`.
A custom configuration directory can be set with the environment variable `$AUTHY_ROOT`

e.g.
```
export AUTHY_ROOT=~/.dotfiles/secrets/authy
```
the example above would create the config file `~/.dotfiles/secrets/authy/.authy.json`


#### Attention
To use this tool, you should enable *Allow Multi-Device* in your Authy App

Expand Down
12 changes: 10 additions & 2 deletions service/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,19 @@ func (d *Device) LoadExistingDeviceInfo() (devInfo DeviceRegistration, err error
}

// ConfigPath get config file path
// Return the path to the config file
// If the file does not exist, it will be created at $HOME ( or optionally AUTHY_ROOT )
func (d *Device) ConfigPath(fname string) (string, error) {
if len(d.conf.ConfigFilePath) == 0 {
authy_root_path, root_dir_exists := os.LookupEnv("AUTHY_ROOT")
devPath, err := homedir.Dir()
if err != nil {
return "", err
if root_dir_exists {
devPath = authy_root_path
d.conf.ConfigFilePath = devPath
} else {
if err != nil {
return "", err
}
}

d.conf.ConfigFilePath = devPath
Expand Down

0 comments on commit 24bbc2d

Please # to comment.