我尝试通过Admin HTTP API部署包含节点属性中凭据的流。在我的情况下,它是类型为mqtt-broker的节点。安全标签包含一个属性user
,我尝试将其放入API调用中。
此属性存储在flows_<hostname>_cred.json
中。就像this post所说的那样,该文件可能是encrypted。在我的案例中,settings.js
设置为credentialSecret: false
。
是否可以在Admin HTTP API中传递存储在flows_<hostname>_cred.json
中的值?还是在本地替换文件的唯一方法?
修改
我发送到https://127.0.0.1:1880/flows
的测试流返回HTTP代码204。
[
{
"id": "f71b8c17.05ad3",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "baa95a0d.e490e",
"type": "mqtt in",
"z": "f71b8c17.05ad3",
"name": "",
"topic": "",
"qos": "2",
"datatype": "auto",
"broker": "e8482c08.9858f",
"x": 120,
"y": 180,
"wires": [
[
"bd237434.8030a"
]
]
},
{
"id": "bd237434.8030a",
"type": "debug",
"z": "f71b8c17.05ad3",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 320,
"y": 180,
"wires": []
},
{
"id": "e8482c08.9858f",
"type": "mqtt-broker",
"z": "",
"name": "test",
"broker": "test",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
如果我在"user": "TEST"
中添加e8482c08.9858f
,这对我不起作用。
答案 0 :(得分:0)
您不会直接将数据传递到creds文件,运行时会为您处理。
您需要将creds属性添加到流程中的匹配节点,然后发布到admin api。然后将它们剥离,加密并添加到creds文件中。
因此,对于mqtt-broker配置节点,您可以在名为凭据的字段中添加user
和password
字段。如此处https://nodered.org/docs/creating-nodes/credentials