-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
TokenStrategy doesn't play nicely with Express Routes #13
Comments
I have run into this as well. Did you come up with a solution? |
OMG I did but I have no idea what it was. I think (a very vague memory) that it was horrible, whatever I did to fix it. Sorry. |
I ended up figuring out a good solution: In exports.originalURL = function(req, defaultHost) {
var parsedUrl = req.url;
// Handle case where req.url is '/' or '/?foo=bar'
if (req.url.match(/^\/($|\?)/)) {
parsedUrl = req.url.slice(1);
}
var headers = req.headers
, protocol = (req.connection.encrypted || req.headers['x-forwarded-proto'] == 'https')
? 'https'
: 'http'
, host = defaultHost || headers.host
, path = (req.baseUrl || '') + parsedUrl || ''; // this computes the full original url, including nested routes
return protocol + '://' + host + path;
}; I didn't submit a PR, since this project doesn't seem to be actively maintained anymore, but my fork has a complete implementation. |
I just run into the same problem today. I've found the same problem in the same line as @jdormit |
Let's say you create an app with a router (free typing follows)
when
helpers.originalURL
is called, it will come up with/profile/
which then will be fed into the HMAC-SHA1 algorithm for the base (at around line 206 of token.js)Unfortunately, the client has computed the base using
/api/1.0/profile
and so the signatures don't match.The text was updated successfully, but these errors were encountered: