Skip to content

Commit ab8c022

Browse files
committed
subservers: add Permissions method to the interface
1 parent 53d0d84 commit ab8c022

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

subservers/faraday.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import (
77
"github.com/lightninglabs/faraday"
88
"github.com/lightninglabs/faraday/frdrpc"
99
"github.com/lightninglabs/faraday/frdrpcserver"
10+
"github.com/lightninglabs/faraday/frdrpcserver/perms"
1011
"github.com/lightninglabs/lndclient"
1112
"github.com/lightningnetwork/lnd/lnrpc"
1213
"google.golang.org/grpc"
14+
"gopkg.in/macaroon-bakery.v2/bakery"
1315
)
1416

1517
// faradaySubServer implements the SubServer interface.
@@ -108,3 +110,11 @@ func (f *faradaySubServer) ServerErrChan() chan error {
108110
func (f *faradaySubServer) MacPath() string {
109111
return f.cfg.MacaroonPath
110112
}
113+
114+
// Permissions returns a map of all RPC methods and their required macaroon
115+
// permissions to access the sub-server.
116+
//
117+
// NOTE: this is part of the SubServer interface.
118+
func (f *faradaySubServer) Permissions() map[string][]bakery.Op {
119+
return perms.RequiredPermissions
120+
}

subservers/interface.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/lightningnetwork/lnd/lnrpc"
99
"github.com/lightningnetwork/lnd/macaroons"
1010
"google.golang.org/grpc"
11+
"gopkg.in/macaroon-bakery.v2/bakery"
1112
)
1213

1314
// SubServer defines an interface that should be implemented by any sub-server
@@ -53,4 +54,8 @@ type SubServer interface {
5354
// MacPath returns the path to the sub-server's macaroon if it is not
5455
// running in remote mode.
5556
MacPath() string
57+
58+
// Permissions returns a map of all RPC methods and their required
59+
// macaroon permissions to access the sub-server.
60+
Permissions() map[string][]bakery.Op
5661
}

subservers/loop.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import (
77
"github.com/lightninglabs/lndclient"
88
"github.com/lightninglabs/loop"
99
"github.com/lightninglabs/loop/loopd"
10+
"github.com/lightninglabs/loop/loopd/perms"
1011
"github.com/lightninglabs/loop/looprpc"
1112
"github.com/lightningnetwork/lnd/lnrpc"
1213
"google.golang.org/grpc"
14+
"gopkg.in/macaroon-bakery.v2/bakery"
1315
)
1416

1517
// loopSubServer implements the SubServer interface.
@@ -118,3 +120,11 @@ func (l *loopSubServer) ServerErrChan() chan error {
118120
func (l *loopSubServer) MacPath() string {
119121
return l.cfg.MacaroonPath
120122
}
123+
124+
// Permissions returns a map of all RPC methods and their required macaroon
125+
// permissions to access the sub-server.
126+
//
127+
// NOTE: this is part of the SubServer interface.
128+
func (l *loopSubServer) Permissions() map[string][]bakery.Op {
129+
return perms.RequiredPermissions
130+
}

subservers/pool.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import (
66
restProxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
77
"github.com/lightninglabs/lndclient"
88
"github.com/lightninglabs/pool"
9+
"github.com/lightninglabs/pool/perms"
910
"github.com/lightninglabs/pool/poolrpc"
1011
"github.com/lightningnetwork/lnd/lnrpc"
1112
"google.golang.org/grpc"
13+
"gopkg.in/macaroon-bakery.v2/bakery"
1214
)
1315

1416
// poolSubServer implements the SubServer interface.
@@ -108,3 +110,11 @@ func (p *poolSubServer) ServerErrChan() chan error {
108110
func (p *poolSubServer) MacPath() string {
109111
return p.cfg.MacaroonPath
110112
}
113+
114+
// Permissions returns a map of all RPC methods and their required macaroon
115+
// permissions to access the sub-server.
116+
//
117+
// NOTE: this is part of the SubServer interface.
118+
func (p *poolSubServer) Permissions() map[string][]bakery.Op {
119+
return perms.RequiredPermissions
120+
}

0 commit comments

Comments
 (0)