nodejs user system authentication - node.js

I'm a nodejs beginner and I have a question about authentication.
My goal is to have an authentication based on the operative system users where the server js run.
I read many article on passport and express framework, but all require the presence of a mongoDB and it was out of scope for my problem.
So my question is:
Is it possible in nodejs to interact with OS and write an authentication module for the OS users?

I don't know exactly how is it possible, but it should be possible.
Some links for Windows:
C# Corner: Vidya Vrat Agarwal, Understanding Windows Authentication in Detail
StackOverflow: Windows Integrated Authentication in node.js Client
StackOverflow: NTLM authentication using node.js
Windows → Dev Center - Desktop → LogonUser function
Addons Node.js Manual & Documentation
However, if you are new to Node.js then using Windows Authentication strategy for Passport.js together with some MongoDB alternative (see Stack Overflow: Lightweight Javascript DB for use in Node.js) may be an easier way to go

Related

Run VS Code Web Extension with full nodejs APIs support in VS Code Desktop

I am developing a web extension that works well on the vscode.dev with client-based OAuth but when I need to use the same in desktop vscode, the JS Domain i.e. location.origin is coming to be vscode-file://vscode-app which I can't use as JS domain for OAuth2. This results in CORS errors for API calls.
Hence, I need to use the server-based OAuth method to avoid CORS errors.
For this, I need to run the http.createServer method from nodejs when the extension runs in the vscode desktop.
This means that some parts of my source code will work in vscode. dev (i.e. nodejs independent) while others will only work in VS Code desktop (i.e. nodejs dependent).
Can anyone guide me on how to go about implementing the same for my project?
P.S. - I want to provide some functionalities in vscode.dev and some extra functionalities in VS Code Desktop hence I need this hybrid approach.

IIS/ASP.Net vs NodeJs/ExpressJS

I'm very new to NodeJs/expressJs, i read tons of articles on internet and still don't understand it
is NodeJs a web server like IIS ? if so can i host an asp.net app in NodeJS ?
Is expressJs a framework like ASP.NET ?
I currently work on both IIS ASP.NET applications as well as NodeJS/ExpressJS systems and the below is what I have noted to be different:
IIS:
Windows server based
Can have strict setups such as MVC etc
Built in deployment that compiles the entire website
Setup can take quite some time to create all modals and get all
plugins working etc
Services can take some time setup and modal mapping can be tedious
NodeJS/ExpressJS:
Not Windows based. I run this typically on an Ubuntu server with
Nginx to push the domain to the public
Easy to setup and fast to get something basic online
Does not natively compile and runs files as they are
Uses npm package manager with easy to install packages
Does not have strict setups but you can technically create your own
MVC style system
Code can quickly become messy however with the correct approach you
can manage the amount of code easily.
NodeJS is not a web server. It is a backend server (Such as a REST API etc)
ExpressJS sits ontop of NodeJS to add functionality and is essentially a framework. Coupled with jade/pug you can write js inside the html.

Window Authentication Using Node JS on Linux

I have multiple apps on Linux server. I want to use Window Authentication for login in apps. How can I do it using on Linux. I already Have connection with Active Directory. I just need current username of requested user for getting user profile from active directory.
Can I do it without deploying apps on IISNODE ???
I want on Linux. Is there any module available for that?
You need to use either NTLM (simpler, but older and apparently less secure) or Kerberos (the new way and more secure, but a little more complicated to setup).
There is a Kerberos module for Node, but I have no experience with it: https://www.npmjs.com/package/kerberos
Search for "kerberos nodejs" and you should find more help.
I also found these walk-throughs to install modules on Apache to do it, in case they're helpful:
NTLM: http://modntlm.sourceforge.net/
Kerberos: https://active-directory-wp.com/docs/Networking/Single_Sign_On/Kerberos_SSO_with_Apache_on_Linux.html

Running related apps in different servers

I have NodeJS server for my iPhone and Android apps and I want to build an admin panel as desktop application using Electron.
From my research, I found out that Electron depends on its own version of node and it can't run on other server instance.
My questions are:
1) is it advisable to implement the admin panel using Electron knowing that it depends on its own version of NodeJS?
2) is there away to integrate my current NodeJS server for mobile apps to my Electron? because using two different servers will be costly when it comes to hosting them
3) what are other alternatives that enable me to implement cross-platform desktop application using my current mobile apps server?
NOTE: The admin panel server functionality are completely different from mobile apps.
1) is it advisable to implement the admin panel using Electron knowing that it depends on its own version of NodeJS?
Yes, that is perfectly fine. You can access your current node server directly from your electron app, or create a new node server that electron will access.
2) is there away to integrate my current NodeJS server for mobile apps to my Electron? because using two different servers will be costly when it comes to hosting them
You can run multiple nodejs servers on one machine (just use different ports when starting the servers). This is one easy way to get around this issue, or you can just have a group of /admin endpoints that handle all admin related functionality. Think of electron has a front-end that can be distributed across various platforms and access any back-end you choose.
3) what are other alternatives that enable me to implement cross-platform desktop application using my current mobile apps server?
Electron / nwjs (node-webkit) are the only two that come to mind. Although there are probably others.
More Electron/nwjs details:
Just think of these as browsers that allow you to write nodejs. Therefore, within the browser you can access databases you ship with your app, or anything on the users file system. You can also make requests from your app to already created nodejs servers. Also, they allow you to easily package up your app for cross-platform distribution.

Is using node.js is suitable for web GUI app and using same source for desktop app?

Im thinking about using node.js for web application , that is something like tomcat with servlents or Apache and php.
my questions are basic but fundamental:
1. can i use node.js as web server? using jquery and all the server side stuff?
2. i want to let the users to be able to use the application in offline mode , and let
the user to download the web app as desktop app .
can node.js be good for this job ?
Node.js is a platform for creating server-side and networking applications. You can use its HTTP and Socket support to create a web server.
And yes, you can use client side libraries and frameworks like jQuery, Angular.js, Ember.js, etc etc. by using a Node.js REST API as backend (as a possible solution).
You can make desktop applications using:
Node-QT bindings
Appjs

Resources