Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/passport-http-oauth/strategies/utils:originalURL method. #14

Open
andriikadyrov90 opened this issue Jun 10, 2016 · 6 comments
Open

/passport-http-oauth/strategies/utils:originalURL method. #14

andriikadyrov90 opened this issue Jun 10, 2016 · 6 comments

Comments

@andriikadyrov90
Copy link

First of all thanks for the library. It`s very easy to implement 'oauth' server provider side with it.

Recently I had a task of creating several routes with the same beginning part of the url. For instance, the start of all urls is '/base' and every route under the base must be checked with 'oauth' (ConsumerStrategy from the library) passport authentication middleware, like the following:

app.use('/base', passport.authenticate('oauth', {session: false}), require('./oauth-api'));

in the 'oauth-api' file I create a Route and add 8 urls. So, the complete routes look like this:

router.get('/route1', controller.route1); router.get('/routeN', controller.routeN);
When an oauth Consumer prepares a request to my server, it creates oauth_signature. The URL part of the signature would be like the following:

http://localhost:{port}/base/route1

Whereas the library would consider the url without the base, like this:

http://localhost:{port}/route1

And therefore the signatures don`t match.

The solution that worked for me was to amend ,mentioned in the topic, the 'originalURL' the line

path = req.url || '';

to the line

path = req.originalUrl || '';

@sambrenner
Copy link

This appears to be fixed by PR #10, would it be possible to have it merged in?

@LittleCodeGeek
Copy link

Seeing as there is no activity on #10, I created #17 with code that more closely resemble the author's.

@ramesius
Copy link

ramesius commented Sep 6, 2018

Ran into this issue recently when using express Router. @zentarul any chance on finalising your PR #17?

@LittleCodeGeek
Copy link

@ramesius I'd love to, but if I'm not mistaken, I need the repository owner to approve the pr first.

@ramesius
Copy link

ramesius commented Sep 6, 2018

CC @jaredhanson, any chance on getting this mentioned PR (#17) sorted out?

@djromberg
Copy link

I just stumbled over the same issue where I want to use express Router but once I do this, the signature verification fails due to the wrong URL. utils.js:29 should use req.originalUrl instead of req.url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants