Swap base58 libraries (#472)
* Swap base58 libraries This doesn't reduce binary size but it removes a metric ton of dependencies.
This commit is contained in:
1 parent
c30fd5620e
commit
cf3fa4522d
10 files changed
+44
-35
No files matched your search
@@ -3,6 +3,7 @@ package base
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
@@ -15,7 +16,6 @@ import (
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/btcsuite/btcutil/base58"
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/authtokens"
|
||||
"github.com/hashicorp/boundary/sdk/wrapper"
|
||||
@@ -219,10 +219,13 @@ func (c *Command) Client(opt ...Option) (*api.Client, error) {
|
||||
token = ""
|
||||
}
|
||||
if token != "" {
|
||||
tokenBytes := base58.Decode(token)
|
||||
if len(tokenBytes) == 0 {
|
||||
tokenBytes, err := base64.RawStdEncoding.DecodeString(token)
|
||||
switch {
|
||||
case err != nil:
|
||||
c.UI.Error(fmt.Errorf("Error base64-unmarshaling stored token from system credential store: %w", err).Error())
|
||||
case len(tokenBytes) == 0:
|
||||
c.UI.Error("Zero length token after decoding stored token from system credential store")
|
||||
} else {
|
||||
default:
|
||||
var authToken authtokens.AuthToken
|
||||
if err := json.Unmarshal(tokenBytes, &authToken); err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error unmarshaling stored token information after reading from system credential store: %s", err))
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package authenticate
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcutil/base58"
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/authmethods"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
@@ -165,7 +165,7 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
c.UI.Error(fmt.Sprintf("Error marshaling auth token to save to system credential store: %s", err))
|
||||
return 1
|
||||
}
|
||||
if err := keyring.Set("HashiCorp Boundary Auth Token", tokenName, base58.Encode(marshaled)); err != nil {
|
||||
if err := keyring.Set("HashiCorp Boundary Auth Token", tokenName, base64.RawStdEncoding.EncodeToString(marshaled)); err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error saving auth token to system credential store: %s", err))
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcutil/base58"
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/targets"
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
@@ -30,6 +29,7 @@ import (
|
||||
"github.com/hashicorp/go-cleanhttp"
|
||||
"github.com/hashicorp/vault/sdk/helper/base62"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/mr-tron/base58"
|
||||
"github.com/posener/complete"
|
||||
"go.uber.org/atomic"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@@ -391,7 +391,11 @@ func (c *Command) Run(args []string) (retCode int) {
|
||||
authzString = sa.AuthorizationToken
|
||||
}
|
||||
|
||||
marshaled := base58.Decode(authzString)
|
||||
marshaled, err := base58.FastBase58Decoding(authzString)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Unable to base58-decode authorization data: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
if len(marshaled) == 0 {
|
||||
c.UI.Error("Zero length authorization information after decoding")
|
||||
return 1
|
||||
|
||||
Reference in new issue
Block a user