mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-30 02:21:08 +02:00
lnd+rpcserver: allow external subservers to specify macaroon validator
Give the external subservers the possibility to also use their own validator to check any macaroons attached to calls to their registered gRPC URIs. This allows them to have their own root key ID database and permission entities.
This commit is contained in:
21
rpcserver.go
21
rpcserver.go
@ -661,10 +661,12 @@ func newRPCServer(cfg *Config, s *server, macService *macaroons.Service,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// External subserver possibly need to register their own permissions.
|
||||
// External subserver possibly need to register their own permissions
|
||||
// and macaroon validator.
|
||||
for _, lis := range listeners {
|
||||
extSubserver := lis.ExternalRPCSubserverCfg
|
||||
if extSubserver != nil {
|
||||
macValidator := extSubserver.MacaroonValidator
|
||||
for method, ops := range extSubserver.Permissions {
|
||||
// For each new method:ops combo, we also ensure
|
||||
// that non of the sub-servers try to override
|
||||
@ -677,6 +679,23 @@ func newRPCServer(cfg *Config, s *server, macService *macaroons.Service,
|
||||
}
|
||||
|
||||
permissions[method] = ops
|
||||
|
||||
// Give the external subservers the possibility
|
||||
// to also use their own validator to check any
|
||||
// macaroons attached to calls to this method.
|
||||
// This allows them to have their own root key
|
||||
// ID database and permission entities.
|
||||
if macValidator != nil {
|
||||
err := macService.RegisterExternalValidator(
|
||||
method, macValidator,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could "+
|
||||
"not register "+
|
||||
"external macaroon "+
|
||||
"validator: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user