express icon indicating copy to clipboard operation
express copied to clipboard

Express 3.x with BasicAuth: There is no request.remoteUser

Open fabioboris opened this issue 14 years ago • 4 comments

I'm migrating an express 2.x to 3.x app with the BasicAuth middleware and I need to get the remoteUser from the request, but it come as undefined.

The code:

var express = require('express');
var app = express.createServer();

var basicAuth = express.basicAuth(function(username, password) {
  return (username == 'admin' && password == '12345');
}, 'Restrict area, please identify');

app.get('/admin', basicAuth, function(req, res){
  res.end('remoteUser: ' + req.remoteUser);
});

app.listen(8080);

Any idea?

fabioboris avatar May 22 '12 04:05 fabioboris

It has been renamed as req.user

Delapouite avatar May 22 '12 04:05 Delapouite

Thank you very much!

fabioboris avatar May 22 '12 15:05 fabioboris

just added an alias back to req.remoteUser

tj avatar May 22 '12 15:05 tj

Is it normal that both those prop are set to "true" when I test ? I was thinking they would contain the actual user name.

sebastien-mignot avatar Oct 17 '13 15:10 sebastien-mignot