Skip to content

Commit

Permalink
ToUpper base32 values for TOTP key ingress (#6400)
Browse files Browse the repository at this point in the history
Fixes #6396
  • Loading branch information
jefferai authored Mar 12, 2019
1 parent a94a4b8 commit 8b9c1e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion builtin/logical/totp/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"net/url"
"path"
"strings"
"testing"
"time"

Expand All @@ -25,7 +26,7 @@ func createKey() (string, error) {

key := keyUrl.Secret()

return key, err
return strings.ToLower(key), err
}

func generateCode(key string, period uint, digits otplib.Digits, algorithm otplib.Algorithm) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion builtin/logical/totp/path_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (b *backend) pathKeyCreate(ctx context.Context, req *logical.Request, data
return logical.ErrorResponse("the key value is required"), nil
}

_, err := base32.StdEncoding.DecodeString(keyString)
_, err := base32.StdEncoding.DecodeString(strings.ToUpper(keyString))
if err != nil {
return logical.ErrorResponse(fmt.Sprintf(
"invalid key value: %s", err)), nil
Expand Down

0 comments on commit 8b9c1e2

Please sign in to comment.