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.enableTunnel = function (/*opts*/) {
vm.admin.network.iface = 'oauth3-tunnel';
return oauth3.request({ return oauth3.request({
method: 'POST' method: 'POST'
, url: 'https://' + vm.clientUri + '/api/com.daplie.goldilocks/tunnel' , url: 'https://' + vm.clientUri + '/api/com.daplie.goldilocks/tunnel'
/* }).then(function (result) {
, data: { // vm.admin.network.iface = 'oauth3-tunnel';
method: 'GET' return result;
, url: 'https://api.ipify.org?format=json'
}
*/
}); });
}; };

View File

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

View File

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

View File

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