mirror of
https://github.com/corda/corda.git
synced 2025-01-03 03:36:48 +00:00
Stop granting NODE_USER full RPC permissions (#2098)
This commit is contained in:
parent
92efd82fab
commit
991c59e753
@ -239,8 +239,6 @@ class ArtemisMessagingServer(private val config: NodeConfiguration,
|
|||||||
securityRoles["$INTERNAL_PREFIX#"] = setOf(nodeInternalRole) // Do not add any other roles here as it's only for the node
|
securityRoles["$INTERNAL_PREFIX#"] = setOf(nodeInternalRole) // Do not add any other roles here as it's only for the node
|
||||||
securityRoles[P2P_QUEUE] = setOf(nodeInternalRole, restrictedRole(PEER_ROLE, send = true))
|
securityRoles[P2P_QUEUE] = setOf(nodeInternalRole, restrictedRole(PEER_ROLE, send = true))
|
||||||
securityRoles[RPCApi.RPC_SERVER_QUEUE_NAME] = setOf(nodeInternalRole, restrictedRole(RPC_ROLE, send = true))
|
securityRoles[RPCApi.RPC_SERVER_QUEUE_NAME] = setOf(nodeInternalRole, restrictedRole(RPC_ROLE, send = true))
|
||||||
// TODO: remove the NODE_USER role below once the webserver doesn't need it anymore.
|
|
||||||
securityRoles["${RPCApi.RPC_CLIENT_QUEUE_NAME_PREFIX}.$NODE_USER.#"] = setOf(nodeInternalRole)
|
|
||||||
// Each RPC user must have its own role and its own queue. This prevents users accessing each other's queues
|
// Each RPC user must have its own role and its own queue. This prevents users accessing each other's queues
|
||||||
// and stealing RPC responses.
|
// and stealing RPC responses.
|
||||||
val rolesAdderOnLogin = RolesAdderOnLogin { username ->
|
val rolesAdderOnLogin = RolesAdderOnLogin { username ->
|
||||||
|
@ -357,9 +357,6 @@ class RPCServer(
|
|||||||
observableMap.cleanUp()
|
observableMap.cleanUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove this User once webserver doesn't need it
|
|
||||||
private val nodeUser = User(NODE_USER, NODE_USER, setOf())
|
|
||||||
|
|
||||||
private fun ClientMessage.context(sessionId: Trace.SessionId): RpcAuthContext {
|
private fun ClientMessage.context(sessionId: Trace.SessionId): RpcAuthContext {
|
||||||
val trace = Trace.newInstance(sessionId = sessionId)
|
val trace = Trace.newInstance(sessionId = sessionId)
|
||||||
val externalTrace = externalTrace()
|
val externalTrace = externalTrace()
|
||||||
@ -372,15 +369,11 @@ class RPCServer(
|
|||||||
val validatedUser = message.getStringProperty(Message.HDR_VALIDATED_USER) ?: throw IllegalArgumentException("Missing validated user from the Artemis message")
|
val validatedUser = message.getStringProperty(Message.HDR_VALIDATED_USER) ?: throw IllegalArgumentException("Missing validated user from the Artemis message")
|
||||||
val targetLegalIdentity = message.getStringProperty(RPCApi.RPC_TARGET_LEGAL_IDENTITY)?.let(CordaX500Name.Companion::parse) ?: nodeLegalName
|
val targetLegalIdentity = message.getStringProperty(RPCApi.RPC_TARGET_LEGAL_IDENTITY)?.let(CordaX500Name.Companion::parse) ?: nodeLegalName
|
||||||
// TODO switch userService based on targetLegalIdentity
|
// TODO switch userService based on targetLegalIdentity
|
||||||
val rpcUser = userService.getUser(validatedUser)
|
val rpcUser = userService.getUser(validatedUser) ?:
|
||||||
return if (rpcUser != null) {
|
throw IllegalArgumentException("Validated user '$validatedUser' is not an RPC user")
|
||||||
Actor(Id(rpcUser.username), userService.id, targetLegalIdentity) to RpcPermissions(rpcUser.permissions)
|
return Pair(
|
||||||
} else if (CordaX500Name.parse(validatedUser) == nodeLegalName) {
|
Actor(Id(rpcUser.username), userService.id, targetLegalIdentity),
|
||||||
// TODO remove this after Shell and WebServer will no longer need it
|
RpcPermissions(rpcUser.permissions))
|
||||||
Actor(Id(nodeUser.username), userService.id, targetLegalIdentity) to RpcPermissions(nodeUser.permissions)
|
|
||||||
} else {
|
|
||||||
throw IllegalArgumentException("Validated user '$validatedUser' is not an RPC user nor the NODE user")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user