Would a function actually work when trying to log into node-red admin ui:
adminAuth: {
type: "credentials",
users: function() {
const creds = require("fs").readFileSync('/run/secrets/nodered-credentials', 'utf-8').split('\n')
console.log(creds)
let users = []
creds.forEach(usercreds => {
users.push(
{
username: usercreds.toString().slice(0, usercreds.indexOf(':')),
password: usercreds.toString().slice(usercreds.indexOf(':') + 1).replace("$2y","$2b"),
permissions: "*"
}
)
})
return users
}
},
The value under /run/secrets/nodered-credentials
is an htpasswd
something that looks like:
admin:$2y$08$x9dYJIaLtdGXFydW2AL9s.YodrBDT3QxYHTcOliBuYSBPAUfHGpjO
At the moment in my settings.js
file I can console log the values but I cannot log myself in
The console log for users
secure_nodered | [
secure_nodered | {
secure_nodered | username: 'admin',
secure_nodered | password: '$2b$08$x9dYJIaLtdGXFydW2AL9s.YodrBDT3QxYHTcOliBuYSBPAUfHGpjO',
secure_nodered | permissions: '*'
secure_nodered | }
secure_nodered | ]