Authentication
@5minds/node-red-auth-processcube-authority — OAuth 2.0 Authentifizierungs-Plugin für Node-RED mit Authority.
Überblick
Das Authentication-Plugin sichert den Node-RED Editor, das Dashboard und HTTP-Nodes über Authority ab. Es basiert auf OAuth 2.0 mit JWT-Token-Validierung.
npm-Paket: @5minds/node-red-auth-processcube-authority
Version: 2.3.x
Lizenz: Proprietary
Geschützte Bereiche
| Bereich | Middleware | Beschreibung |
|---|---|---|
| Editor | adminAuth | Node-RED Editor-Zugang |
| Dashboard | dashboardMiddleware | Dashboard-UI-Zugang |
| Dashboard WebSocket | dashboardIoMiddleware | Dashboard WebSocket-Verbindungen |
| HTTP-Nodes | httpNodeMiddleware | Custom HTTP-Endpoints |
Konfiguration
Die Konfiguration erfolgt über Umgebungsvariablen:
NODERED_AUTHORITY_URL=https://authority.example.com
NODERED_AUTH_CLIENT_ID=node-red-client
NODERED_AUTH_CLIENT_SECRET=secretsettings.js
const authority = require('@5minds/node-red-auth-processcube-authority');
module.exports = {
adminAuth: authority.adminAuth({
authorityUrl: process.env.NODERED_AUTHORITY_URL,
clientId: process.env.NODERED_AUTH_CLIENT_ID,
clientSecret: process.env.NODERED_AUTH_CLIENT_SECRET
}),
httpNodeMiddleware: authority.httpNodeMiddleware,
ui: {
middleware: authority.dashboardMiddleware
}
};Token Acquisition
Token von Authority abrufen (z.B. für Service-to-Service):
// POST /connect/token
msg.payload = {
grant_type: "client_credentials",
client_id: env.get("CLIENT_ID"),
client_secret: env.get("CLIENT_SECRET"),
scope: "engine_read engine_write"
};Response:
msg.payload = {
access_token: "eyJhbGc...",
expires_in: 3600,
token_type: "Bearer"
};Authenticated Requests
Token in Context speichern und verwenden:
flow.set("authToken", msg.payload.access_token);
// Später verwenden
msg.headers = {
"Authorization": `Bearer ${flow.get("authToken")}`
};Token Refresh
Automatischer Token-Refresh:
[Inject: Every 50 minutes] → [Get Token] → [Store in Context]Authentifizierung deaktivieren
Für Entwicklung kann die Authentifizierung deaktiviert werden:
NODERED_AUTH_DISABLED=trueBestimmte URLs können von der Authentifizierung ausgenommen werden:
NODERED_AUTH_SKIP_URLS=/api/public,/healthFeatures
- OAuth 2.0: Vollständige OAuth 2.0 Integration
- JWT-Validierung: Token-Validierung über JWKS-Endpoints
- Passport.js: Integration mit Passport.js für Session-Management
- Express Sessions: Session-Management mit Memory Store
- SSO: Single Sign-On über Authority
Nächste Schritte
- Authority Dokumentation — Authority-Setup
- Runtime Extensions — Health Checks und Monitoring