Initial working google auth
This commit is contained in:
parent
fb52d49f74
commit
00a40f6bba
1058 changed files with 114441 additions and 0 deletions
32
auth-service/node_modules/passport-oauth2/lib/utils.js
generated
vendored
Normal file
32
auth-service/node_modules/passport-oauth2/lib/utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
exports.merge = require('utils-merge');
|
||||
|
||||
/**
|
||||
* Reconstructs the original URL of the request.
|
||||
*
|
||||
* This function builds a URL that corresponds the original URL requested by the
|
||||
* client, including the protocol (http or https) and host.
|
||||
*
|
||||
* If the request passed through any proxies that terminate SSL, the
|
||||
* `X-Forwarded-Proto` header is used to detect if the request was encrypted to
|
||||
* the proxy, assuming that the proxy has been flagged as trusted.
|
||||
*
|
||||
* @param {http.IncomingMessage} req
|
||||
* @param {Object} [options]
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
exports.originalURL = function(req, options) {
|
||||
options = options || {};
|
||||
var app = req.app;
|
||||
if (app && app.get && app.get('trust proxy')) {
|
||||
options.proxy = true;
|
||||
}
|
||||
var trustProxy = options.proxy;
|
||||
|
||||
var proto = (req.headers['x-forwarded-proto'] || '').toLowerCase()
|
||||
, tls = req.connection.encrypted || (trustProxy && 'https' == proto.split(/\s*,\s*/)[0])
|
||||
, host = (trustProxy && req.headers['x-forwarded-host']) || req.headers.host
|
||||
, protocol = tls ? 'https' : 'http'
|
||||
, path = req.url || '';
|
||||
return protocol + '://' + host + path;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue