Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ The default time-based authentication codes are derived from a hash of the
key and the current time, so it is important that the system clock have at
least one-minute accuracy.

The keychain is stored unencrypted in the text file `$HOME/.2fa`.
The keychain is stored unencrypted in the text file $HOME/.2fa
or in $XDG_CONFIG_HOME/2fa if XDG_CONFIG_HOME is set.

## Example

Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
// the key and the current time, so it is important that the system clock have
// at least one-minute accuracy.
//
// The keychain is stored unencrypted in the text file $HOME/.2fa.
// The keychain is stored unencrypted in the text file $HOME/.2fa
// or in $XDG_CONFIG_HOME/2fa if XDG_CONFIG_HOME is set.
//
// Example
//
Expand Down Expand Up @@ -107,6 +108,9 @@ func main() {
flag.Parse()

k := readKeychain(filepath.Join(os.Getenv("HOME"), ".2fa"))
if os.Getenv("XDG_CONFIG_HOME") != "" {
k = readKeychain(filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "2fa"))
}

if *flagList {
if flag.NArg() != 0 {
Expand Down