Skip to content

Commit 1332106

Browse files
committed
subservers: add WhiteListedURLs to the SubServer interface
Add a new `WhiteListedURLs` method to the `SubServer` interface so that Lit can easily collect the set of permissions from each sub-server that does not require a macaroon.
1 parent 84df1bf commit 1332106

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

subservers/faraday.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,11 @@ func (f *faradaySubServer) MacPath() string {
118118
func (f *faradaySubServer) Permissions() map[string][]bakery.Op {
119119
return perms.RequiredPermissions
120120
}
121+
122+
// WhiteListedURLs returns a map of all the sub-server's URLs that can be
123+
// accessed without a macaroon.
124+
//
125+
// NOTE: this is part of the SubServer interface.
126+
func (f *faradaySubServer) WhiteListedURLs() map[string]struct{} {
127+
return nil
128+
}

subservers/interface.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,8 @@ type SubServer interface {
5858
// Permissions returns a map of all RPC methods and their required
5959
// macaroon permissions to access the sub-server.
6060
Permissions() map[string][]bakery.Op
61+
62+
// WhiteListedURLs returns a map of all the sub-server's URLs that can
63+
// be accessed without a macaroon.
64+
WhiteListedURLs() map[string]struct{}
6165
}

subservers/loop.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,11 @@ func (l *loopSubServer) MacPath() string {
128128
func (l *loopSubServer) Permissions() map[string][]bakery.Op {
129129
return perms.RequiredPermissions
130130
}
131+
132+
// WhiteListedURLs returns a map of all the sub-server's URLs that can be
133+
// accessed without a macaroon.
134+
//
135+
// NOTE: this is part of the SubServer interface.
136+
func (l *loopSubServer) WhiteListedURLs() map[string]struct{} {
137+
return nil
138+
}

subservers/pool.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,11 @@ func (p *poolSubServer) MacPath() string {
118118
func (p *poolSubServer) Permissions() map[string][]bakery.Op {
119119
return perms.RequiredPermissions
120120
}
121+
122+
// WhiteListedURLs returns a map of all the sub-server's URLs that can be
123+
// accessed without a macaroon.
124+
//
125+
// NOTE: this is part of the SubServer interface.
126+
func (p *poolSubServer) WhiteListedURLs() map[string]struct{} {
127+
return nil
128+
}

subservers/taproot-assets.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,19 @@ func (t *taprootAssetsSubServer) MacPath() string {
174174
func (t *taprootAssetsSubServer) Permissions() map[string][]bakery.Op {
175175
return perms.RequiredPermissions
176176
}
177+
178+
// WhiteListedURLs returns a map of all the sub-server's URLs that can be
179+
// accessed without a macaroon.
180+
//
181+
// NOTE: this is part of the SubServer interface.
182+
func (t *taprootAssetsSubServer) WhiteListedURLs() map[string]struct{} {
183+
// If the taproot-asset daemon is running in integrated mode, then we
184+
// use cfg.RpcConf.AllowPublicStats to determine if the public stats
185+
// endpoints should be included in the whitelist. If it is running in
186+
// remote mode, however, then we don't know if the public stats are
187+
// allowed, and so we just allow the request through since the remote
188+
// daemon will handle blocking the call if it is not whitelisted there.
189+
return perms.MacaroonWhitelist(
190+
t.cfg.RpcConf.AllowPublicStats || t.remote,
191+
)
192+
}

0 commit comments

Comments
 (0)