Hyperledger Composer BusinessNetwork 连接 - 0.14.3 无法连接
Hyperledger Composer BusinessNetwork Connection - 0.14.3 cannot connect
我正在尝试使用 BusinessNetworkConnection for NodeJS,但如何从 playground 上部署的 BNA 获取凭据并将其保存在我的服务器目录中?
我得到
2017-11-03T13:07:32.83-0400 [APP/PROC/WEB/0] ERR (node:62)
UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 1): Error: Error trying login and get user Context.
Error: Error trying to enroll user or load channel configuration.
Error: Enrollment failed with errors
[[{"code":400,"message":"Authorization failure"}]]
当我尝试使用代码时
const BusinessNetworkConnection = require("composer-client").BusinessNetworkConnection;
this.businessNetworkConnection = new BusinessNetworkConnection();
this.CONNECTION_PROFILE_NAME = "ibm-bc-org1";
this.businessNetworkIdentifier = "giveback";
this.businessNetworkConnection
.connect(
this.CONNECTION_PROFILE_NAME,
this.businessNetworkIdentifier,
"admin",
"adminpw"
)
.then(result => {
this.businessNetworkDefinition = result;
console.log("BusinessNetworkConnection: ", result);
})
我有一个目录 /home/vcap/app/.composer-connection-profiles/ibm-bc-org1
,其中有一个 connection.json
文件引用 /home/vcap/app/.composer-credentials/ibm-bc-org1
作为我的凭据。该代码适用于 composer@0.13.2
,但现在我转到了 composer@0.14.3
。我删除了以前的凭据并创建了一个新的游乐场等,一切都是新鲜干净的。
当发生这种情况时,有一种解决方法。因为我正在尝试连接 Composer 使用 admin || adminpw
创建的凭据。您只需在模型文件中定义一个新参与者,然后授予该参与者系统权限以查询和侦听 Historian
发出的事件。
例如在你的 model.cto
:
participant ServerAdmin identified by serverhash {
// ServerAdmin is a type of participant
o String serverhash
}
并在您的 permissions.acl
中添加:
rule ServerAdminUser {
description: "Grant business network administrators full access to
user resources"
participant: "org.acme.sample.ServerAdmin"
operation: ALL
resource: "**"
action: ALLOW
}
rule ServerAdminSystem {
description: "Grant business network administrators full access to system resources"
participant: "org.acme.sample.ServerAdmin"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
然后在 Composer 在 playground 上部署网络后,您可以通过 REST 添加此参与者 API,并为其颁发新身份。这将为您提供 User ID
和 User Secret
,您可以在 BusinessNetworkConnection.connect()
中使用它们
我正在尝试使用 BusinessNetworkConnection for NodeJS,但如何从 playground 上部署的 BNA 获取凭据并将其保存在我的服务器目录中?
我得到
2017-11-03T13:07:32.83-0400 [APP/PROC/WEB/0] ERR (node:62)
UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 1): Error: Error trying login and get user Context.
Error: Error trying to enroll user or load channel configuration.
Error: Enrollment failed with errors
[[{"code":400,"message":"Authorization failure"}]]
当我尝试使用代码时
const BusinessNetworkConnection = require("composer-client").BusinessNetworkConnection;
this.businessNetworkConnection = new BusinessNetworkConnection();
this.CONNECTION_PROFILE_NAME = "ibm-bc-org1";
this.businessNetworkIdentifier = "giveback";
this.businessNetworkConnection
.connect(
this.CONNECTION_PROFILE_NAME,
this.businessNetworkIdentifier,
"admin",
"adminpw"
)
.then(result => {
this.businessNetworkDefinition = result;
console.log("BusinessNetworkConnection: ", result);
})
我有一个目录 /home/vcap/app/.composer-connection-profiles/ibm-bc-org1
,其中有一个 connection.json
文件引用 /home/vcap/app/.composer-credentials/ibm-bc-org1
作为我的凭据。该代码适用于 composer@0.13.2
,但现在我转到了 composer@0.14.3
。我删除了以前的凭据并创建了一个新的游乐场等,一切都是新鲜干净的。
当发生这种情况时,有一种解决方法。因为我正在尝试连接 Composer 使用 admin || adminpw
创建的凭据。您只需在模型文件中定义一个新参与者,然后授予该参与者系统权限以查询和侦听 Historian
发出的事件。
例如在你的 model.cto
:
participant ServerAdmin identified by serverhash {
// ServerAdmin is a type of participant
o String serverhash
}
并在您的 permissions.acl
中添加:
rule ServerAdminUser {
description: "Grant business network administrators full access to
user resources"
participant: "org.acme.sample.ServerAdmin"
operation: ALL
resource: "**"
action: ALLOW
}
rule ServerAdminSystem {
description: "Grant business network administrators full access to system resources"
participant: "org.acme.sample.ServerAdmin"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
然后在 Composer 在 playground 上部署网络后,您可以通过 REST 添加此参与者 API,并为其颁发新身份。这将为您提供 User ID
和 User Secret
,您可以在 BusinessNetworkConnection.connect()