help icon indicating copy to clipboard operation
help copied to clipboard

Node and Authentication

Open rayj00 opened this issue 4 years ago • 7 comments

  • 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

rayj00 avatar Mar 12 '21 19:03 rayj00

Can you share what happens when you run that code?

addaleax avatar Mar 12 '21 19:03 addaleax

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

rayj00 avatar Mar 12 '21 20:03 rayj00

Could you maybe share your full code in that case? What webpage is being displayed?

addaleax avatar Mar 12 '21 20:03 addaleax

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

rayj00 avatar Mar 12 '21 21:03 rayj00

Actually it works for md5 but I can't get it to work for sha256?

rayj00 avatar Mar 12 '21 21:03 rayj00

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.

marsonya avatar Mar 18 '21 19:03 marsonya

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.

github-actions[bot] avatar May 10 '24 01:05 github-actions[bot]

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.

github-actions[bot] avatar Jun 09 '24 01:06 github-actions[bot]