lncli: add command to create new macaroon#1160
Conversation
|
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? |
|
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. |
898a08e to
de4c7ca
Compare
4e4cca6 to
0cd3c8a
Compare
140edb9 to
2d79147
Compare
5c0a41f to
798db9c
Compare
f829b7e to
b04419a
Compare
850f64b to
6fbc5b7
Compare
ca7c476 to
e17108b
Compare
fa64927 to
9290643
Compare
|
During testing I noticed that all of the main macaroons (not just admin.macaroon) need to be removed in order to trigger regeneration. Idk if there is a reason for that. |
There was a problem hiding this comment.
If you'd be following up this PR with more granular macaroon baking on the individual call level, how would that map to bakery.Ops?
There was a problem hiding this comment.
Do you mean being able to create a macaroon for a RPC call that shares permissions with another, but the macaroon is only allowed for the first one?
There was a problem hiding this comment.
My idea for the follow-up PR would be that we would use a constant for the entity (for example "rpc") and the full RPC URL (as seen in rpcserver.go, for example "/lnrpc.Lightning/SendCoins") as the action. This would result in quite large macaroons but would offer most flexibility.
There was a problem hiding this comment.
Have we already heard of a use case where our partitioning is insufficient and this fine granularity is required?
There was a problem hiding this comment.
Not yet. But I can think of multiple use cases for this. For example being able to estimate a fee through lnd but not being able to see the wallet balance.
wpaulino
left a comment
There was a problem hiding this comment.
During testing I noticed that all of the main macaroons (not just admin.macaroon) need to be removed in order to trigger regeneration. Idk if there is a reason for that.
Don't know why either, it should regenerate any that don't already exist. See
Line 360 in 254de64
Great work @guggero! I know many users have requested this feature in the past, so it's nice to finally be able to push this forward.
There was a problem hiding this comment.
Do you mean being able to create a macaroon for a RPC call that shares permissions with another, but the macaroon is only allowed for the first one?
|
Thank you @joostjager and @wpaulino for the reviews! Will introduce a RPC call to get all supported permissions in the follow-up PR that also introduces fine-grained permissions on individual RPC method level. |
wpaulino
left a comment
There was a problem hiding this 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.
|
@Roasbeef asked me to rename the service to |
As discussed in #1147 there is a need to create macaroons with custom permissions set since the three existing macaroon files
admin.macaroon,invoice.macaroonandreadonly.macaroonaren't fine-grained enough.A new gRPC method named
NewMacaroonis added:macaroon(could be used for macaroon based RPCs mentioned in Add support for accounting-based macaroons #291 too).writeaccess to the entity macaroon is necessary to call the method NewMacaroon.admin.macaroongetswriteaccess to the entitymacaroon.newmacaroonthat calls this gRPC method.NewMacaroonmethod 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=10Creates 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.macaroonandinvoices.macaroonbefore starting0.9, otherwise they won't get regenerated macaroons that have the required permission (macaroon:generate) to mint custom macaroons.