Giter VIP home page Giter VIP logo

node-red-auth-gitlab's People

Contributors

knolleary avatar vincentsc avatar

Stargazers

 avatar

Watchers

 avatar

node-red-auth-gitlab's Issues

Problem after login

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:

image

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.