mirror of
https://github.com/corda/corda.git
synced 2025-06-19 23:53:52 +00:00
WebServer init failure on config produced by plugins >= 4.0.2 [CORDA-877] (#2624)
This commit is contained in:
@ -5,6 +5,7 @@ import net.corda.core.utilities.NetworkHostAndPort
|
|||||||
import net.corda.nodeapi.internal.config.NodeSSLConfiguration
|
import net.corda.nodeapi.internal.config.NodeSSLConfiguration
|
||||||
import net.corda.nodeapi.internal.config.User
|
import net.corda.nodeapi.internal.config.User
|
||||||
import net.corda.nodeapi.internal.config.getValue
|
import net.corda.nodeapi.internal.config.getValue
|
||||||
|
import net.corda.nodeapi.internal.config.parseAs
|
||||||
import java.nio.file.Path
|
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.")
|
throw Exception("Missing rpc address property. Either 'rpcSettings' or 'rpcAddress' must be specified.")
|
||||||
}
|
}
|
||||||
val webAddress: NetworkHostAndPort by config
|
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 {
|
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 ${config.runAs}")
|
||||||
log.info("Connecting to node at ${config.rpcAddress} as $rpcUser")
|
|
||||||
val client = CordaRPCClient(config.rpcAddress)
|
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
|
return connection.proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user