Skip to content

Commit 43ed7ed

Browse files
committed
rpc_proxy+litcli: replace dummy string with empty macaroon
To avoid the macaroon parsing to fail in session.IsSuperMacaroon(), we want the dummy macaroon to be formally valid (meaning, it can be parsed) but not actually valid (meaning, it will fail the signature verification since we don't have the root key for it anywhere).
1 parent 517b598 commit 43ed7ed

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cmd/litcli/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"context"
55
"encoding/base64"
6+
"encoding/hex"
67
"fmt"
78
"os"
89
"path/filepath"
@@ -210,7 +211,7 @@ func getAuthContext(cliCtx *cli.Context) context.Context {
210211
ctxb := context.Background()
211212
md := metadata.MD{}
212213

213-
md.Set("macaroon", "no-macaroons-for-litcli")
214+
md.Set("macaroon", hex.EncodeToString(terminal.EmptyMacaroonBytes))
214215
md.Set("authorization", fmt.Sprintf("Basic %s", basicAuth))
215216

216217
return metadata.NewOutgoingContext(ctxb, md)

rpc_proxy.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ const (
3333
HeaderMacaroon = "Macaroon"
3434
)
3535

36+
var (
37+
// EmptyMacaroonBytes is the byte representation of an empty but
38+
// formally valid macaroon.
39+
EmptyMacaroonBytes, _ = hex.DecodeString(
40+
"020205656d7074790000062062083e2ea599285ac29350abb4ea21fd7c5a" +
41+
"15aca8b4c0d38e6c058829369e50",
42+
)
43+
)
44+
3645
// proxyErr is an error type that adds more context to an error occurring in the
3746
// proxy.
3847
type proxyErr struct {
@@ -499,7 +508,7 @@ func (p *rpcProxy) basicAuthToMacaroon(basicAuth, requestURI string,
499508
}
500509

501510
case isLitURI(requestURI):
502-
return []byte("no-macaroons-for-litcli"), nil
511+
return EmptyMacaroonBytes, nil
503512

504513
default:
505514
return nil, fmt.Errorf("unknown gRPC web request: %v",

0 commit comments

Comments
 (0)