Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: allow LND and subserver whitelisted calls #617

Merged
merged 7 commits into from
Sep 8, 2023

Conversation

ellemouton
Copy link
Member

@ellemouton ellemouton commented Aug 7, 2023

This PR does a few things:

  1. Ensures that Lit register's LND's State server to it's REST server
  2. Allow LND's & Lit's and all Lit's subserver's whitelisted endpoints to pass through without requiring a macaroon

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@jamaljsr
Copy link
Member

jamaljsr commented Aug 8, 2023

When integrating with tapd's universe stats HTTP endpoints, I ran into an issue with litd requiring a macaroon for whitelisted RPCs.

Can this be addressed in this PR or should I open a separate issue?

@ellemouton
Copy link
Member Author

ah! great catch @jamaljsr ! Yeah I think it defs makes sense to add that in this PR. Will do asap 👍

perms/manager.go Show resolved Hide resolved
subservers/taproot-assets.go Outdated Show resolved Hide resolved
@ellemouton
Copy link
Member Author

@guggero - apologies, im re-requesting your review cause quite a bit has changed now so that whitelisted calls from other sub-servers are also taken into account

@ellemouton ellemouton changed the title multi: allow lnd whitelist calls multi: allow LND and subserver whitelisted calls Aug 11, 2023
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, just one small change then we're good to go.

subservers/taproot-assets.go Outdated Show resolved Hide resolved
perms/manager.go Outdated Show resolved Hide resolved
perms/manager.go Outdated Show resolved Hide resolved
@ellemouton
Copy link
Member Author

Thanks @guggero 🎉 updated!

subservers/taproot-assets.go Outdated Show resolved Hide resolved
@lightninglabs-deploy
Copy link

@ViktorTigerstrom: review reminder

Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, very clean PR 🔥🚀!

Just for clarification, I just want to verify as well that it's intentional that the LightningTerminal.Permissions function won't include any whitelisted urls, as will happen with this PR. That's intended behaviour, correct? I'm asking because I'm not 100% what "permissions for which the external validator of the terminal is responsible." really entails.

Before this commit, LND's State server could not be accessed via Lit's
REST server.
Currently `basicAuthToMacaroon` returns a different error for an
un-handled URI than is returned for other funcions which first check the
permissions manager to see if a URI is handled. With this commit, we
ensure that the error returned is the same so that the error we assert
on in tests can just be one error.
This commit adds a new `IsWhiteListURL` to the permissions manager. This
can then be used by LiT to check if it should perform macaroon
validation on a query or not.
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.
@ellemouton
Copy link
Member Author

Just for clarification, I just want to verify as well that it's intentional that the LightningTerminal.Permissions function won't include any whitelisted urls, as will happen with this PR. That's intended behaviour, correct? I'm asking because I'm not 100% what "permissions for which the external validator of the terminal is responsible." really entails.

As far as I can see, LightningTerminal.Permissions() calls perms.Manager.GetLitPerms() which returns everything in fixedPerms. If a Lit itself has whitelist perms, these will be added to fixedPerms in the NewManager function. Then, if any subserver registers whitelist URLs via RegisterSubServer, then these will also be added to fixedPerms. So Lightning.Permissions right now will include the whiltelist calls. Or am I misunderstanding?

@ViktorTigerstrom
Copy link
Contributor

ViktorTigerstrom commented Sep 7, 2023

As far as I can see, LightningTerminal.Permissions() calls perms.Manager.GetLitPerms() which returns everything in fixedPerms.

Ah wait, I realised that I was confused sorry. I interpreted yesterday that GetLitPerms looped over the specific []bakery.Op list for an url to add it to result, which would have resulted in whitelisted urls not getting added as a url is whitelisted by having an empty []bakery.Op list.
But I see now that GetLitPerms loops over the outer map[string][]bakery.Op, which should mean that the specific url does indeed get added with an empty []bakery.Op as the result.

Sorry for the confusion :).

@ellemouton ellemouton merged commit edab9a4 into lightninglabs:master Sep 8, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants