Don't assume our secret is base32 encoded.

According to https://en.wikipedia.org/wiki/Time-based_One-time_Password_algorithm
secrets are only base32 encoded in gauthenticator and gauth friendly providers.
This commit is contained in:
Aaron Bieber
2018-04-16 13:55:03 -06:00
committed by Kyle Isom
parent a1452cebc9
commit acefe4a3b9
3 changed files with 4 additions and 5 deletions

View File

@@ -152,7 +152,8 @@ func totpFromURL(u *url.URL) (*TOTP, string, error) {
key, err := base32.StdEncoding.DecodeString(secret)
if err != nil {
return nil, "", err
// secret isn't base32 encoded
key = []byte(secret)
}
otp := NewTOTP(key, 0, period, digits, algo)
return otp, label, nil