Skip to content

Commit 3b690f8

Browse files
committed
multi: validate macaroons for lit calls
Use the new macaroon service to verify LitURI calls.
1 parent bd77c1a commit 3b690f8

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

rpc_proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ func (p *rpcProxy) basicAuthToMacaroon(basicAuth, requestURI string,
499499
}
500500

501501
case isLitURI(requestURI):
502-
return []byte("no-macaroons-for-litcli"), nil
502+
macPath = p.cfg.MacaroonPath
503503

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

subserver_permissions.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,18 @@ var (
1212
// litPermissions is a map of all LiT RPC methods and their required
1313
// macaroon permissions to access the session service.
1414
litPermissions = map[string][]bakery.Op{
15-
"/litrpc.Sessions/AddSession": {{}},
16-
"/litrpc.Sessions/ListSessions": {{}},
17-
"/litrpc.Sessions/RevokeSession": {{}},
15+
"/litrpc.Sessions/AddSession": {{
16+
Entity: "sessions",
17+
Action: "write",
18+
}},
19+
"/litrpc.Sessions/ListSessions": {{
20+
Entity: "sessions",
21+
Action: "read",
22+
}},
23+
"/litrpc.Sessions/RevokeSession": {{
24+
Entity: "sessions",
25+
Action: "write",
26+
}},
1827
}
1928

2029
// whiteListedMethods is a map of all lnd RPC methods that don't require

terminal.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,12 +740,12 @@ func (g *LightningTerminal) ValidateMacaroon(ctx context.Context,
740740
}
741741

742742
case isLitURI(fullMethod):
743-
wrap := fmt.Errorf("invalid basic auth")
744-
_, err := g.rpcProxy.convertBasicAuth(ctx, fullMethod, wrap)
745-
if err != nil {
743+
if err := g.sessionRpcServer.macaroonService.ValidateMacaroon(
744+
ctx, requiredPermissions, fullMethod,
745+
); err != nil {
746746
return &proxyErr{
747747
proxyContext: "lit",
748-
wrapped: fmt.Errorf("invalid auth: %v",
748+
wrapped: fmt.Errorf("invalid macaroon: %w",
749749
err),
750750
}
751751
}

0 commit comments

Comments
 (0)