Skip to content

Commit

Permalink
Merge pull request #69 from SaaShup/allow_username_and_password
Browse files Browse the repository at this point in the history
Allow username and password
  • Loading branch information
dzove855 authored Apr 2, 2024
2 parents cccd15a + 7c83c67 commit 4929388
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
4 changes: 2 additions & 2 deletions flows.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -5439,4 +5439,4 @@
]
]
}
]
]
7 changes: 4 additions & 3 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: "*"
}]
},
Expand All @@ -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: [
Expand Down

0 comments on commit 4929388

Please sign in to comment.