summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pquerna/otp/otp.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/pquerna/otp/otp.go')
-rw-r--r--vendor/github.com/pquerna/otp/otp.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/vendor/github.com/pquerna/otp/otp.go b/vendor/github.com/pquerna/otp/otp.go
index 1573ab0185..5db93029ce 100644
--- a/vendor/github.com/pquerna/otp/otp.go
+++ b/vendor/github.com/pquerna/otp/otp.go
@@ -54,17 +54,19 @@ type Key struct {
// NewKeyFromURL creates a new Key from an TOTP or HOTP url.
//
// The URL format is documented here:
-// https://code.google.com/p/google-authenticator/wiki/KeyUriFormat
+// https://github.com/google/google-authenticator/wiki/Key-Uri-Format
//
func NewKeyFromURL(orig string) (*Key, error) {
- u, err := url.Parse(orig)
+ s := strings.TrimSpace(orig)
+
+ u, err := url.Parse(s)
if err != nil {
return nil, err
}
return &Key{
- orig: orig,
+ orig: s,
url: u,
}, nil
}
@@ -136,6 +138,11 @@ func (k *Key) Secret() string {
return q.Get("secret")
}
+// URL returns the OTP URL as a string
+func (k *Key) URL() string {
+ return k.url.String()
+}
+
// Algorithm represents the hashing function to use in the HMAC
// operation needed for OTPs.
type Algorithm int