parent
c403e367f7
commit
fc223c9f86
|
@ -60,38 +60,11 @@ function setRoutes(server) {
|
|||
}
|
||||
console.log('GitHub OAuth: ' + token);
|
||||
|
||||
// FIXME: synchronize things in the background.
|
||||
// Send the token to all of those IPs.
|
||||
var ips = serverSecrets.shieldsIps;
|
||||
Promise.all(ips.map(function(ip) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var options = {
|
||||
url: 'https://' + ip + '/github-auth/add-token',
|
||||
method: 'POST',
|
||||
form: {
|
||||
shieldsSecret: serverSecrets.shieldsSecret,
|
||||
token: token,
|
||||
},
|
||||
// We target servers by IP, and we use HTTPS. Assuming that
|
||||
// 1. Internet routers aren't hacked, and
|
||||
// 2. We don't unknowingly lose our IP to someone else,
|
||||
// we're not leaking people's and our information.
|
||||
// (If we did, it would have no impact, as we only ask for a token,
|
||||
// no GitHub scope. The malicious entity would only be able to use
|
||||
// our rate limit pool.)
|
||||
// FIXME: use letsencrypt.
|
||||
strictSSL: false,
|
||||
};
|
||||
request(options, function(err, res, body) {
|
||||
if (err != null) { return reject('Posting the GitHub user token failed: ' + err.stack); }
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
})).then(function() {
|
||||
end('Done!');
|
||||
}).catch(function(e) {
|
||||
end('Done!');
|
||||
|
||||
sendTokenToAllServers(token)
|
||||
.catch(function(e) {
|
||||
console.error('GitHub user token transmission failed:', e);
|
||||
end('Horror! Something went wrong. Please try again.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -110,4 +83,33 @@ function setRoutes(server) {
|
|||
});
|
||||
};
|
||||
|
||||
function sendTokenToAllServers(token) {
|
||||
var ips = serverSecrets.shieldsIps;
|
||||
return Promise.all(ips.map(function(ip) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var options = {
|
||||
url: 'https://' + ip + '/github-auth/add-token',
|
||||
method: 'POST',
|
||||
form: {
|
||||
shieldsSecret: serverSecrets.shieldsSecret,
|
||||
token: token,
|
||||
},
|
||||
// We target servers by IP, and we use HTTPS. Assuming that
|
||||
// 1. Internet routers aren't hacked, and
|
||||
// 2. We don't unknowingly lose our IP to someone else,
|
||||
// we're not leaking people's and our information.
|
||||
// (If we did, it would have no impact, as we only ask for a token,
|
||||
// no GitHub scope. The malicious entity would only be able to use
|
||||
// our rate limit pool.)
|
||||
// FIXME: use letsencrypt.
|
||||
strictSSL: false,
|
||||
};
|
||||
request(options, function(err, res, body) {
|
||||
if (err != null) { return reject('Posting the GitHub user token failed: ' + err.stack); }
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
exports.setRoutes = setRoutes;
|
||||
|
|
Loading…
Reference in New Issue
Block a user