help
help copied to clipboard
Node and Authentication
- Node.js Version: v14.4.0
- OS: Ubuntu 20.04 Server
- Scope (install, code, runtime, meta, other?): Code
- Module (and version) (if relevant):
I am trying to implement node authentication
// I am an example of JS code
Server.js code:
const fs = require('fs'); const path = require('path'); const url = require('url'); var httpServer = require('http'); const auth = require("http-auth"); const basic = auth.basic( { realm: "Private Area", file: __dirname + "/htpasswd", }); ... ... function serverHandler(request, response) {
console.log("dirname = ", __dirname);
//console.log(user = ${basic.file} + ${user});
basic.check(request, response => {
response.end(`Welcome to private area, ${basic.file} + ${username}`);
});
I know I'm missing something....but what?
Thanks,
Ray
Can you share what happens when you run that code?
Can you share what happens when you run that code?
Ironically, absolutely nothing happens! The node server just goes on it's merry way and gets and displays the webpage.
Ray
Could you maybe share your full code in that case? What webpage is being displayed?
Could you maybe share your full code in that case? What webpage is being displayed?
I am actually testing another method from https://www.dotnetcurry.com/nodejs/1237/digest-authentication-nodejs-application I have it working but still need to figure out how to differentiate two classes of users.
Ray
Actually it works for md5 but I can't get it to work for sha256?
Actually it works for md5 but I can't get it to work for sha256?
Hi @rayj00, did you find the solution for your problem? In case you haven't, kindly share your full code if possible.
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.
It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.