Help needed for 2FA with Authy

Ok, that is what I did.
In my Google console project dashboard I have first configured the OAuth consent screen. First step: User Type: external.


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.

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

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

Screenshot (163)

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

Screenshot (156)

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

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

npm install passport-google-oauth20

Then I have changed the adminAuth section to

    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:

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.

// 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)"},
3 Likes