GitHub – node-red/node-red-auth-github: A GitHub authentication plugin for Node-RED

Introduction

This Guide is for setting up a secure Dedicated Server.
Running node-red
This guide assumes you have a running server with Ubuntu 20.04 and that you have access to terminal on the server. You can host this yourself however this guide does not address port forwarding from routers or DMZ settings and or ipv6 settings.

You need a Domain Name and the ability to point it to your IP address. Let’s Encrypt doesn’t issue certificates for bare IP addresses, only domain names. You’ll need to register a domain name in order to get a Let’s Encrypt certificate.

What your server needs: a visable IP address to the internet to include if you wish a ipv6 address.

Add the certificate to settings.js

With the certificates obtained edit ~/.node-red/settings.js and make the following changes:

Uncomment the following line

# From
//var fs = require("fs)

# To
var fs = require("fs)

Adding authentication to node-red

So that we can put Node-RED behind authentication we need to generate a password hash and update the settings.js file. This settings file is located at ~/.node-red/settings.js.

Automatic_increasing_ban_times

Many malicious actors will just take note of the fixed ban time and just keep at it every 10min. Instead of increasing the fixed time we want to increase the time for specific bad actors and not every one.

In terminal:

This will open a text editor

search for and remove the # sign in front of the following lines so they look like this:

Restart fail2ban

In terminal:

END OF TUTORIAL

Build-essential

Install possible dependency build-essential first

In terminal:

Can i add other fields to the jwt payload?

Not yet.

Copy the certificate files to the .node-red folder

This will cause a breaking change every 3 months when the certificate renews, so you will need a cron job for this.

Credentials within the editor

Within the editor, a node has restricted access to its credentials. Any that are
of type text are available under the credentials property – just as they are
in the runtime.

But credentials of type password are not available. Instead,
a corresponding boolean property called has_<property-name> is present to
indicate whether the credential has a non-blank value assigned to it.

Generate a certificate

To generate the certificate run the following command.

Install node-red

Install Node-RED with the following command

sudo npm install -g --unsafe-perm node-red

Create a service so that Node_RED will start on reboot

Install_nginx

Nginx is a web server which can also be used as a reverse proxy.
By default, Nginx is configured to start automatically when the server boots/reboots

In terminal:

Check to see if Nginx is running

In terminal:

Is it secure?

Json web token (JWT) is an industry standard RFC719 in representing claims between two parties. As long as the token passes verification and the secret hasn’t been compromised, you can be sure that the contents of the JWT payload hasn’t been tampered with. You can read more about JWT and how it’s used here:

Introduction to JSON Web Tokens

5 Easy Steps to Understanding JSON Web Tokens (JWT)

Nod-red_script

Install nod-red and its dependencies

In terminal:

Pre-requisites

Start with fully patched Ubuntu 18.04LTS base OS install. Not going to cover that part here.

Install the build-essentials package

sudo apt-get install -y build-essential

Install Node Package Manager (npm)

sudo apt-get install npm -y

Register a new github application

To enable access control with GitHub, you must first register a new application
on your GitHub account.

Once created, you will be provided a Client ID and Client Secret that
you will need to use to configure the authentication plugin.

Runtime use of credentials

Within the runtime, a node can access its credentials using the credentials
property:

Setup_server

Bring up a terminal on the server

Update_server

Update the local repositories and upgrade the operating system and installed applications by applying the latest patches.
Keep settings or files during the upgrade if asked. Follow the suggestions presented in terminal

In terminal:

Аутентификация пользователей с помощью собственного кода

Вместо того, чтобы «хардкодить» данные о пользователях в файл настроек, вы также можете задать аутентификацию пользователей при помощи собственного кода. Кроме того, ваш метод можно будет встроить в уже имеющиеся аутентификационные схемы.

Пример ниже показывает, как можно использовать внешний модуль, чтобы задать собственный аутентификационный код:

Аутентификация через oauth/openid

Была добавлена в версии 0.17.

Если вы хотите настроить аутентификацию через внешний ресурс, то можете воспользоваться для этого большим диапазоном аутентификационных стратегий библиотеки «passport.js».

Защита админского и редакторского api

Админский и редакторский API поддерживают два типа аутентификации:

Истечение срока действия аутентификационного токена

По умолчанию срок действия токена доступа истекает через 7 дней после его создания. Увеличение этого периода сейчас не поддерживается.

Полномочия пользователей

До выхода версии 0.14 для пользователей можно было задать только два вида полномочий:

  • «*» – полный доступ
  • «read» – только для чтения

Но с выходом версии 0.14 появились новые возможности для настройки полномочий. Теперь значением в этом свойстве может быть и одна строка (как раньше), и массив с несколькими полномочиями.

У каждого метода в админском API есть полномочия, необходимые для доступа к нему. Модель полномочий – ресурсо-ориентированная. К примеру, чтобы прочесть данные текущего потока, пользователю понадобится полномочие «flows.read», а для обновления потока ему понадобится полномочие «flows.write».

Похожее:  connection error 80130183 :: War Thunder General Discussions

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *