forked from forgejo/forgejo
Update github.com/pquerna/otp from untagged to v1.2.0 (#11358)
This commit is contained in:
parent
57b6f83191
commit
43bb85908d
16 changed files with 192 additions and 54 deletions
13
vendor/github.com/pquerna/otp/otp.go
generated
vendored
13
vendor/github.com/pquerna/otp/otp.go
generated
vendored
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue