-->

How can I configure security per node in Corda usi

2020-08-05 10:05发布

问题:

I want to add the security property to my node configuration using Gradle. I'm trying to do something like the below:

node {
name "O=Bank_A,L=New York,C=US"
p2pPort 10005
rpcSettings {
address("localhost:10006")
adminAddress("localhost:10046")
}
h2Port 9005
cordapps = [
"$project.group:bank-abc:$project.version",
"$project.group:shared-contracts-states:$project.version",
"$corda_release_group:corda-finance:$corda_release_version"
]

security = {
   authService = {
      dataSource = {
         type = "DB"
         passwordEncryption = "SHIRO_1_CRYPT"
         connection = {
             jdbcUrl = "jdbc:h2:tcp://10.0.75.1:9014/node"
             username = "some user"
             password = "some pass"
             driverClassName = "org.h2.Driver"
             }
          }
       }
    }
}

when I execute gradlew deployNodes. I get the below error:

  • What went wrong:

A problem occurred evaluating root project 'tbs-term-reciprocal-dapp'.

Could not set unknown property 'security' for object of type net.corda.plugins.Node.

回答1:

In order to add security config, you need to use extraConfig within your node's Gradle script.

Taking your example, the extraConfig will look like this:

extraConfig = [
    security : [
        authService : [
            dataSource : [
                type: "DB",
                passwordEncryption: "SHIRO_1_CRYPT",
                connection : [
                    jdbcUrl: "jdbc:h2:tcp://10.0.75.1:9014/node",
                    username: "sa",
                    password: "",
                    driverClassName: "org.h2.Driver"
                ]
            ]
        ]
    ]
]


标签: corda