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.
This commit is contained in:
Elle Mouton 2023-08-08 21:32:18 +02:00
parent 84df1bf966
commit 1332106eef
No known key found for this signature in database
GPG key ID: D7D916376026F177
5 changed files with 44 additions and 0 deletions

View file

@ -118,3 +118,11 @@ func (f *faradaySubServer) MacPath() string {
func (f *faradaySubServer) Permissions() map[string][]bakery.Op {
return perms.RequiredPermissions
}
// WhiteListedURLs returns a map of all the sub-server's URLs that can be
// accessed without a macaroon.
//
// NOTE: this is part of the SubServer interface.
func (f *faradaySubServer) WhiteListedURLs() map[string]struct{} {
return nil
}

View file

@ -58,4 +58,8 @@ type SubServer interface {
// Permissions returns a map of all RPC methods and their required
// macaroon permissions to access the sub-server.
Permissions() map[string][]bakery.Op
// WhiteListedURLs returns a map of all the sub-server's URLs that can
// be accessed without a macaroon.
WhiteListedURLs() map[string]struct{}
}

View file

@ -128,3 +128,11 @@ func (l *loopSubServer) MacPath() string {
func (l *loopSubServer) Permissions() map[string][]bakery.Op {
return perms.RequiredPermissions
}
// WhiteListedURLs returns a map of all the sub-server's URLs that can be
// accessed without a macaroon.
//
// NOTE: this is part of the SubServer interface.
func (l *loopSubServer) WhiteListedURLs() map[string]struct{} {
return nil
}

View file

@ -118,3 +118,11 @@ func (p *poolSubServer) MacPath() string {
func (p *poolSubServer) Permissions() map[string][]bakery.Op {
return perms.RequiredPermissions
}
// WhiteListedURLs returns a map of all the sub-server's URLs that can be
// accessed without a macaroon.
//
// NOTE: this is part of the SubServer interface.
func (p *poolSubServer) WhiteListedURLs() map[string]struct{} {
return nil
}

View file

@ -174,3 +174,19 @@ func (t *taprootAssetsSubServer) MacPath() string {
func (t *taprootAssetsSubServer) Permissions() map[string][]bakery.Op {
return perms.RequiredPermissions
}
// WhiteListedURLs returns a map of all the sub-server's URLs that can be
// accessed without a macaroon.
//
// NOTE: this is part of the SubServer interface.
func (t *taprootAssetsSubServer) WhiteListedURLs() map[string]struct{} {
// If the taproot-asset daemon is running in integrated mode, then we
// use cfg.RpcConf.AllowPublicStats to determine if the public stats
// endpoints should be included in the whitelist. If it is running in
// remote mode, however, then we don't know if the public stats are
// allowed, and so we just allow the request through since the remote
// daemon will handle blocking the call if it is not whitelisted there.
return perms.MacaroonWhitelist(
t.cfg.RpcConf.AllowPublicStats || t.remote,
)
}