From fcdc1a88d748b9f87c080ff083283191c6aa79ad Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 16 Jul 2015 18:20:49 -0300 Subject: [PATCH] Host Option in OAuth Support for reverse proxy server,as nginx, in Authon --- lib/services/oauth2.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/services/oauth2.js b/lib/services/oauth2.js index b6210ee..f0cc807 100644 --- a/lib/services/oauth2.js +++ b/lib/services/oauth2.js @@ -8,7 +8,8 @@ function OAuth2(options){ // This option is necessary when the Oauth service has a self-signed cert. // Hopefully this is only set to false in the safety of testing but not out in the wild. this.rejectUnauthorizedRequests = !(options && options.rejectUnauthorized == false); - + this.host = options.host || null; + EventEmitter.call(this); } @@ -19,7 +20,9 @@ OAuth2.prototype.parseURI = function(request) { , secure = request.connection.encrypted || proto == "https" , protocol = secure ? "https" : "http" , host = request.headers.host || request.connection.remoteAddress - + + if (this.host) host = this.host; + return url.parse(protocol + "://" + host + request.url, true) }