So I finally relented and decided to go with OAuth2 after much debate and research. It seemed like the safest way to go with the least amount of holes poked into my authentication system.
I was able to modify this plugin to suit my needs and I got it working with an API endpoint that auto-generates random user information. The problem I have is how to link the API endpoint that's called from within node (not from the user's browser) to associate with their current session. In other words, how do I associate this server-side node call with the originating request made by the user in their browser.
To help explain this is what i've got:
Nodebb is running from https://forum.nzb.cat
This is the library.js config from my modified nodebb-plugin-sso-oauth:
constants = Object.freeze({
type: "oauth2", // Either 'oauth' or 'oauth2'
name: "nodebb",
oauth: {
requestTokenURL: '',
accessTokenURL: '',
userAuthorizationURL: '',
consumerKey: '',
consumerSecret: ''
},
oauth2: {
authorizationURL: 'https://auth.nzb.cat/oauth/authorize',
tokenURL: 'https://auth.nzb.cat/oauth',
clientID: 'CLIENTIDSSS',
clientSecret: 'SECRETZZ',
state: 'xyz' //had to append this var to the object or the oauth server explodes.
},
userRoute: 'https://nzb.cat/resource'
}),
Now the nzb.cat/resource endpoint is programmed to output a json representation of the currently logged in user. It validates a successful oauth handshake by parsing the token provided. The issue is the call comes from node itself and not the browser, so there's no currently logged in user from it's perspective, it has nothing to output.
How do I securely "mark" which user is logged in so the process can pull the proper user later on.
And just one last time to make it clear, the entire oauth2 process works great, i get a token and access code without issue, it's just how to denote which user to log in.
I feel kind of stupid I got this far and seem to be missing a major piece. I looked at the other oauth plugins for some help but I couldn't make heads or tails of them for some reason. I'm still not that strong with event based systems.
Also, BTW, you won't be able to hit any of those oauth2 URL's, I have them locked down to specific ip addresses for obvious reasons, I pulled out the client_id and secret because reasons.