2

I developed (in node.js) a simple site (example: http://www.mydomain.com) and I want to allow clients to authenticate through https (example: https://www.mydomain.com/login). After successfully authentication, they are redirected to my site in http... (not secure)

How can I do this? I created two simple files (mydomain.js and mydomainsecure.js) where I run two instances of node on two different ports (80 for http and 443 for https), but after login on https (and redirect to http) I'm not logged in (obviously????)

What is the correct way to implement this?

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
Tiziano Rossi
  • 573
  • 1
  • 3
  • 8

2 Answers2

0

There's a similar question in which a client-side redirect is part of the solution. Further information on Yahoo authentication may help.

Community
  • 1
  • 1
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
0

You can use http-auth module for that:

// Authentication module.
var auth = require('http-auth');
var basic = auth.basic({
    realm: "Simon Area.",
    file: __dirname + "/../data/users.htpasswd" // gevorg:gpass, Sarah:testpass ...
});

// Creating new HTTP server.
http.createServer(basic, function(req, res) {
    res.end("Welcome to private area - " + req.user + "!");
}).listen(1337);
gevorg
  • 4,835
  • 4
  • 35
  • 52