Register new users, how?

474 views
Skip to first unread message

PM

unread,
Oct 15, 2016, 4:42:49 AM10/15/16
to Node-RED
I'm looking for a way to do register/login within node-red, using mongodb to store usernames and passwords (bcrypted).
Any idea?
I know settings.js but I'd like users to be able to register, not just static credentials.

Nicholas O'Leary

unread,
Oct 15, 2016, 4:51:08 AM10/15/16
to Node-RED

Hi,

The docs describe how you can create your own authentication plugin:

http://nodered.org/docs/security#custom-user-authentication

That will let you authenticate users against whatever source you want. How you register users etc is up to you; node-red doesn't provide a user registration work flow.

Nick


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/61fdfbdb-a2ec-4d3b-8986-30542d261aa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adrian Brown

unread,
Oct 15, 2016, 4:55:15 AM10/15/16
to Node-RED

PM

unread,
Oct 15, 2016, 6:09:04 AM10/15/16
to Node-RED
Thank you for your prompt replies!
Men, this is Saturday :)

LDAP is not what I want in my case, but good to know.

I should have been more precise, I'd like to register new users on httpNode (or httpStatic, I didn't get the difference).
I'm trying to setup settings.js according to the guide:
  • Set the adminAuth property in settings.js to load this module:
adminAuth: require("./user-authentication");
adminauth is on line 105, within module.export object, so I modified it as:
adminAuth: require("./user-authentication"),
// and removed

but when running node-red I get:
Error loading settings file: /home/pm/.node-red/settings.js
Error: Cannot find module 'when'

Ok, so I "npm install when --save"
Now I get:
15 Oct 12:00:58 - [info] Started flows
Potentially unhandled rejection [1] ReferenceError: valid is not defined
    at /home/pm/.node-red/user-authentication.js:8:16
    at init (/home/pm/.node-red/node_modules/when/lib/makePromise.js:39:5)
    at new Promise (/home/pm/.node-red/node_modules/when/lib/makePromise.js:27:53)
    at Function.promise (/home/pm/.node-red/node_modules/when/when.js:97:10)
    at Object.users [as get] (/home/pm/.node-red/user-authentication.js:5:20)
    at Object.get (/usr/lib/node_modules/node-red/red/api/auth/users.js:98:42)
    at /usr/lib/node_modules/node-red/red/api/comms.js:111:43
    at tryCatchReject (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:804:4)
    at Fulfilled.when (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:592:4)

And ... I'm stuck.
Do we have a sign in / sign up work flow example somewhere?
And the newbie question : httpStatic vs httpNode?
Thanks and have a good week-end.

PM

unread,
Oct 15, 2016, 10:05:42 AM10/15/16
to Node-RED
Ok, I commented if (valid) parts and it works (well, admin is seen by default),

Any example to register new user and validate from user-authentication.js?

PM

unread,
Oct 15, 2016, 10:20:53 AM10/15/16
to Node-RED
I tried same technique for httNodeAuth and it's not working, I get:

/usr/lib/node_modules/node-red/red.js:189
    if (pass.length == "32") {
            ^
TypeError: Cannot read property 'length' of undefined
    at basicAuthMiddleware (/usr/lib/node_modules/node-red/red.js:189:13)
    at Object.<anonymous> (/usr/lib/node_modules/node-red/red.js:222:35)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)

Ben Hardill

unread,
Oct 15, 2016, 12:52:31 PM10/15/16
to Node-RED
The pointer to the LDAP code was not meant to be a direct solution, but a pointer some example of writing authentication code.

PM

unread,
Oct 15, 2016, 2:32:05 PM10/15/16
to Node-RED
Thanks Ben,
I read your articles, can you explain what I miss? I still don't get how to register users within dashboard or web.

Nicholas O'Leary

unread,
Oct 15, 2016, 2:49:12 PM10/15/16
to Node-RED Mailing List
Hi,

adminAuth and everything it provides is there to secure the editor - the 'admin' side of things.

It sounds like you are talking about securing the HTTP side of things - the HTTP nodes and the dashboard. Currently we don't have the same flexibility on that side of things. The only option, via httpNodeAuth is a single, hardcoded, username and password. That is not going to give you what you need.

You need to use the 'embedded' approach (https://nodered.org/docs/embedding) - that will allow you to add your own http middleware functions in front of the httpNode app and perform whatever custom authentication you need on all requests. What that function does is up to you.

Nick



On 15 October 2016 at 19:32, PM <man...@vocamen.com> wrote:
Thanks Ben,
I read your articles, can you explain what I miss? I still don't get how to register users within dashboard or web.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Ben Hardill

unread,
Oct 15, 2016, 2:51:47 PM10/15/16
to Node-RED
The short answer is, you don't with anything built into Node-RED or the node-red-dashboard

You will have to implement all of that yourself based on what ever backend storage you choose

PM

unread,
Oct 16, 2016, 10:02:20 AM10/16/16
to Node-RED
Thanks,
I hoped for a internal way.
Having user account in dashboard would be great.
User's settings could be useful to apply like light, music, room temp, etc.
For a home, it's ok to click "Dad's settings", for a time-shared office ...

I'd love to write a node if I was able, but I'm not for now.

I know we can embed NPM modules in node-red, is it easy? Any tutorial somewhere?
Does an embeded NPM Auth module could be middleware for dashboard? Or dashboard would superseeds embedded NPM module?
Reply all
Reply to author
Forward
0 new messages