diff --git a/go.mod b/go.mod index aca71e7f88..6dabbe3715 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.15 require ( github.com/armon/go-metrics v0.3.4 - github.com/btcsuite/btcutil v1.0.2 github.com/bufbuild/buf v0.24.0 github.com/fatih/color v1.9.0 github.com/fatih/structs v1.1.0 @@ -42,6 +41,7 @@ require ( github.com/mitchellh/go-wordwrap v1.0.0 github.com/mitchellh/gox v1.0.1 github.com/mitchellh/mapstructure v1.3.3 + github.com/mr-tron/base58 v1.2.0 github.com/oligot/go-mod-upgrade v0.2.1 github.com/ory/dockertest/v3 v3.6.0 github.com/patrickmn/go-cache v2.1.0+incompatible diff --git a/go.sum b/go.sum index 204548245c..080ea97a65 100644 --- a/go.sum +++ b/go.sum @@ -107,7 +107,6 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -158,16 +157,6 @@ github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCS github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2uts= -github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bufbuild/buf v0.24.0 h1:lh0fKlL+gLvRtW1PaYUFvl+hVGVhz/japrhomsQ/xg4= github.com/bufbuild/buf v0.24.0/go.mod h1:klyqCtJViM5ky2cLvZGI6GjhNu1/YAtgJ8TuCKzEDEs= github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M= @@ -230,7 +219,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM= github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -696,7 +684,6 @@ github.com/jcmturner/gokrb5/v8 v8.2.0/go.mod h1:T1hnNppQsBtxW0tCHMHTkAt8n/sABdzZ github.com/jcmturner/rpc/v2 v2.0.2/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jefferai/isbadcipher v0.0.0-20190226160619-51d2077c035f h1:E87tDTVS5W65euzixn7clSzK66puSt1H4I5SC0EmHH4= github.com/jefferai/isbadcipher v0.0.0-20190226160619-51d2077c035f/go.mod h1:3J2qVK16Lq8V+wfiL2lPeDZ7UWMxk5LemerHa1p6N00= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= @@ -716,7 +703,6 @@ github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhB github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -739,7 +725,6 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.0 h1:wJbzvpYMVGG9iTI9VxpnNZfd4DzMPoCWze3GgSqz8yg= @@ -853,6 +838,8 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= +github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8/go.mod h1:86wM1zFnC6/uDBfZGNwB65O+pR2OFi5q/YQaEUid1qA= @@ -1125,7 +1112,6 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1146,7 +1132,6 @@ golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= diff --git a/internal/auth/auth.go b/internal/auth/auth.go index c90a271e5c..364f86862b 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -8,7 +8,6 @@ import ( "strings" "time" - "github.com/btcsuite/btcutil/base58" "github.com/hashicorp/boundary/globals" "github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes" "github.com/hashicorp/boundary/internal/gen/controller/tokens" @@ -23,6 +22,7 @@ import ( "github.com/hashicorp/go-hclog" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/kr/pretty" + "github.com/mr-tron/base58" "google.golang.org/protobuf/proto" ) @@ -500,7 +500,12 @@ func (v *verifier) decryptToken() { v.requestInfo.TokenFormat = AuthTokenTypeUnknown return } - marshaledToken := base58.Decode(v.requestInfo.EncryptedToken[len(globals.ServiceTokenV1):]) + marshaledToken, err := base58.FastBase58Decoding(v.requestInfo.EncryptedToken[len(globals.ServiceTokenV1):]) + if err != nil { + v.logger.Trace("decrypt bearer token: error unmarshaling base58 token; continuing as anonymous user", "error", err) + v.requestInfo.TokenFormat = AuthTokenTypeUnknown + return + } blobInfo := new(wrapping.EncryptedBlobInfo) if err := proto.Unmarshal(marshaledToken, blobInfo); err != nil { diff --git a/internal/authtoken/authtoken.go b/internal/authtoken/authtoken.go index da4d2136c7..140124e555 100644 --- a/internal/authtoken/authtoken.go +++ b/internal/authtoken/authtoken.go @@ -6,7 +6,6 @@ import ( mathrand "math/rand" "time" - "github.com/btcsuite/btcutil/base58" "github.com/hashicorp/boundary/globals" "github.com/hashicorp/boundary/internal/authtoken/store" "github.com/hashicorp/boundary/internal/db" @@ -15,6 +14,7 @@ import ( wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/go-kms-wrapping/structwrapping" "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/mr-tron/base58" "google.golang.org/protobuf/proto" ) @@ -133,5 +133,7 @@ func EncryptToken(ctx context.Context, kmsCache *kms.Kms, scopeId, publicId, tok return "", fmt.Errorf("error marshaling encrypted token: %w", err) } - return globals.ServiceTokenV1 + base58.Encode(marshaledBlob), nil + encoded := base58.FastBase58Encoding(marshaledBlob) + + return globals.ServiceTokenV1 + encoded, nil } diff --git a/internal/cmd/base/base.go b/internal/cmd/base/base.go index d7f5c7e2cc..01bb7613f4 100644 --- a/internal/cmd/base/base.go +++ b/internal/cmd/base/base.go @@ -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)) diff --git a/internal/cmd/commands/authenticate/password.go b/internal/cmd/commands/authenticate/password.go index 299b709352..8d52369aad 100644 --- a/internal/cmd/commands/authenticate/password.go +++ b/internal/cmd/commands/authenticate/password.go @@ -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 } diff --git a/internal/cmd/commands/proxy/proxy.go b/internal/cmd/commands/proxy/proxy.go index 4ab495a3a2..6544499331 100644 --- a/internal/cmd/commands/proxy/proxy.go +++ b/internal/cmd/commands/proxy/proxy.go @@ -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 diff --git a/internal/servers/controller/handlers/sessions/session_service_test.go b/internal/servers/controller/handlers/sessions/session_service_test.go index 09debd1d09..85049cfb55 100644 --- a/internal/servers/controller/handlers/sessions/session_service_test.go +++ b/internal/servers/controller/handlers/sessions/session_service_test.go @@ -78,6 +78,7 @@ func TestGetSession(t *testing.T) { ExpirationTime: sess.ExpirationTime.GetTimestamp(), Scope: &scopes.ScopeInfo{Id: p.GetPublicId(), Type: scope.Project.String()}, States: []*pb.SessionState{{Status: session.StatusPending.String(), StartTime: sess.CreateTime.GetTimestamp()}}, + Certificate: sess.Certificate, } cases := []struct { @@ -191,6 +192,7 @@ func TestList(t *testing.T) { Scope: &scopes.ScopeInfo{Id: pWithSessions.GetPublicId(), Type: scope.Project.String()}, Status: status, States: states, + Certificate: sess.Certificate, }) } @@ -299,6 +301,7 @@ func TestCancel(t *testing.T) { ExpirationTime: sess.ExpirationTime.GetTimestamp(), Scope: &scopes.ScopeInfo{Id: p.GetPublicId(), Type: scope.Project.String()}, Status: session.StatusCanceling.String(), + Certificate: sess.Certificate, } version := wireSess.GetVersion() diff --git a/internal/servers/controller/handlers/targets/target_service.go b/internal/servers/controller/handlers/targets/target_service.go index b6397a3e54..02ac3e9253 100644 --- a/internal/servers/controller/handlers/targets/target_service.go +++ b/internal/servers/controller/handlers/targets/target_service.go @@ -7,7 +7,6 @@ import ( "math/rand" "net/url" - "github.com/btcsuite/btcutil/base58" "github.com/golang/protobuf/ptypes/wrappers" "github.com/hashicorp/boundary/internal/auth" "github.com/hashicorp/boundary/internal/db" @@ -25,6 +24,7 @@ import ( "github.com/hashicorp/boundary/internal/types/action" "github.com/hashicorp/boundary/internal/types/resource" "github.com/hashicorp/boundary/internal/types/scope" + "github.com/mr-tron/base58" "google.golang.org/grpc/codes" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" @@ -401,13 +401,15 @@ HostSetIterationLoop: if err != nil { return nil, err } + encodedMarshaledSad := base58.FastBase58Encoding(marshaledSad) + ret := &pb.SessionAuthorization{ SessionId: sess.PublicId, TargetId: t.GetPublicId(), Scope: authResults.Scope, CreatedTime: sess.CreateTime.GetTimestamp(), Type: t.GetType(), - AuthorizationToken: base58.Encode(marshaledSad), + AuthorizationToken: string(encodedMarshaledSad), UserId: authResults.UserId, HostId: chosenId.hostId, HostSetId: chosenId.hostSetId, diff --git a/sdk/recovery/recovery.go b/sdk/recovery/recovery.go index 4cbc14d4ac..a79db7cc94 100644 --- a/sdk/recovery/recovery.go +++ b/sdk/recovery/recovery.go @@ -9,9 +9,9 @@ import ( "strings" "time" - "github.com/btcsuite/btcutil/base58" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/go-uuid" + "github.com/mr-tron/base58" "google.golang.org/protobuf/proto" ) @@ -61,7 +61,9 @@ func formatToken(ctx context.Context, wrapper wrapping.Wrapper, info *Info) (str return "", fmt.Errorf("error marshaling encrypted blob: %w", err) } - return fmt.Sprintf("r_%s%s", v1String, base58.Encode(marshaledBlob)), nil + encodedMarshaledBlob := base58.FastBase58Encoding(marshaledBlob) + + return fmt.Sprintf("r_%s%s", v1String, encodedMarshaledBlob), nil } func ParseRecoveryToken(ctx context.Context, wrapper wrapping.Wrapper, versionedToken string) (*Info, error) { @@ -84,7 +86,10 @@ func ParseRecoveryToken(ctx context.Context, wrapper wrapping.Wrapper, versioned return nil, fmt.Errorf("unknown recovery token version %s", ver) } - marshaledBlob := base58.Decode(token) + marshaledBlob, err := base58.FastBase58Decoding(token) + if err != nil { + return nil, fmt.Errorf("error base58-decoding token: %w", err) + } if len(marshaledBlob) == 0 { return nil, fmt.Errorf("length zero after base58-decoding token") }