MAJOR: Updates for Authenticated Web UI and CLI #30

Open
coolaj86 wants to merge 77 commits from next into master
6 changed files with 34 additions and 19 deletions
Showing only changes of commit 0489d20fd3 - Show all commits

View File

@ -369,7 +369,12 @@ function parseConfig(err, text) {
if (!state.config.relay || !state.config.token) { if (!state.config.relay || !state.config.token) {
if (!state.config.relay) { if (!state.config.relay) {
state.config.relay = 'telebit.cloud'; try {
state.config.relay = 'telebit.cloud';
} catch(e) {
console.error(state.config);
throw e;
}
} }
//console.log("question the user?", Date.now()); //console.log("question the user?", Date.now());

View File

@ -586,8 +586,10 @@ function jwtEggspress(req, res, next) {
req.jwt = decodeJwt(jwt); req.jwt = decodeJwt(jwt);
} catch(e) { } catch(e) {
// ignore // ignore
next();
return;
} }
if (!req.jwk.kid) { if (!req.jwt.header.kid) {
res.send({ error: { message: "JWT must include a SHA thumbprint as the 'kid' (key id)" } }); res.send({ error: { message: "JWT must include a SHA thumbprint as the 'kid' (key id)" } });
return; return;
} }

View File

@ -24,7 +24,7 @@ module.exports.create = function (opts) {
return fs.unlink(f); return fs.unlink(f);
} }
, findCredentials: function (/*service*/) { , findCredentials: function (/*service*/) {
return fs.readDir(opts.configDir).then(function (nodes) { return fs.readdir(opts.configDir).then(function (nodes) {
return Promise.all(nodes.filter(function (node) { return Promise.all(nodes.filter(function (node) {
return keyext === node.slice(-4); return keyext === node.slice(-4);
}).map(function (node) { }).map(function (node) {

View File

@ -150,7 +150,7 @@ module.exports.create = function (state) {
, claims: { iss: false, exp: Math.round(Date.now()/1000) + (15 * 60) } , claims: { iss: false, exp: Math.round(Date.now()/1000) + (15 * 60) }
//TODO , exp: '15m' //TODO , exp: '15m'
}).then(function (jwt) { }).then(function (jwt) {
req.setHeader("authorization", 'bearer ' + jwt); req.setHeader("Authorization", 'Bearer ' + jwt);
req.end(); req.end();
}); });
} }

36
package-lock.json generated
View File

@ -454,13 +454,21 @@
} }
}, },
"keytar": { "keytar": {
"version": "4.4.1", "version": "4.6.0",
"resolved": "https://registry.npmjs.org/keytar/-/keytar-4.4.1.tgz", "resolved": "https://registry.npmjs.org/keytar/-/keytar-4.6.0.tgz",
"integrity": "sha512-6xEe7ybXSR5EZC+z0GI2yqLYZjV1tyPQY2xSZ8rGsBxrrLEh8VR/Lfqv59uGX+I+W+OZxH0jCXN1dU1++ify4g==", "integrity": "sha512-8wWWTC62QHvUvgW/QYyJv7X0GFZfp2Ykr5n3PuXKADro0Sv2RKvuYxbkzoZvsw33EDNAKnUTSA0/KLGN/MbwDw==",
"optional": true, "optional": true,
"requires": { "requires": {
"nan": "2.12.1", "nan": "2.13.2",
"prebuild-install": "5.2.4" "prebuild-install": "5.3.0"
},
"dependencies": {
"nan": {
"version": "2.13.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz",
"integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==",
"optional": true
}
} }
}, },
"le-challenge-fs": { "le-challenge-fs": {
@ -577,9 +585,9 @@
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
}, },
"node-abi": { "node-abi": {
"version": "2.7.1", "version": "2.8.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.7.1.tgz", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.8.0.tgz",
"integrity": "sha512-OV8Bq1OrPh6z+Y4dqwo05HqrRL9YNF7QVMRfq1/pguwKLG+q9UB/Lk0x5qXjO23JjJg+/jqCHSTaG1P3tfKfuw==", "integrity": "sha512-1/aa2clS0pue0HjckL62CsbhWWU35HARvBDXcJtYKbYR7LnIutmpxmXbuDMV9kEviD2lP/wACOgWmmwljghHyQ==",
"optional": true, "optional": true,
"requires": { "requires": {
"semver": "^5.4.1" "semver": "^5.4.1"
@ -667,9 +675,9 @@
} }
}, },
"prebuild-install": { "prebuild-install": {
"version": "5.2.4", "version": "5.3.0",
"resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.2.4.tgz", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.0.tgz",
"integrity": "sha512-CG3JnpTZXdmr92GW4zbcba4jkDha6uHraJ7hW4Fn8j0mExxwOKK20hqho8ZuBDCKYCHYIkFM1P2jhtG+KpP4fg==", "integrity": "sha512-aaLVANlj4HgZweKttFNUVNRxDukytuIuxeK2boIMHjagNJCiVKWFsKF4tCE3ql3GbrD2tExPQ7/pwtEJcHNZeg==",
"optional": true, "optional": true,
"requires": { "requires": {
"detect-libc": "^1.0.3", "detect-libc": "^1.0.3",
@ -822,9 +830,9 @@
"integrity": "sha1-Az1go60g7PLgCUDRT5eCNGV3QzU=" "integrity": "sha1-Az1go60g7PLgCUDRT5eCNGV3QzU="
}, },
"semver": { "semver": {
"version": "5.6.0", "version": "5.7.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==",
"optional": true "optional": true
}, },
"send": { "send": {

View File

@ -74,7 +74,7 @@
"ws": "^6.0.0" "ws": "^6.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"keytar": "^4.4.1" "keytar": "^4.6.0"
}, },
"trulyOptionalDependencies": { "trulyOptionalDependencies": {
"bluebird": "^3.5.1" "bluebird": "^3.5.1"