vincentsc / node-red-auth-gitlab Goto Github PK
View Code? Open in Web Editor NEWThis project forked from node-red/node-red-auth-twitter
A Gitlab authentication plugin for Node-RED
License: Apache License 2.0
This project forked from node-red/node-red-auth-twitter
A Gitlab authentication plugin for Node-RED
License: Apache License 2.0
To make sure user-management is handled by Gitlab, user access should be allowed read/write/no access based on group-memberships.
Possible to use OpenID-scope? https://discourse.nodered.org/t/implicit-list-of-users-in-adminauth/9813 useful?
Hello,
I'm trying to integrate gitlab login in my application (node-red embedded into express application). I read the documentation, filled all the required credentials and added the callback endpoint but I think I'm missing something related with scopes because I get 401 although I set username: "ericzon" with permissions: ["*"]
Here is my basic setup:
const http = require('http');
const path = require('path');
const express = require('express');
const RED = require('node-red');
const passport = require('passport');
const app = express();
console.log('Starting application...');
app.use('/', express.static('public'));
const server = http.createServer(app);
const HOME_DIR = '/red';
const settings = {
httpAdminRoot: HOME_DIR,
httpNodeRoot: '/api',
userDir: path.join(__dirname, path.sep, 'userDir'),
functionGlobalContext: { }, // enables global context
adminAuth: require('./userDir/node_modules/node-red-auth-gitlab')({
clientID: process.env.GITLAB_CLIENT_ID,
clientSecret: process.env.GITLAB_SECRET,
baseURL: "http://localhost:3000",
gitlabURL: "https://gitlab.com/",
users: [
{ username: "ericzon", permissions: ["*"]}
]
})
};
RED.init(server, settings);
app.use(settings.httpAdminRoot, RED.httpAdmin);
app.use(settings.httpNodeRoot, RED.httpNode);
app.get('/auth/strategy/callback',
passport.authenticate('gitlab', {
failureRedirect: '/red-auth-failure'
}),
function(req, res) {
res.redirect(HOME_DIR);
});
const PORT = process.env.PORT || 3000;
server.listen(PORT), () => {
console.log('Listening port ' + PORT);
};
RED.start();
I go through all the process of login against Gitlab, all seems ok but when I return to backoffice, settings request returns 401 and login appears:
I'm using node-red version: v1.0.6 & 1.1.0 in MACOS Mojave
Adding another log in @node-red/editor-api/lib/auth/index.js inside needsPermission method I can see that 401 is returned after failing settings.read
P.S 1: It works fine when I run this kind of auth in a version of node-red without embed in express.
P.S 2: Investigating more, I see that the problem seems to be caused by httpAdminRoot. If I set '/' it seems to work well in my version but if I add '/red' as prefix, it fails. Any way to work with different httpAdminRoot?
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.