Skip to content

Commit

Permalink
Don't assume first value is non-url format. (gopasspw#467)
Browse files Browse the repository at this point in the history
The first entry can be OTP shared secret or the URL. This fixes
  • Loading branch information
qbit authored and dominikschulz committed Nov 16, 2017
1 parent dfcf210 commit d30ad5d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion action/otp.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ func (s *Action) OTP(ctx context.Context, c *cli.Context) error {
secKey = sec.Password()
}

otp, err = twofactor.NewGoogleTOTP(secKey)
if strings.HasPrefix(secKey, "otpauth://") {
otp, label, err = twofactor.FromURL(secKey)
} else {
otp, err = twofactor.NewGoogleTOTP(secKey)
}

if err != nil {
return s.exitError(ctx, ExitUnknown, err, "No OTP entry found for %s", name)
}
Expand Down

0 comments on commit d30ad5d

Please sign in to comment.