Skip to content

multi: add macaroon service and remove ui password use in litcli #308

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

Merged
merged 6 commits into from
Jun 7, 2022

Conversation

ellemouton
Copy link
Member

@ellemouton ellemouton commented Jan 7, 2022

Add a macaroon service to litd for its session rpc server and use this to validate incoming LitURI calls. Remove ui password requirement from litcli.

@ellemouton ellemouton requested a review from guggero January 7, 2022 11:16
@ellemouton ellemouton force-pushed the macaroonService branch 2 times, most recently from b69ed87 to ab37af6 Compare January 7, 2022 11:27

var (
// TODO(elle): Temp values. change these before landing pr.
nBytes, _ = hex.DecodeString(
Copy link
Member

Choose a reason for hiding this comment

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

Should instead be a key derived from the user's seed?

Copy link
Member Author

Choose a reason for hiding this comment

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

from the users seed in LND? yes this is the idea. So we have a static pubkey here (need to still gen a proper one) and then we derive a shared secret with lnd using this static key and a seed in LND using the DeriveSharedSecret endpoint. the macaroon service does this.
Is this what you mean or is there a litd user seed that you mean?

Copy link
Member

Choose a reason for hiding this comment

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

Here's the public key derived with numsgen from LNC with the phrase "Shared Secret": 0215b5a3e0ef58b101431e1e513dd017d1018b420bd2e89dcd71f45c031f00469e
Should probably mention the phrase and link to https://github.com/lightninglabs/lightning-node-connect/tree/master/mailbox/numsgen

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.

Great next step towards getting rid of the UI password!
Code looks very good, did an initial pass.

Will do some manual testing next.


var (
// TODO(elle): Temp values. change these before landing pr.
nBytes, _ = hex.DecodeString(
Copy link
Member

Choose a reason for hiding this comment

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

Here's the public key derived with numsgen from LNC with the phrase "Shared Secret": 0215b5a3e0ef58b101431e1e513dd017d1018b420bd2e89dcd71f45c031f00469e
Should probably mention the phrase and link to https://github.com/lightninglabs/lightning-node-connect/tree/master/mailbox/numsgen

@ellemouton ellemouton force-pushed the macaroonService branch 3 times, most recently from 3d664cc to e4f3ab4 Compare January 17, 2022 14:50
@ellemouton ellemouton requested a review from guggero January 31, 2022 11:17
@ellemouton ellemouton force-pushed the macaroonService branch 2 times, most recently from dd942fd to 5b93b03 Compare February 14, 2022 12:49
@ellemouton
Copy link
Member Author

this is pretty much ready for re-review. Just waiting on tagged releases for pool & faraday so the go.mod here can be bumped to include the macaroon service changes in those repos.

@guggero
Copy link
Member

guggero commented Mar 29, 2022

Can you rebase this when you have time please so I can do another pass?

@ellemouton
Copy link
Member Author

Mmmm ok I rebased but need to still figure out how to update the itests to use the macaroon path instead of ui password....

@ellemouton
Copy link
Member Author

ok, the itest is fixed now @guggero , this is ready for re-review 👍

(btw, the lnc-auth itest for remote mote consistently fails for me on my machine (on master branch too). any idea why that could be?)

guggero
guggero previously approved these changes Apr 12, 2022
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.

tACK, LGTM. Only nits and itest changes required. Also made sure the UI still works with the UI password.

@ellemouton ellemouton force-pushed the macaroonService branch 3 times, most recently from c767f6a to 86655ab Compare April 13, 2022 10:20
Copy link
Member Author

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Thanks @guggero 🚀 updated 👍

@ellemouton
Copy link
Member Author

erg the itests are failing now. dont think i quite understand what do want/dont want on the lnd vs litd port...

@ellemouton
Copy link
Member Author

nvm, i found the issue. will push up in a minute

guggero
guggero previously approved these changes Apr 13, 2022
@ellemouton
Copy link
Member Author

will update this today 👍

@ellemouton ellemouton force-pushed the macaroonService branch 3 times, most recently from 22b9432 to 29806d1 Compare May 16, 2022 13:04
@ellemouton
Copy link
Member Author

updated @guggero 😊

@ellemouton ellemouton requested review from guggero and Roasbeef May 18, 2022 13:33
guggero
guggero previously approved these changes May 19, 2022
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.

Two small things, otherwise looks good to me. Nice work 💯

guggero
guggero previously approved these changes May 20, 2022
@lightninglabs-deploy
Copy link

@Roasbeef: review reminder

Currently, if in lnd-remote mode, the tls cert path will be constructed
to be in the network directory which it should not be.
Let sessionRpcServer handle the session db and session server instead of
LightningTerminal handling those direclty. Then start the
sessionRpcServer as if it was a subserver like loop/pool.
Add a macaroonService to the main LightningTerminal struct.
Use the new macaroon service to verify LitURI calls.
@ellemouton
Copy link
Member Author

@Roasbeef , could you take a quick look at this pr? I think we are just waiting for your ACK here since you previously left some review comments on it

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

PR is looking pretty good! Only one main comment re allowing a read only session type when we go to validate the session type itself.

wrap := fmt.Errorf("invalid basic auth")
_, err := g.rpcProxy.convertBasicAuth(ctx, fullMethod, wrap)
if err != nil {
if !g.macaroonServiceStarted {
Copy link
Member

Choose a reason for hiding this comment

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

How are we planning on handling the rollout here re people with old litd installs and TW? Specifically, lets say a new TW client is running in the browser and goes to connect to my existing (unupgraded) litd node, as is this operation will fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

LitURI calls are not allowed through TW.

@@ -1,14 +1,11 @@
package main

import (
"context"
Copy link
Member

Choose a reason for hiding this comment

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

Note, this means that in stateless mode, litcli calls wont work and all calls will need to go through tht UI.

Which UI?

Isn't it the case that litcli can still just use the macaroon to interact w/ litd? Stateless just means we don't write the macaroon to disk, but as long as litcli can find that macaroon somehow, then things should work.

Copy link
Member Author

@ellemouton ellemouton Jun 7, 2022

Choose a reason for hiding this comment

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

Which UI?

The UI served from the Litd binary.

but as long as litcli can find that macaroon somehow, then things should work.

yeah 👍 updated the commit message 👍

"the necessary macaroon: %w", pubKeyBytes, err)
return nil
}
if sess.Type != session.TypeMacaroonAdmin &&
Copy link
Member

Choose a reason for hiding this comment

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

Below we check TypeMacaroonReadonly, so presumably we want to allow it here as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

see line 184?

Copy link
Member Author

Choose a reason for hiding this comment

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

this check errors out if type is not either admin or readonly. If it is one of those then it is allowed.

Remove the use of the UI password from litcl. Use the litd macaroon
instead. Note, this means that in stateless mode, litcli won't have a
macaroon to use on disk and one must be baked specifically.
@ellemouton ellemouton requested a review from Roasbeef June 7, 2022 09:48
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🥟

@guggero guggero merged commit 53618d9 into lightninglabs:master Jun 7, 2022
@ellemouton ellemouton deleted the macaroonService branch June 7, 2022 18:15
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.

4 participants