Make sure our secret is always uppercase

Non-uppercase secrets that are base32 encoded will fial to decode
unless we upper them.
This commit is contained in:
Aaron Bieber
2017-09-17 15:41:16 -06:00
committed by Kyle Isom
parent 5d57d844d4
commit eaad1884d4
2 changed files with 4 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import (
"io" "io"
"net/url" "net/url"
"strconv" "strconv"
"strings"
) )
// HOTP represents an RFC-4226 Hash-based One Time Password instance. // HOTP represents an RFC-4226 Hash-based One Time Password instance.
@@ -64,7 +65,7 @@ func hotpFromURL(u *url.URL) (*HOTP, string, error) {
label := u.Path[1:] label := u.Path[1:]
v := u.Query() v := u.Query()
secret := v.Get("secret") secret := strings.ToUpper(v.Get("secret"))
if secret == "" { if secret == "" {
return nil, "", ErrInvalidURL return nil, "", ErrInvalidURL
} }

View File

@@ -10,6 +10,7 @@ import (
"io" "io"
"net/url" "net/url"
"strconv" "strconv"
"strings"
"time" "time"
) )
@@ -115,7 +116,7 @@ func totpFromURL(u *url.URL) (*TOTP, string, error) {
label := u.Path[1:] label := u.Path[1:]
v := u.Query() v := u.Query()
secret := v.Get("secret") secret := strings.ToUpper(v.Get("secret"))
if secret == "" { if secret == "" {
return nil, "", ErrInvalidURL return nil, "", ErrInvalidURL
} }