Node-Red:通过 Admin HTTP API 部署流程,在节点属性中包含凭据
Node-Red: Deploy flow via Admin HTTP API containing credentials in nodes properties
我尝试通过 Admin HTTP API containing credentials in nodes properties. In my case it's a node of type mqtt-broker 部署流程。安全选项卡包含一个 属性 user
,我试图将其放入 API 调用中。
这个属性存储在flows_<hostname>_cred.json
中。喜欢 stated this file could be encrypted。在我的例子中 settings.js
它设置为 credentialSecret: false
.
是否可以在 Admin HTTP API 中传递存储在 flows_<hostname>_cred.json
中的值?或者是唯一在本地替换文件的方法?
编辑
我发送给https://127.0.0.1:1880/flows
的测试流程,returnsHTTP代码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": ""
}
]
如果我在 e8482c08.9858f
中添加 "user": "TEST"
,这对我不起作用。
您不直接将数据传递给 creds 文件,这是由运行时为您处理的。
您需要将 creds 属性添加到流程中的匹配节点,然后 post 到管理员 api。然后它们将被剥离、加密并添加到 creds 文件中。
因此,对于 mqtt-broker 配置节点,您将在名为 credentials 的字段中添加 user
和 password
字段。如文档中所述 https://nodered.org/docs/creating-nodes/credentials
我尝试通过 Admin HTTP API containing credentials in nodes properties. In my case it's a node of type mqtt-broker 部署流程。安全选项卡包含一个 属性 user
,我试图将其放入 API 调用中。
这个属性存储在flows_<hostname>_cred.json
中。喜欢settings.js
它设置为 credentialSecret: false
.
是否可以在 Admin HTTP API 中传递存储在 flows_<hostname>_cred.json
中的值?或者是唯一在本地替换文件的方法?
编辑
我发送给https://127.0.0.1:1880/flows
的测试流程,returnsHTTP代码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": ""
}
]
如果我在 e8482c08.9858f
中添加 "user": "TEST"
,这对我不起作用。
您不直接将数据传递给 creds 文件,这是由运行时为您处理的。
您需要将 creds 属性添加到流程中的匹配节点,然后 post 到管理员 api。然后它们将被剥离、加密并添加到 creds 文件中。
因此,对于 mqtt-broker 配置节点,您将在名为 credentials 的字段中添加 user
和 password
字段。如文档中所述 https://nodered.org/docs/creating-nodes/credentials