fixed the owner not being on stored tunnel tokens

This commit is contained in:
tigerbot 2017-06-08 10:44:22 -06:00
parent 50cee61ac6
commit 027494cd1d
4 changed files with 9 additions and 14 deletions

View File

@ -240,17 +240,12 @@ angular.module('com.daplie.cloud', [ 'org.oauth3' ])
};
vm.enableTunnel = function (/*opts*/) {
vm.admin.network.iface = 'oauth3-tunnel';
return oauth3.request({
method: 'POST'
, url: 'https://' + vm.clientUri + '/api/com.daplie.goldilocks/tunnel'
/*
, data: {
method: 'GET'
, url: 'https://api.ipify.org?format=json'
}
*/
}).then(function (result) {
// vm.admin.network.iface = 'oauth3-tunnel';
return result;
});
};

View File

@ -140,6 +140,7 @@ module.exports = function (myDeps, conf, overrideHttp) {
, tunnel: function (deps, session) {
// TODO save session to config and turn tunnel on
var OAUTH3 = deps.OAUTH3;
var owner = session.id;
var url = require('url');
var providerUri = session.token.aud;
var urlObj = url.parse(OAUTH3.url.normalize(session.token.azp));
@ -176,7 +177,7 @@ module.exports = function (myDeps, conf, overrideHttp) {
}
}).then(function (result) {
console.log('got a token from the tunnel server?');
result.owner = session.id;
result.owner = owner;
return deps.tunneler.add(result);
});
/*

View File

@ -200,8 +200,8 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
agent.createConnection = deps.net.createConnection;
var proxy = require('http-proxy').createProxyServer({
agent: agent,
toProxy: true
agent: agent
, toProxy: true
});
proxyServer = http.createServer(function (req, res) {
@ -229,8 +229,8 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
xHeaders['X-Forwarded-Host'] = headers.host;
conn.proxyOpts = {
target: 'http://'+(mod.address || (mod.host || 'localhost')+':'+mod.port),
headers: xHeaders
target: 'http://'+(mod.address || (mod.host || 'localhost')+':'+mod.port)
, headers: xHeaders
};
proxyServer.emit('connection', conn);
conn.unshift(opts.firstChunk);

View File

@ -132,7 +132,6 @@ module.exports.create = function (deps, conf) {
console.log('req.body', req.body);
return deps.storage.owners.get(req.userId).then(function (session) {
session.token.id = req.userId;
return api.tunnel(deps, session).then(function () {
res.setHeader('Content-Type', 'application/json;');
res.end(JSON.stringify({ success: true }));