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

lncli: add command to create new macaroon #1160

Merged
merged 3 commits into from Oct 25, 2019

Conversation

@guggero
Copy link
Collaborator

guggero commented Apr 30, 2018

As discussed in #1147 there is a need to create macaroons with custom permissions set since the three existing macaroon files admin.macaroon, invoice.macaroon and readonly.macaroon aren't fine-grained enough.

A new gRPC method named NewMacaroon is added:

  • Introduces a new permission entity named macaroon (could be used for macaroon based RPCs mentioned in #291 too).
  • write access to the entity macaroon is necessary to call the method NewMacaroon.
  • The admin.macaroon gets write access to the entity macaroon.
  • A new command is added to lncli named newmacaroon that calls this gRPC method.
  • As parameters to the NewMacaroon method a list of entity/action pairs for the allowed operations can be passed.

Example:

lncli newmacaroon --permission=invoices/write --permission=invoices/read --save_to=~/.lnd/custom-invoice.macaroon --timeout=10

Creates a macaroon that is valid for reading and writing invoices during the next 10 seconds.

Closes #283, #1147, #3516.

NOTE for release notes: Users will need to delete or move their admin.macaroon, readonly.macaroon and invoices.macaroon before starting 0.9, otherwise they won't get regenerated macaroons that have the required permission (macaroon:generate) to mint custom macaroons.

@vegardengen

This comment has been minimized.

Copy link
Contributor

vegardengen commented Apr 30, 2018

This one actually conflicts with #1147

Would it make sense to make this into one common PR? Or merge one, then rebase/fix conflicts after that?

@guggero

This comment has been minimized.

Copy link
Collaborator Author

guggero commented May 1, 2018

If either of the two PRs is merged, I'll rebase the other one. The functionality should not conflict, both commands have their usefulness IMO, even if there is overlap in some of the command arguments.

@Roasbeef Roasbeef requested a review from aakselrod May 1, 2018
@guggero guggero force-pushed the guggero:new-macaroon branch 6 times, most recently from 898a08e to de4c7ca May 2, 2018
@guggero guggero force-pushed the guggero:new-macaroon branch 3 times, most recently from 4e4cca6 to 0cd3c8a May 10, 2018
@guggero guggero force-pushed the guggero:new-macaroon branch 2 times, most recently from 140edb9 to 2d79147 May 18, 2018
@guggero guggero force-pushed the guggero:new-macaroon branch 2 times, most recently from 5c0a41f to 798db9c May 26, 2018
@guggero guggero force-pushed the guggero:new-macaroon branch 3 times, most recently from f829b7e to b04419a Jun 2, 2018
@guggero guggero force-pushed the guggero:new-macaroon branch 2 times, most recently from 850f64b to 6fbc5b7 Jun 13, 2018
@guggero guggero force-pushed the guggero:new-macaroon branch 2 times, most recently from ca7c476 to e17108b Jun 27, 2018
@guggero guggero force-pushed the guggero:new-macaroon branch from e17108b to d7725ca Jul 10, 2018
@guggero guggero removed this from Needs review in High Priority Oct 23, 2019
@guggero guggero removed this from Needs review in Macaroon Evolution Oct 23, 2019
@guggero guggero force-pushed the guggero:new-macaroon branch from 159aec6 to e4a50fb Oct 23, 2019
@guggero guggero requested a review from joostjager Oct 23, 2019
rpcserver.go Outdated Show resolved Hide resolved
rpcserver.go Outdated Show resolved Hide resolved
rpcserver.go Outdated Show resolved Hide resolved
rpcserver.go Show resolved Hide resolved
cmd/lncli/cmd_new_macaroon.go Outdated Show resolved Hide resolved
@guggero guggero force-pushed the guggero:new-macaroon branch from e4a50fb to 4dd93fd Oct 23, 2019
@guggero guggero requested a review from joostjager Oct 23, 2019
rpcserver.go Outdated Show resolved Hide resolved
cmd/lncli/cmd_new_macaroon.go Outdated Show resolved Hide resolved
cmd/lncli/cmd_new_macaroon.go Outdated Show resolved Hide resolved
@guggero guggero force-pushed the guggero:new-macaroon branch from 4dd93fd to f38b6cd Oct 23, 2019
Copy link
Collaborator

wpaulino left a comment

LGTM 💥

I think another nice follow-up would be to allow lncli to use a custom macaroon through a flag as hex to prevent having to save it to a file.

cmd/lncli/cmd_new_macaroon.go Outdated Show resolved Hide resolved
rpcserver.go Show resolved Hide resolved
@guggero guggero force-pushed the guggero:new-macaroon branch from f38b6cd to f96ebc8 Oct 24, 2019
@guggero

This comment has been minimized.

Copy link
Collaborator Author

guggero commented Oct 24, 2019

@Roasbeef asked me to rename the service to BakeMacaroon.

@guggero guggero requested review from wpaulino and joostjager Oct 24, 2019
@guggero guggero force-pushed the guggero:new-macaroon branch from f96ebc8 to dac1d2a Oct 24, 2019
rpcserver.go Outdated Show resolved Hide resolved
guggero added 2 commits Oct 23, 2019
@guggero guggero force-pushed the guggero:new-macaroon branch from dac1d2a to 1270a8e Oct 24, 2019
v0.9.0-beta automation moved this from Needs Review to Approved Oct 24, 2019
@Roasbeef Roasbeef merged commit b110a3a into lightningnetwork:master Oct 25, 2019
1 of 2 checks passed
1 of 2 checks passed
coverage/coveralls Coverage decreased (-0.08%) to 62.914%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
v0.9.0-beta automation moved this from Approved to Done Oct 25, 2019
@guggero guggero deleted the guggero:new-macaroon branch Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v0.9.0-beta
  
Done
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.