lockbox

password manager
Log | Files | Refs | README | LICENSE

commit 335c8a5e8bae5fed3d218c3d5ec11b339168e87f
parent 357ca2840e355b48c98bc8cc4fd4cbec25dcf845
Author: Sean Enck <sean@ttypty.com>
Date:   Sun,  2 Oct 2022 12:46:10 -0400

allow changing token for totp oath url

Diffstat:
Mcmd/vers.txt | 2+-
Minternal/backend/actions.go | 3+--
Minternal/inputs/env.go | 12+++++++++---
3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/cmd/vers.txt b/cmd/vers.txt @@ -1 +1 @@ -v22.10.04 +v22.10.05 diff --git a/internal/backend/actions.go b/internal/backend/actions.go @@ -3,7 +3,6 @@ package backend import ( "errors" - "fmt" "os" "path/filepath" "strings" @@ -190,7 +189,7 @@ func (t *Transaction) Move(src QueryEntity, dst string) error { field = notesKey } if NewSuffix(dTitle) == NewSuffix(inputs.TOTPToken()) { - url := fmt.Sprintf("otpauth://totp/totp:none?secret=%s&period=30&digits=6&issuer=lb", src.Value) + url := inputs.FormatTOTP(src.Value) e.Values = append(e.Values, protectedValue("otp", url)) } diff --git a/internal/inputs/env.go b/internal/inputs/env.go @@ -17,8 +17,8 @@ const ( noColorEnv = prefixKey + "NOCOLOR" interactiveEnv = prefixKey + "INTERACTIVE" readOnlyEnv = prefixKey + "READONLY" - // TotpEnv allows for overriding of the special name for totp entries. - TotpEnv = prefixKey + "TOTP" + fieldTOTPEnv = prefixKey + "TOTP" + formatTOTPEnv = fieldTOTPEnv + "_FORMAT" // KeyModeEnv indicates what the KEY value is (e.g. command, plaintext). KeyModeEnv = prefixKey + "KEYMODE" // KeyEnv is the key value used by the lockbox store. @@ -124,5 +124,11 @@ func IsInteractive() (bool, error) { // TOTPToken gets the name of the totp special case tokens func TOTPToken() string { - return EnvOrDefault(TotpEnv, "totp") + return EnvOrDefault(fieldTOTPEnv, "totp") +} + +// FormatTOTP will format a totp otpauth url +func FormatTOTP(value string) string { + v := EnvOrDefault(formatTOTPEnv, "otpauth://totp/totp:none?secret=%s&period=30&digits=6&issuer=lb") + return fmt.Sprintf(v, value) }