mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopd: move RequiredPermissions to dedicated dir
This commit moves the RequiredPermissions map to its own directory so that projects importing the permissions list dont need to import all the dependencies of the loopd package.
This commit is contained in:
parent
5b5dfc0f5e
commit
8ccd35e0c1
3 changed files with 88 additions and 87 deletions
|
|
@ -15,6 +15,7 @@ import (
|
||||||
proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||||
"github.com/lightninglabs/lndclient"
|
"github.com/lightninglabs/lndclient"
|
||||||
"github.com/lightninglabs/loop"
|
"github.com/lightninglabs/loop"
|
||||||
|
"github.com/lightninglabs/loop/loopd/perms"
|
||||||
"github.com/lightninglabs/loop/loopdb"
|
"github.com/lightninglabs/loop/loopdb"
|
||||||
"github.com/lightninglabs/loop/looprpc"
|
"github.com/lightninglabs/loop/looprpc"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
|
|
@ -379,7 +380,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
|
||||||
// Add our debug permissions to our main set of required permissions
|
// Add our debug permissions to our main set of required permissions
|
||||||
// if compiled in.
|
// if compiled in.
|
||||||
for endpoint, perm := range debugRequiredPermissions {
|
for endpoint, perm := range debugRequiredPermissions {
|
||||||
RequiredPermissions[endpoint] = perm
|
perms.RequiredPermissions[endpoint] = perm
|
||||||
}
|
}
|
||||||
|
|
||||||
if withMacaroonService {
|
if withMacaroonService {
|
||||||
|
|
@ -395,7 +396,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
|
||||||
Checkers: []macaroons.Checker{
|
Checkers: []macaroons.Checker{
|
||||||
macaroons.IPLockChecker,
|
macaroons.IPLockChecker,
|
||||||
},
|
},
|
||||||
RequiredPerms: RequiredPermissions,
|
RequiredPerms: perms.RequiredPermissions,
|
||||||
DBPassword: macDbDefaultPw,
|
DBPassword: macDbDefaultPw,
|
||||||
LndClient: &d.lnd.LndServices,
|
LndClient: &d.lnd.LndServices,
|
||||||
EphemeralKey: lndclient.SharedKeyNUMS,
|
EphemeralKey: lndclient.SharedKeyNUMS,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
package loopd
|
package loopd
|
||||||
|
|
||||||
import (
|
|
||||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// loopMacaroonLocation is the value we use for the loopd macaroons'
|
// loopMacaroonLocation is the value we use for the loopd macaroons'
|
||||||
// "Location" field when baking them.
|
// "Location" field when baking them.
|
||||||
|
|
@ -11,87 +7,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// RequiredPermissions is a map of all loop RPC methods and their
|
|
||||||
// required macaroon permissions to access loopd.
|
|
||||||
RequiredPermissions = map[string][]bakery.Op{
|
|
||||||
"/looprpc.SwapClient/LoopOut": {{
|
|
||||||
Entity: "swap",
|
|
||||||
Action: "execute",
|
|
||||||
}, {
|
|
||||||
Entity: "loop",
|
|
||||||
Action: "out",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/LoopIn": {{
|
|
||||||
Entity: "swap",
|
|
||||||
Action: "execute",
|
|
||||||
}, {
|
|
||||||
Entity: "loop",
|
|
||||||
Action: "in",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/Monitor": {{
|
|
||||||
Entity: "swap",
|
|
||||||
Action: "read",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/ListSwaps": {{
|
|
||||||
Entity: "swap",
|
|
||||||
Action: "read",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/SwapInfo": {{
|
|
||||||
Entity: "swap",
|
|
||||||
Action: "read",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/LoopOutTerms": {{
|
|
||||||
Entity: "terms",
|
|
||||||
Action: "read",
|
|
||||||
}, {
|
|
||||||
Entity: "loop",
|
|
||||||
Action: "out",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/LoopOutQuote": {{
|
|
||||||
Entity: "swap",
|
|
||||||
Action: "read",
|
|
||||||
}, {
|
|
||||||
Entity: "loop",
|
|
||||||
Action: "out",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/GetLoopInTerms": {{
|
|
||||||
Entity: "terms",
|
|
||||||
Action: "read",
|
|
||||||
}, {
|
|
||||||
Entity: "loop",
|
|
||||||
Action: "in",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/GetLoopInQuote": {{
|
|
||||||
Entity: "swap",
|
|
||||||
Action: "read",
|
|
||||||
}, {
|
|
||||||
Entity: "loop",
|
|
||||||
Action: "in",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/GetLsatTokens": {{
|
|
||||||
Entity: "auth",
|
|
||||||
Action: "read",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/SuggestSwaps": {{
|
|
||||||
Entity: "suggestions",
|
|
||||||
Action: "read",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/GetLiquidityParams": {{
|
|
||||||
Entity: "suggestions",
|
|
||||||
Action: "read",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/SetLiquidityParams": {{
|
|
||||||
Entity: "suggestions",
|
|
||||||
Action: "write",
|
|
||||||
}},
|
|
||||||
"/looprpc.SwapClient/Probe": {{
|
|
||||||
Entity: "swap",
|
|
||||||
Action: "execute",
|
|
||||||
}, {
|
|
||||||
Entity: "loop",
|
|
||||||
Action: "in",
|
|
||||||
}},
|
|
||||||
}
|
|
||||||
|
|
||||||
// macDbDefaultPw is the default encryption password used to encrypt the
|
// macDbDefaultPw is the default encryption password used to encrypt the
|
||||||
// loop macaroon database. The macaroon service requires us to set a
|
// loop macaroon database. The macaroon service requires us to set a
|
||||||
|
|
|
||||||
85
loopd/perms/perms.go
Normal file
85
loopd/perms/perms.go
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
package perms
|
||||||
|
|
||||||
|
import "gopkg.in/macaroon-bakery.v2/bakery"
|
||||||
|
|
||||||
|
// RequiredPermissions is a map of all loop RPC methods and their
|
||||||
|
// required macaroon permissions to access loopd.
|
||||||
|
var RequiredPermissions = map[string][]bakery.Op{
|
||||||
|
"/looprpc.SwapClient/LoopOut": {{
|
||||||
|
Entity: "swap",
|
||||||
|
Action: "execute",
|
||||||
|
}, {
|
||||||
|
Entity: "loop",
|
||||||
|
Action: "out",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/LoopIn": {{
|
||||||
|
Entity: "swap",
|
||||||
|
Action: "execute",
|
||||||
|
}, {
|
||||||
|
Entity: "loop",
|
||||||
|
Action: "in",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/Monitor": {{
|
||||||
|
Entity: "swap",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/ListSwaps": {{
|
||||||
|
Entity: "swap",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/SwapInfo": {{
|
||||||
|
Entity: "swap",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/LoopOutTerms": {{
|
||||||
|
Entity: "terms",
|
||||||
|
Action: "read",
|
||||||
|
}, {
|
||||||
|
Entity: "loop",
|
||||||
|
Action: "out",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/LoopOutQuote": {{
|
||||||
|
Entity: "swap",
|
||||||
|
Action: "read",
|
||||||
|
}, {
|
||||||
|
Entity: "loop",
|
||||||
|
Action: "out",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/GetLoopInTerms": {{
|
||||||
|
Entity: "terms",
|
||||||
|
Action: "read",
|
||||||
|
}, {
|
||||||
|
Entity: "loop",
|
||||||
|
Action: "in",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/GetLoopInQuote": {{
|
||||||
|
Entity: "swap",
|
||||||
|
Action: "read",
|
||||||
|
}, {
|
||||||
|
Entity: "loop",
|
||||||
|
Action: "in",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/GetLsatTokens": {{
|
||||||
|
Entity: "auth",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/SuggestSwaps": {{
|
||||||
|
Entity: "suggestions",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/GetLiquidityParams": {{
|
||||||
|
Entity: "suggestions",
|
||||||
|
Action: "read",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/SetLiquidityParams": {{
|
||||||
|
Entity: "suggestions",
|
||||||
|
Action: "write",
|
||||||
|
}},
|
||||||
|
"/looprpc.SwapClient/Probe": {{
|
||||||
|
Entity: "swap",
|
||||||
|
Action: "execute",
|
||||||
|
}, {
|
||||||
|
Entity: "loop",
|
||||||
|
Action: "in",
|
||||||
|
}},
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue