# Help needed for 2FA with Authy

**URL:** https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764
**Category:** General
**Created:** [17 May 2022 16:00 UTC](https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764 "2022-05-17T16:00:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Topolynx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/topolynx/32/32597_2.png) [@Topolynx](https://discourse.nodered.org/u/Topolynx)
#### Post date: [17 May 2022 16:00 UTC](https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764/1 "2022-05-17T16:00:16Z")

</div>

Hi! I would like to secure node-red with 2FA and a dedicated app (I'm actually using Authy for other services).  
What I've found in the forum and in Node-Red's support pages hasn't helped me enough. Could someone explain me how to activate the new authentication method please? Thanks!

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [17 May 2022 21:08 UTC](https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764/2 "2022-05-17T21:08:28Z")

</div>

Not especially easy. Even I've not bothered to try it as yet. You will need an authy recipe for PassportJS which you will need to link to node-red via the appropriate property in settings.js.

An alternative and potentially easier way would be to use an Authy recipe for NGINX, using NGINX as a reverse proxy for Node-RED.

I've published some NGINX config for Node-RED not so long back in the forum here.

~~There is an Authy recipe for NGINX here: [Adding 2-Factor Authentication to any Web App using Nginx • Sean's Blog (seantodd.co.uk)](https://seantodd.co.uk/blog/putting-2fa-on-everything/) - not tried it though so don't know how good it is.~~ - Oops! Though that is 2FA, it isn't Authy, sorry - dratted Google searches seem to be getting worse quality recently. Well this search turns up a few relevant articles anyway: [nginx authy - Google Search](https://www.google.com/search?q=nginx+authy)

---

<div class="post-metadata">

### Author: ![Topolynx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/topolynx/32/32597_2.png) [@Topolynx](https://discourse.nodered.org/u/Topolynx)
#### Post date: [19 May 2022 10:01 UTC](https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764/3 "2022-05-19T10:01:34Z")

</div>

Thanks @TotallyInformation , I really would avoid using NGINX because it is not so simple making it work (in fact I'm using caddy v2 because configuring it wasn't a pain, undoubtedly.  
Meanwhile I've set OAuth authentication with Google and Passport following [that thread](https://discourse.nodered.org/t/authenticating-into-node-red-using-google-oauth-working-solution/10047) but something has gone wrong because every Google user could login in my node-red, so I've restored the basic internal authentication method.

---

<div class="post-metadata">

### Author: ![Topolynx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/topolynx/32/32597_2.png) [@Topolynx](https://discourse.nodered.org/u/Topolynx)
#### Post date: [19 May 2022 10:40 UTC](https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764/4 "2022-05-19T10:40:07Z")

</div>

I have found what I did wrong [here](https://discourse.nodered.org/t/google-oauth2-issues/3489/10) and corrected my settings file...

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [19 May 2022 11:09 UTC](https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764/5 "2022-05-19T11:09:13Z")

</div>

Glad you got it going.

Would be very cool if you wrote this up in #share-your-projects for future readers?

Cheers.

---

<div class="post-metadata">

### Author: ![Topolynx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/topolynx/32/32597_2.png) [@Topolynx](https://discourse.nodered.org/u/Topolynx)
#### Post date: [19 May 2022 17:12 UTC](https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764/6 "2022-05-19T17:12:17Z")

</div>

Hi @Steve-Mcl ok I'll do it, but for now I prefer to write the steps here since I still have to figure out how enable the _httpNodeAuth_ and _httpStaticAuth_ for the google user.

---

<div class="post-metadata">

### Author: ![Topolynx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/topolynx/32/32597_2.png) [@Topolynx](https://discourse.nodered.org/u/Topolynx)
#### Post date: [19 May 2022 19:15 UTC](https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764/7 "2022-05-19T19:15:55Z")

</div>

Ok, that is what I did.  
In my [Google console project dashboard](https://console.cloud.google.com/home/dashboard) I have first configured the OAuth consent screen. First step: User Type: **external**.

 ![Screenshot (157)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/47c57153ce6ec66ff38da828f7ffde99ca6c8f44.png)  
Saved and moved to the next step.  
Selected my email from the menu, filled the _Authorized domains_ and _Developer contact information_,  
saved and moved to the next step.

 ![Screenshot (158)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/606deab4acc91bcc974b9048c4a9ea1a34ed59d9.png)

 ![Screenshot (159)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6d570abf0b0d3ae1e51962ce33584fa45939d501.png)

Added the scopes. In the Manually add scopes field I wrote email. Saved and moved to the last step.

 ![Screenshot (160)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5a6af03ece46e51f11ce6a2897504a8e004db01d.png)

Finally, I added my google email, Saved twice. OAuth consent screen configured.

![Screenshot (163)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/b/9bafc0afadfcaa688ba95a897e37ecce4d92aafd.png)

Next step, I have created OAuth credentials. The following screenshot should be clear.

 ![Screenshot (155)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/385856948a622db2c8ae9ab75a5acc880957c145.png)

![Screenshot (156)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35ddffc9ede6c5aef9d43f6f0743bb963e8708fb.png)

Now with the credentials I moved to configure node-red itself.

First, stop node-red.  
Installed passport-google-oauth20.

```auto
npm install passport-google-oauth20

```

Then I have changed the _adminAuth_ section to

```auto
    adminAuth: {
        type: "strategy",
        strategy: {
            name: "google",
            label: 'Accedi con Google',
            icon: "fa-google",
            strategy: require('passport-google-oauth20').Strategy,
            options: {
                clientID: 'your ClientID',
                clientSecret: 'your SecretKey',
                scope: 'email',
                callbackURL: "https://yournodered.yourdomain.xxx/auth/strategy/callback",
                verify: function (token, tokenSecret, profile, done) {
                    profile.username = profile.emails.constructor === Array ? profile.emails[0].value : null;
                    return done(null, profile);
                    }
                },
            },
            users: [
                { username: "youremail@gmail.com", permissions: ["*"]}
                ]
            },

```

Saved and restarted node-red.  
If everything is fine the new login screen should be like that:

 ![Screenshot (164)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/9932acc58071c003860a8dedcbb83dc4b22ab187.png)

That's all.  
I have commented the httpNodeAuth and httpStaticAuth sections because I would know if I can generate a password for my gmail new user as described [here](https://nodered.org/docs/user-guide/runtime/securing-node-red).

```auto
// httpNodeAuth: {user:"mebeforegoogleoauth",pass:"(see https://nodered.org/docs/user-guide/runtime/securing-node-red)"},
// httpStaticAuth: {user:"mebeforegoogleoauth",pass:"(see https://nodered.org/docs/user-guide/runtime/securing-node-red)"},

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [2 June 2022 19:16 UTC](https://discourse.nodered.org/t/help-needed-for-2fa-with-authy/62764/8 "2022-06-02T19:16:16Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
