jaredhanson / passport-http

HTTP Basic and Digest authentication strategies for Passport and Node.js.
https://www.passportjs.org/packages/passport-http/?utm_source=github&utm_medium=referral&utm_campaign=passport-http&utm_content=about
MIT License
268 stars 110 forks source link

HTTP digest on router #65

Open gawen opened 7 years ago

gawen commented 7 years ago

Hello,

I am unable to apply a DigestStrategy to a route defined in a express' Router.

Here's the following snippet. Note the variable use_router.

var handler = function(req, res) {
    res.json({"hello": "world"});
};

if (use_router) {
    var router = express.Router();
    router.get('/', passport.authenticate('digest', {session: false}), handler);
    app.use("/hello", router);
} else {
    app.get('/hello', passport.authenticate('digest', {session: false}), handler);
}

I expected to received {"hello": "world"} if I GET on /hello the right username (any value) and password ("password").

curl -v --user user:password --digest http://localhost:8888/hello

It does when use_router is false, BUT it does not when use_router is true.

I would expect aaplying a DigestStrategy to a route registered in a router to work, but it appears it does not.

Used versions: