Skip to content

Commit 4c81a92

Browse files
committed
lnrpc+rpcserver: improve docs for CheckMacaroonPermissions
Fixes #10026.
1 parent b5c84ea commit 4c81a92

File tree

5 files changed

+55
-16
lines changed

5 files changed

+55
-16
lines changed

lnrpc/lightning.pb.go

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/lightning.proto

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,10 @@ service Lightning {
548548
returns (ListPermissionsResponse);
549549

550550
/*
551-
CheckMacaroonPermissions checks whether a request follows the constraints
552-
imposed on the macaroon and that the macaroon is authorized to follow the
553-
provided permissions.
551+
CheckMacaroonPermissions checks whether the provided macaroon contains all
552+
the provided permissions. If the macaroon is valid (e.g. all caveats are
553+
satisfied), and all permissions provided in the request are met, then
554+
this RPC returns true.
554555
*/
555556
rpc CheckMacaroonPermissions (CheckMacPermRequest)
556557
returns (CheckMacPermResponse);
@@ -5099,8 +5100,24 @@ message Op {
50995100
}
51005101

51015102
message CheckMacPermRequest {
5103+
// The macaroon to check permissions for, serialized in binary format. For
5104+
// a macaroon to be valid, it must have been issued by lnd, must succeed all
5105+
// caveat conditions, and must contain all of the permissions specified in
5106+
// the permissions field.
51025107
bytes macaroon = 1;
5108+
5109+
// The list of permissions the macaroon should be checked against. Only if
5110+
// the macaroon contains all of these permissions, it is considered valid.
5111+
// If the list of permissions given is empty, then the macaroon is
5112+
// considered valid only based on issuance authority and caveat validity.
51035113
repeated MacaroonPermission permissions = 2;
5114+
5115+
// The RPC method to check the macaroon against. This is only used if there
5116+
// are custom `uri:<rpcpackage>.<ServiceName>/<MethodName>` permissions in
5117+
// the permission list above. To check a macaroon against the list of
5118+
// permissions of a certain RPC method, query the `ListPermissions` RPC
5119+
// first, extract the permissions for the method, and then pass them in the
5120+
// `permissions` field above.
51045121
string fullMethod = 3;
51055122
}
51065123

lnrpc/lightning.swagger.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@
19711971
},
19721972
"/v1/macaroon/checkpermissions": {
19731973
"post": {
1974-
"summary": "CheckMacaroonPermissions checks whether a request follows the constraints\nimposed on the macaroon and that the macaroon is authorized to follow the\nprovided permissions.",
1974+
"summary": "CheckMacaroonPermissions checks whether the provided macaroon contains all\nthe provided permissions. If the macaroon is valid (e.g. all caveats are\nsatisfied), and all permissions provided in the request are met, then\nthis RPC returns true.",
19751975
"operationId": "Lightning_CheckMacaroonPermissions",
19761976
"responses": {
19771977
"200": {
@@ -4643,17 +4643,20 @@
46434643
"properties": {
46444644
"macaroon": {
46454645
"type": "string",
4646-
"format": "byte"
4646+
"format": "byte",
4647+
"description": "The macaroon to check permissions for, serialized in binary format. For\na macaroon to be valid, it must have been issued by lnd, must succeed all\ncaveat conditions, and must contain all of the permissions specified in\nthe permissions field."
46474648
},
46484649
"permissions": {
46494650
"type": "array",
46504651
"items": {
46514652
"type": "object",
46524653
"$ref": "#/definitions/lnrpcMacaroonPermission"
4653-
}
4654+
},
4655+
"description": "The list of permissions the macaroon should be checked against. Only if\nthe macaroon contains all of these permissions, it is considered valid.\nIf the list of permissions given is empty, then the macaroon is\nconsidered valid only based on issuance authority and caveat validity."
46544656
},
46554657
"fullMethod": {
4656-
"type": "string"
4658+
"type": "string",
4659+
"description": "The RPC method to check the macaroon against. This is only used if there\nare custom `uri:\u003crpcpackage\u003e.\u003cServiceName\u003e/\u003cMethodName\u003e` permissions in\nthe permission list above. To check a macaroon against the list of\npermissions of a certain RPC method, query the `ListPermissions` RPC\nfirst, extract the permissions for the method, and then pass them in the\n`permissions` field above."
46574660
}
46584661
}
46594662
},

lnrpc/lightning_grpc.pb.go

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpcserver.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8726,7 +8726,10 @@ func (r *rpcServer) ListPermissions(_ context.Context,
87268726
}, nil
87278727
}
87288728

8729-
// CheckMacaroonPermissions checks the caveats and permissions of a macaroon.
8729+
// CheckMacaroonPermissions checks whether the provided macaroon contains all
8730+
// the provided permissions. If the macaroon is valid (e.g. all caveats are
8731+
// satisfied), and all permissions provided in the request are met, then
8732+
// this RPC returns true.
87308733
func (r *rpcServer) CheckMacaroonPermissions(ctx context.Context,
87318734
req *lnrpc.CheckMacPermRequest) (*lnrpc.CheckMacPermResponse, error) {
87328735

0 commit comments

Comments
 (0)