mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-18 05:42:09 +01:00
lncli: ip range caveat for macaroons
This commit is contained in:
parent
26a4562263
commit
1681be6d65
@ -30,6 +30,10 @@ var (
|
|||||||
Name: "ip_address",
|
Name: "ip_address",
|
||||||
Usage: "the IP address the macaroon will be bound to",
|
Usage: "the IP address the macaroon will be bound to",
|
||||||
}
|
}
|
||||||
|
macIPRangeFlag = cli.StringFlag{
|
||||||
|
Name: "ip_range",
|
||||||
|
Usage: "the IP range the macaroon will be bound to",
|
||||||
|
}
|
||||||
macCustomCaveatNameFlag = cli.StringFlag{
|
macCustomCaveatNameFlag = cli.StringFlag{
|
||||||
Name: "custom_caveat_name",
|
Name: "custom_caveat_name",
|
||||||
Usage: "the name of the custom caveat to add",
|
Usage: "the name of the custom caveat to add",
|
||||||
@ -557,6 +561,19 @@ func applyMacaroonConstraints(ctx *cli.Context,
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.IsSet(macIPRangeFlag.Name) {
|
||||||
|
_, net, err := net.ParseCIDR(ctx.String(macIPRangeFlag.Name))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to parse ip_range "+
|
||||||
|
"%s: %w", ctx.String("ip_range"), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
macConstraints = append(
|
||||||
|
macConstraints,
|
||||||
|
macaroons.IPLockConstraint(net.String()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.IsSet(macCustomCaveatNameFlag.Name) {
|
if ctx.IsSet(macCustomCaveatNameFlag.Name) {
|
||||||
customCaveatName := ctx.String(macCustomCaveatNameFlag.Name)
|
customCaveatName := ctx.String(macCustomCaveatNameFlag.Name)
|
||||||
if containsWhiteSpace(customCaveatName) {
|
if containsWhiteSpace(customCaveatName) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user