Shared authentication support?

Technical Support
  • Looking to integrate NodeBB with our main website (www.example.com). Can NodeBB recognise accounts that have already been authenticated on the website? If so, how?

    The NodeBB will be hosted on the same server but on a different subdomain (forum.example.com)?

    The site is built on the java platform. It uses Spring Security and MySql Database.

  • The recommended method of sharing sessions between two separate and distinct applications is through OAuth2. We recommend this approach because NodeBB maintains its own user records, so that we can keep track of user-related metrics and other data. Relying on another database would be tricky, prone to breaking, and quite possibly dangerous.

    Luckily, it's quite straightforward to get things working with OAuth2!

    The first step is getting your application to expose an OAuth2 endpoint. If you're running a Node.js based app, you can use a module called OAuth2orize.

    Once that is set up, you'll want to take a look at the SSO plugin skeleton for customised OAuth deployments -- nodebb-plugin-sso-oauth. You'll take this plugin, fork it, and modify it to communicate with your OAuth endpoint.

    Once everything is working properly, you should be able to register and log in/out via your web app.

  • This post is deleted!

Suggested Topics


  • 1 Votes
    23 Posts
    1k Views

    I made it!

    Upgraded from nodebb v1.17 on Ubuntu 18.04 with mongodb 4.0 to nodebb v3.2.1 on Ubuntu 20.04 with mongodb 5.0. Used node v18 to update nodebb.

    Had a few minor issues (getting rid of an expired mongodb 4.0 key), thinking of using npm install --global npm@6 to avoid any issue with plugins updates (emoiji, markdown).

    And voilà!

    Thanks for all the work, the new admin dashboard is sexy as hell.
    Keep up the good work and enjoy your summer!

    Happy GIF

  • 0 Votes
    12 Posts
    2k Views

    @phenomlab My password consists of upper case letters, numbers and lower case letters.

  • 0 Votes
    9 Posts
    3k Views

    @mosthated , Most probably your website already in production (hope it's being doing well 😊). Still, if you'll need to auto-resize the NodeBB embedded in iframe into a host website, try this plugin https://www.npmjs.com/package/nodebb-plugin-iframe-resizable (together with iframe-resizer of course). I wrote it just because I have struggled with exactly the same problem as you.

  • 0 Votes
    3 Posts
    1k Views

    Superb, thanks @julian much obliged.

    Steve

  • 0 Votes
    24 Posts
    12k Views

    I started off this quest with just a simple problem. To have the ability for users to address my nodebb forum (http://theamericanbulletin.com:8080) as (“http://forum.theamericanbulletin.com”). This simple problem turned into a quest through countless videos and reading ( at least fifty) mindnumbing posts on blogs and other forums. I am running a Windows server ( 2008 ) with IIS to service my Wordpress main site. My NodeBB forum is listening on port 8080. All advice was to work within the framework of Windows and IIS, using 'Rewrite', to route traffic on the Server. After days of frustration, I had to come up with a better plan. One that gets me above proprietary nuances. The only way to do that was to get hold of port 80 myself..my own proxy server.. and what better webserver than Nodejs. With little of a search I came accoss this project.

    GitHub - http-party/node-http-proxy: A full-featured http proxy for node.js

    A full-featured http proxy for node.js. Contribute to http-party/node-http-proxy development by creating an account on GitHub.

    favicon

    GitHub (github.com)

    I git cloned the above link. Renamed the new directory to nodeproxy e:\nodeproxy> npm install ( pulls all the needed modules) created a new directory under the new 'nodeproxy' entitled MyProxy Created the MyProxy.js file ( contents below ) Moved my WordPress to listen on port 8081 in IIS Started new proxy server (e:\nodeproxy\myproxy> node myproxy.js ) Done!

    Some notes about the js file. When I first started I used this post as a guideline. It used a routing table... exactly what I was looking for. Although I was not needing to spin-up three test servers, this provided some insight into the power if this little application. I could, if I wanted to.... spin-up as many listeners as I wanted..... listening on whatever, or as many port(s) as I wanted.

    nodejs: routing table using http-proxy

    Trying to put in place an http proxy with a custom routing logic using http-proxy 1.4.3, following this tuto and executing the code below: var httpProxy = require("http-proxy"); var url = require(...

    favicon

    Stack Overflow (stackoverflow.com)

    var httpProxy = require("http-proxy"); var url = require("url"); httpProxy.createServer(function(req, res, proxy) { var hostname = req.headers.host.split(":")[0]; var pathname = url.parse(req.url).pathname; // Options for the outgoing proxy request. var options = { host: hostname }; // Routing logic if(hostname == "127.0.0.1") { options.port = 8083; } else if(pathname == "/upload") { options.port = 8082; options.path = "/"; } else { options.port = 8081; } // (add more conditional blocks here) proxy.proxyRequest(req, res, options); }).listen(8080); console.log("Proxy listening on port 8080"); // We simulate the 3 target applications var http = require("http"); http.createServer(function(req, res) { res.end("Request received on 8081"); }).listen(8081); http.createServer(function(req, res) { res.end("Request received on 8082"); }).listen(8082); http.createServer(function(req, res) { res.end("Request received on 8083"); }).listen(8083);

    I modified the above code to tailor it to my routes, but the server kept breaking. The proxy would throw a “socket hang up” when I moved between the Wordpress site and the NodeBB site. The error was not getting caught and the proxy would just break and go back to a system prompt. Another day of research lead me to this post.

    Not Found

    favicon

    (www.clock.co.uk)

    It was in this post where the idea of wrapping the proxy-server within a domain arose. Perfect! I can pass the error up to the domain and let it dispose of it while the proxy keeps serving ( at least that's how I think it works). Plus the added benefit of having and overlord (parent) to all the potential listeners that could be spun-up to report to. But that is a whole different subject.

    So I added a Domain to the mix and came-up with a working solution. While this only apples to those with 'full' control over their servers, it does add a layer of control over proprietary systems running on your machine, and frees the developer (to a point) from those systems. I do not have to mess with rewrite... or some Apache routine tables. This is 'clean' and simple.

    Please feel free to improve on this concept and tighten this up. There is room for lots of improvement here. Please add to the knowledge.

    Rich

    MyProxy.Js

    var util = require('util'),
    http = require('http'),
    url = require('url'),
    domain = require('domain')
    httpProxy = require('../lib/http-proxy'),
    proxy = httpProxy.createProxyServer({});
    serverDomain = domain.create();
    proxy.on('error', function(err, req, res)
    {
    console.log(err.message);
    });
    serverDomain.run(function () {http.createServer(function(req, res)
    {
    var reqd = domain.create()
    reqd.add(req)
    reqd.add(res)
    // On error dispose of the domain
    reqd.on('error', function (error) {
    console.error('Error', error, req.url)
    reqd.dispose()
    });
    var oUrl = url.parse(req.url);
    if (typeof req.headers !== 'undefined' && req.headers.host.split)
    {
    var hostname = req.headers.host.split(":")[0];
    var pathname = oUrl.pathname;
    switch(hostname)
    {
    case 'forum.theamericanbulletin.com':
    proxy.web(req, res, { target: 'http://localhost:8080' });
    break;
    default:
    proxy.web(req, res, { target: 'http://localhost:8081' });
    };
    console.log(hostname);
    console.log(pathname);
    }
    }).listen(80,function(){
    console.log('proxy listening on port 80');
    });
    });