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-oath2 broken check for 'trust proxy' #22

Closed
thecaddy opened this issue Oct 22, 2014 · 2 comments
Closed

Passport-oath2 broken check for 'trust proxy' #22

thecaddy opened this issue Oct 22, 2014 · 2 comments

Comments

@thecaddy
Copy link

I'm using passport-facebook which in turn uses passport-oauth2. It looks like there is a line of code explicitly for express buried down in it that causes loggin in to crash.

If you look in the file below the offending line is 19:
https://github.com/jaredhanson/passport-oauth2/blob/master/lib/utils.js

exports.originalURL = function(req, options) {
  options = options || {};
  var app = req.app;
  //this is the bad stuff
  if (app && app.get && app.get('trust proxy')) {
    options.proxy = true;
  }

app.get('header nonsense here') is an express function and doesn't exist for koa. Maybe add a mapping to koa to retrieve the header values according to what express returns?

rkusa added a commit that referenced this issue Oct 22, 2014
@rkusa
Copy link
Owner

rkusa commented Oct 22, 2014

Good finding, thanks! The mock should now return Koa's app.proxy for calls to Express' req.app.get('trust proxy').

Does this change work for you?

Don't forget to set:

var koa = require('koa')
var app = koa()
app.proxy = true

@thecaddy
Copy link
Author

Just ran my test on it, and works like a charm. Thanks for the quick response!

@rkusa rkusa closed this as completed in 0451f63 Oct 23, 2014
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

2 participants