mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
multi: use ReadOnly param of BakeSuperMacaroon
This commit is contained in:
parent
a59bf2735d
commit
b4f8224c54
3 changed files with 12 additions and 5 deletions
|
|
@ -32,6 +32,11 @@ var litCommands = []cli.Command{
|
|||
"specified as a hex string using a " +
|
||||
"maximum of 8 characters.",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "read_only",
|
||||
Usage: "Whether the macaroon should " +
|
||||
"only contain read permissions.",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "save_to",
|
||||
Usage: "Save returned admin macaroon to " +
|
||||
|
|
@ -125,6 +130,7 @@ func bakeSuperMacaroon(ctx *cli.Context) error {
|
|||
resp, err := client.BakeSuperMacaroon(
|
||||
ctxb, &litrpc.BakeSuperMacaroonRequest{
|
||||
RootKeyIdSuffix: suffix,
|
||||
ReadOnly: ctx.Bool("read_only"),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -187,7 +187,8 @@ type rpcProxy struct {
|
|||
}
|
||||
|
||||
// bakeSuperMac can be used to bake a new super macaroon.
|
||||
type bakeSuperMac func(ctx context.Context, rootKeyID uint32) (string, error)
|
||||
type bakeSuperMac func(ctx context.Context, rootKeyID uint32,
|
||||
readOnly bool) (string, error)
|
||||
|
||||
// lndBasicClientFn can be used to obtain access to an lnrpc.LightningClient if
|
||||
// it is available.
|
||||
|
|
@ -255,7 +256,7 @@ func (p *rpcProxy) BakeSuperMacaroon(ctx context.Context,
|
|||
return nil, ErrWaitingToStart
|
||||
}
|
||||
|
||||
superMac, err := p.bakeSuperMac(ctx, req.RootKeyIdSuffix)
|
||||
superMac, err := p.bakeSuperMac(ctx, req.RootKeyIdSuffix, req.ReadOnly)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -584,8 +584,8 @@ func (g *LightningTerminal) start() error {
|
|||
|
||||
// bakeSuperMac is a closure that can be used to bake a new super
|
||||
// macaroon that contains all active permissions.
|
||||
bakeSuperMac := func(ctx context.Context, rootKeyIDSuffix uint32) (
|
||||
string, error) {
|
||||
bakeSuperMac := func(ctx context.Context, rootKeyIDSuffix uint32,
|
||||
readOnly bool) (string, error) {
|
||||
|
||||
var suffixBytes [4]byte
|
||||
binary.BigEndian.PutUint32(suffixBytes[:], rootKeyIDSuffix)
|
||||
|
|
@ -594,7 +594,7 @@ func (g *LightningTerminal) start() error {
|
|||
|
||||
return BakeSuperMacaroon(
|
||||
ctx, g.basicClient, rootKeyID,
|
||||
g.permsMgr.ActivePermissions(false), nil,
|
||||
g.permsMgr.ActivePermissions(readOnly), nil,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue