mirror of
https://github.com/corda/corda.git
synced 2025-03-25 13:27:58 +00:00
WebServer init failure on config produced by plugins >= 4.0.2 [CORDA-877] (#2624)
This commit is contained in:
parent
5be0e4b39e
commit
fd491d91ff
@ -5,6 +5,7 @@ import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.nodeapi.internal.config.NodeSSLConfiguration
|
||||
import net.corda.nodeapi.internal.config.User
|
||||
import net.corda.nodeapi.internal.config.getValue
|
||||
import net.corda.nodeapi.internal.config.parseAs
|
||||
import java.nio.file.Path
|
||||
|
||||
/**
|
||||
@ -25,5 +26,16 @@ class WebServerConfig(override val baseDirectory: Path, val config: Config) : No
|
||||
throw Exception("Missing rpc address property. Either 'rpcSettings' or 'rpcAddress' must be specified.")
|
||||
}
|
||||
val webAddress: NetworkHostAndPort by config
|
||||
val rpcUsers: List<User> by config
|
||||
val runAs: User
|
||||
|
||||
init {
|
||||
// TODO: replace with credentials supplied by a user
|
||||
val users = if (config.hasPath("rpcUsers")) {
|
||||
// TODO: remove this once config format is updated
|
||||
config.getConfigList("rpcUsers")
|
||||
} else {
|
||||
config.getConfigList("security.authService.dataSource.users")
|
||||
}
|
||||
runAs = users.first().parseAs<User>()
|
||||
}
|
||||
}
|
||||
|
@ -189,10 +189,9 @@ class NodeWebServer(val config: WebServerConfig) {
|
||||
}
|
||||
|
||||
private fun connectLocalRpcAsNodeUser(): CordaRPCOps {
|
||||
val rpcUser = config.rpcUsers.firstOrNull() ?: throw IllegalArgumentException("The node config has not specified any RPC users")
|
||||
log.info("Connecting to node at ${config.rpcAddress} as $rpcUser")
|
||||
log.info("Connecting to node at ${config.rpcAddress} as ${config.runAs}")
|
||||
val client = CordaRPCClient(config.rpcAddress)
|
||||
val connection = client.start(rpcUser.username, rpcUser.password)
|
||||
val connection = client.start(config.runAs.username, config.runAs.password)
|
||||
return connection.proxy
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user