jaredhanson / jaredhanson/passport-http

HTTP digest on router

Open
#65 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
261
Forks
112
PR merge metrics
No merged PRs in 30d

Description

Hello,

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

[Here's the following snippet](https://gist.github.com/Gawen/ed8663a6d2d543c3ab29391d12bdb55f#file-server-js). Note the variable `use_router`.

```js
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"`).

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

[It does when `use_router` is `false`](https://gist.github.com/Gawen/ed8663a6d2d543c3ab29391d12bdb55f#file-use_router_is_false_output-txt), BUT [it does not when `use_router` is `true`](https://gist.github.com/Gawen/ed8663a6d2d543c3ab29391d12bdb55f#file-use_router_is_true_output-txt).

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

Used versions:

- express: "^4.14.0"
- passport: "^0.3.2"
- passport-http: "^0.3.0"

Contributor guide

Open the contributing guide

Research direction

Start with the linked server.js example and compare the DigestStrategy behavior for the direct route and the Express Router route. Reproduce both curl requests and trace the router-mounted authentication entry point; done means the router-based /hello request returns the expected JSON with digest authentication.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, javascript
Domain
authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.