mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
macaroons+rpcserver: Add new RPC call for checking macaroon permissions
This commit is contained in:
@@ -161,10 +161,20 @@ func (svc *Service) ValidateMacaroon(ctx context.Context,
|
||||
len(md["macaroon"]))
|
||||
}
|
||||
|
||||
return svc.CheckMacAuth(
|
||||
ctx, md["macaroon"][0], requiredPermissions, fullMethod,
|
||||
)
|
||||
}
|
||||
|
||||
// CheckMacAuth checks that the macaroon is not disobeying any caveats and is
|
||||
// authorized to perform the operation the user wants to perform.
|
||||
func (svc *Service) CheckMacAuth(ctx context.Context, macStr string,
|
||||
requiredPermissions []bakery.Op, fullMethod string) error {
|
||||
|
||||
// With the macaroon obtained, we'll now decode the hex-string
|
||||
// encoding, then unmarshal it from binary into its concrete struct
|
||||
// representation.
|
||||
macBytes, err := hex.DecodeString(md["macaroon"][0])
|
||||
macBytes, err := hex.DecodeString(macStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user