diff --git a/README.md b/README.md index 0c30109..5b195b2 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ Agent to install on the docker server to manage containers though [netbox plugin ## Settings go to the [nodered admin page](http://localhost:1880/nodered) to change the settings. +you can define username and password via envionment variable: +- API_USERNAME +- API_PASSWORD (NOTE: password should be a hash of node-red admin hash-pw) +- ADMIN_USERNAME +- ADMIN_PASSWORD (NOTE: password should be a hash of node-red admin hash-pw) ## Clean ``` diff --git a/flows.json b/flows.json index 22b07ba..8ec4129 100644 --- a/flows.json +++ b/flows.json @@ -248,7 +248,7 @@ "fieldType": "msg", "format": "handlebars", "syntax": "plain", - "template": "data = require(\"./package.json\")\n\nmodule.exports = {\n credentialSecret: \"saashup\",\n flowFile: \"flows.json\",\n flowFilePretty: true,\n adminAuth: {\n type: \"credentials\",\n users: [{\n username: \"admin\",\n password: \"$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK\",\n permissions: \"*\"\n }]\n },\n /*https: {\n key: require(\"fs\").readFileSync('/data/privkey.pem'),\n cert: require(\"fs\").readFileSync('/data/cert.pem')\n },\n requireHttps: true,*/\n httpNodeAuth: {\n user:\"admin\",pass:\"$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK\"\n },\n uiPort: process.env.PORT || 1880,\n httpStatic: [\n { path: '/usr/src/node-red/public', root: '/' },\n { path: '/usr/src/node-red/public/doc.html', root: '/doc' },\n { path: '/usr/src/node-red/public/openapi.yml', root: '/openapi' }\n ],\n httpAdminRoot: '/nodered',\n diagnostics: {\n enabled: true,\n ui: true,\n },\n runtimeState: {\n enabled: false,\n ui: false,\n },\n logging: {\n console: {\n level: \"info\",\n metrics: false,\n audit: false,\n handler: function(settings) {\n return function(msg) {\n const level = {\n 20: 'error',\n 30: 'warn',\n 40: 'info'\n };\n const lvl = \"level\" in msg ? msg.level : \"40\";\n\n delete msg.type;\n delete msg.z;\n delete msg.path;\n delete msg.name;\n delete msg.id;\n\n let line = `${data.name} level=${level[lvl]} version=${data.version}`;\n\n if (typeof msg.msg === 'object') {\n for (const key of Object.keys(msg.msg)) {\n line += ` ${key}=${JSON.stringify(msg.msg[key])}`;\n }\n } else {\n line += ` msg=` + JSON.stringify(msg.msg);\n }\n\n if (lvl <= 20) {\n return console.error(line);\n }\n\n return console.log(line);\n }\n }\n }\n },\n exportGlobalContextKeys: false,\n externalModules: {\n },\n editorTheme: {\n tours: false,\n palette: {\n },\n projects: {\n enabled: false,\n workflow: {\n mode: \"manual\"\n }\n },\n codeEditor: {\n lib: \"monaco\",\n options: {\n }\n },\n markdownEditor: {\n mermaid: {\n enabled: true\n }\n },\n },\n functionExternalModules: true,\n functionTimeout: 0,\n functionGlobalContext: {\n },\n debugMaxLength: 1000,\n mqttReconnectTime: 15000,\n serialReconnectTime: 15000\n}\n", + "template": "data = require(\"./package.json\")\n\nmodule.exports = {\n credentialSecret: \"saashup\",\n flowFile: \"flows.json\",\n flowFilePretty: true,\n adminAuth: {\n type: \"credentials\",\n users: [{\n username: process.env.ADMIN_USERNAME || \"admin\",\n password: process.env.ADMIN_PASSWORD || \"$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK\",\n permissions: \"*\"\n }]\n },\n /*https: {\n key: require(\"fs\").readFileSync('/data/privkey.pem'),\n cert: require(\"fs\").readFileSync('/data/cert.pem')\n },\n requireHttps: true,*/\n httpNodeAuth: {\n user: process.env.API_USERNAME || \"admin\",\n pass: process.env.API_PASSWORD || \"$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK\"\n },\n uiPort: process.env.PORT || 1880,\n httpStatic: [\n { path: '/usr/src/node-red/public', root: '/' },\n { path: '/usr/src/node-red/public/doc.html', root: '/doc' },\n { path: '/usr/src/node-red/public/openapi.yml', root: '/openapi' }\n ],\n httpAdminRoot: '/nodered',\n diagnostics: {\n enabled: true,\n ui: true,\n },\n runtimeState: {\n enabled: false,\n ui: false,\n },\n logging: {\n console: {\n level: \"info\",\n metrics: false,\n audit: false,\n handler: function(settings) {\n return function(msg) {\n const level = {\n 20: 'error',\n 30: 'warn',\n 40: 'info'\n };\n const lvl = \"level\" in msg ? msg.level : \"40\";\n\n delete msg.type;\n delete msg.z;\n delete msg.path;\n delete msg.name;\n delete msg.id;\n\n let line = `${data.name} level=${level[lvl]} version=${data.version}`;\n\n if (typeof msg.msg === 'object') {\n for (const key of Object.keys(msg.msg)) {\n line += ` ${key}=${JSON.stringify(msg.msg[key])}`;\n }\n } else {\n line += ` msg=` + JSON.stringify(msg.msg);\n }\n\n if (lvl <= 20) {\n return console.error(line);\n }\n\n return console.log(line);\n }\n }\n }\n },\n exportGlobalContextKeys: false,\n externalModules: {\n },\n editorTheme: {\n tours: false,\n palette: {\n },\n projects: {\n enabled: false,\n workflow: {\n mode: \"manual\"\n }\n },\n codeEditor: {\n lib: \"monaco\",\n options: {\n }\n },\n markdownEditor: {\n mermaid: {\n enabled: true\n }\n },\n },\n functionExternalModules: true,\n functionTimeout: 0,\n functionGlobalContext: {\n },\n debugMaxLength: 1000,\n mqttReconnectTime: 15000,\n serialReconnectTime: 15000\n}\n", "output": "str", "x": 460, "y": 420, @@ -5439,4 +5439,4 @@ ] ] } -] \ No newline at end of file +] diff --git a/settings.js b/settings.js index 0bf7373..e45a966 100644 --- a/settings.js +++ b/settings.js @@ -7,8 +7,8 @@ module.exports = { adminAuth: { type: "credentials", users: [{ - username: "admin", - password: "$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK", + username: process.env.ADMIN_USERNAME || "admin", + password: process.env.ADMIN_PASSWORD || "$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK", permissions: "*" }] }, @@ -18,7 +18,8 @@ module.exports = { }, requireHttps: true,*/ httpNodeAuth: { - user:"admin",pass:"$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK" + user: process.env.API_USERNAME || "admin", + pass: process.env.API_PASSWORD || "$2a$08$s.NFdSn4Gm4d7gHErya//e6O8RO1/3f7TZ7zflXJ9jfFV0cI6jGwK" }, uiPort: process.env.PORT || 1880, httpStatic: [