website/integrations/development/node-red/index.md
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.
:::caution
This requires modification of the Node-RED settings.js file and installing additional Passport-js packages; see Securing Node-RED documentation for further details.
:::
The following placeholders are used in this guide:
authentik.company is the FQDN of authentik.nodred.company is the FQDN of Node-RED.:::info This documentation lists only the settings that you need to change from their default values. Be aware that any changes other than those explicitly mentioned in this guide could cause issues accessing your application. :::
To support the integration of Node-RED with authentik, you need to create an application/provider pair in authentik.
Strict redirect URI to https://nodered.company/auth/strategy/callback/.:::info Group based permissions are not implemented in the below example :::
Use npm to install passport-openidconnect
Navigate to the node-red node_modules directory, this is dependent on your chosen install method. In the official Node-RED docker container the node_modules directory is located in the data volume data/node_modules/. Alternatively enter the docker container docker exec -it nodered bash and cd /data/node_modules to utilise npm within the docker container.
Run the command npm install passport-openidconnect
Edit the node-red settings.js file /data/settings.js to use the external authentication source via passport-openidconnect.
adminAuth: {
type:"strategy",
strategy: {
name: "openidconnect",
label: 'Sign in with authentik',
icon:"fa-cloud",
strategy: require("passport-openidconnect").Strategy,
options: {
issuer: 'https://authentik.company/application/o/<application_slug>/',
authorizationURL: 'https://authentik.company/application/o/authorize/',
tokenURL: 'https://authentik.company/application/o/token/',
userInfoURL: 'https://authentik.company/application/o/userinfo/',
clientID: '<client_id>',
clientSecret: '<client_secret>',
callbackURL: 'https://nodered.company/auth/strategy/callback/',
scope: ['email', 'profile', 'openid'],
proxy: true,
verify: function(context, issuer, profile, done) {
return done(null, profile);
},
}
},
users: function(user) {
return Promise.resolve({ username: user, permissions: "*" });
}
},