More FIDO2 improvements, improved NPM install.
Ylian Saint-Hilaire committed
Mar 23, 2019 at 13:28 UTC
4561468b05f713fed0873240144dc6fa26abd80e
6 files changed
+315
-36
meshcentral.js
+20
-4
@@ -1596,21 +1596,30 @@ function getConfig(createSampleConfig) {
1596
1597
// Check if a list of modules are present and install any missing ones
1598
function InstallModules(modules, func) {
1599
- if (modules.length > 0) { InstallModule(modules.shift(), InstallModules, modules, func); } else { func(); }
1599
+ var missingModules = [];
1600
+ if (modules.length > 0) {
1601
+ for (var i in modules) { try { var xxmodule = require(modules[i]); } catch (e) { missingModules.push(modules[i]); } }
1602
+ if (missingModules.length > 0) { InstallModule(missingModules.join(' '), InstallModules, modules, func); } else { func(); }
1603
+ }
1604
}
1605
1606
// Check if a module is present and install it if missing
1607
+var InstallModuleChildProcess = null;
1608
function InstallModule(modulename, func, tag1, tag2) {
1609
try {
1610
var module = require(modulename);
1611
} catch (e) {
1612
console.log('Installing ' + modulename + '...');
1613
var child_process = require('child_process');
1609
- child_process.exec('npm install ' + modulename + ' --no-optional --save', { maxBuffer: 512000 }, function (error, stdout, stderr) {
1614
+
1615
+ // Looks like we need to keep a global reference to the child process object for this to work correctly.
1616
+ InstallModuleChildProcess = child_process.exec('npm install ' + modulename + ' --no-optional --save', { maxBuffer: 512000, timeout: 10000 }, function (error, stdout, stderr) {
1617
+ InstallModuleChildProcess = null;
1618
if (error != null) { console.log('ERROR: Unable to install missing package \'' + modulename + '\', make sure npm is installed: ' + error); process.exit(); return; }
1619
func(tag1, tag2);
1620
return;
1621
});
1622
+
1623
return;
1624
}
1625
func(tag1, tag2);
@@ -1633,7 +1642,8 @@ function mainStart(args) {
1642
1643
// Check is Windows SSPI will be used
1644
var sspi = false;
1636
- if (require('os').platform() == 'win32') { for (var i in config.domains) { if (config.domains[i].auth == 'sspi') { sspi = true; } } }
1645
+ var allsspi = true;
1646
+ if (require('os').platform() == 'win32') { for (var i in config.domains) { if (config.domains[i].auth == 'sspi') { sspi = true; } else { allsspi = false; } } }
1647
1648
// Build the list of required modules
1649
var modules = ['ws', 'nedb', 'https', 'yauzl', 'xmldom', 'express', 'archiver', 'multiparty', 'node-forge', 'express-ws', 'compression', 'body-parser', 'connect-redis', 'express-handlebars'];
@@ -1642,8 +1652,14 @@ function mainStart(args) {
1652
if (config.settings.mongodb != null) { modules.push('mongojs'); } // Add MongoDB
1653
if (config.smtp != null) { modules.push('nodemailer'); } // Add SMTP support
1654
1655
+ // Get the current node version
1656
+ var nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
1657
+
1658
// If running NodeJS < 8, install "util.promisify"
1646
- if (Number(process.version.match(/^v(\d+\.\d+)/)[1]) < 8) { modules.push('util.promisify'); }
1659
+ if (nodeVersion < 8) { modules.push('util.promisify'); }
1660
+
1661
+ // if running NodeJS 8 or higher, we can install WebAuthn/FIDO2 support
1662
+ if ((nodeVersion >= 8) && (allsspi == false)) { modules.push('@davedoesdev/fido2-lib'); }
1663
1664
// Install any missing modules and launch the server
1665
InstallModules(modules, function () { meshserver = CreateMeshCentralServer(config, args); meshserver.Start(); });
meshuser.js
+11
-1
@@ -2004,11 +2004,17 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2004
{
2005
if ((obj.webAuthnReqistrationRequest == null) || (parent.f2l == null)) return;
2006
2007
+ // Figure out the origin
2008
+ var httpport = ((args.aliasport != null) ? args.aliasport : args.port);
2009
+ var origin = "https://" + (domain.dns ? domain.dns : parent.certificates.CommonName);
2010
+ if (httpport != 443) { origin += ':' + httpport; }
2011
+
2012
var attestationExpectations = {
2013
challenge: obj.webAuthnReqistrationRequest.request.challenge.split('+').join('-').split('/').join('_').split('=').join(''), // Convert to Base64URL
2009
- origin: "https://devbox.mesh.meshcentral.com",
2014
+ origin: origin,
2015
factor: "either"
2016
};
2017
+
2018
var clientAttestationResponse = command.response;
2019
clientAttestationResponse.id = clientAttestationResponse.rawId;
2020
clientAttestationResponse.rawId = new Uint8Array(Buffer.from(clientAttestationResponse.rawId, 'base64')).buffer;
@@ -2016,6 +2022,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2022
clientAttestationResponse.response.clientDataJSON = new Uint8Array(Buffer.from(clientAttestationResponse.response.clientDataJSON, 'base64')).buffer;
2023
2024
parent.f2l.attestationResult(clientAttestationResponse, attestationExpectations).then(function (regResult) {
2025
+ // If we register a WebAuthn/FIDO2 key, remove all U2F keys.
2026
+ // TODO
2027
+
2028
+ // Add the new WebAuthn/FIDO2 keys
2029
var keyIndex = parent.crypto.randomBytes(4).readUInt32BE(0);
2030
if (user.otphkeys == null) { user.otphkeys = []; }
2031
user.otphkeys.push({ name: obj.webAuthnReqistrationRequest.keyname, type: 3, publicKey: regResult.authnrData.get('credentialPublicKeyPem'), counter: regResult.authnrData.get('counter'), keyIndex: keyIndex, keyId: clientAttestationResponse.id });
package-lock.json
+272
-19
@@ -1,9 +1,59 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.2.9-q",
3
+ "version": "0.3.0-u",
4
"lockfileVersion": 1,
5
"requires": true,
6
"dependencies": {
7
+ "@davedoesdev/fido2-lib": {
8
+ "version": "2.4.0",
9
+ "resolved": "https://registry.npmjs.org/@davedoesdev/fido2-lib/-/fido2-lib-2.4.0.tgz",
10
+ "integrity": "sha512-qBNCio4amWMxDe7e8VG3wOo3iu/cFxzLpZ+vzRhLDYbQpZVBhJxFyYXCak33+1qPkDHJOSLZBU7x5jyruU1RMA==",
11
+ "requires": {
12
+ "@peculiar/webcrypto": "^1.0.1",
13
+ "asn1js": "^2.0.18",
14
+ "cbor": "^4.0.0",
15
+ "cose-to-jwk": "^1.1.0",
16
+ "jwk-to-pem": "^2.0.0",
17
+ "node-jose": "^1.0.0",
18
+ "pkijs": "=2.1.58",
19
+ "psl": "^1.1.24"
20
+ }
21
+ },
22
+ "@peculiar/asn1-schema": {
23
+ "version": "1.0.3",
24
+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-1.0.3.tgz",
25
+ "integrity": "sha512-Tfgj9eNJ6cTKEtEuidKenLHMx/Q5M8KEE9hnohHqvdpqHJXWYr5RlT3GjAHPjGXy5+mr7sSfuXfzE6aAkEGN7A==",
26
+ "requires": {
27
+ "asn1js": "^2.0.22",
28
+ "tslib": "^1.9.3"
29
+ }
30
+ },
31
+ "@peculiar/json-schema": {
32
+ "version": "1.1.5",
33
+ "resolved": "https://registry.npmjs.org/@peculiar/json-schema/-/json-schema-1.1.5.tgz",
34
+ "integrity": "sha512-y5XYA3pf9+c+YKVpWnPtQbNmlNCs2ehNHyMLJvq4K5Fjwc1N64YGy7MNecKW3uYLga+sqbGTQSUdOdlnaRRbpA==",
35
+ "requires": {
36
+ "tslib": "^1.9.3"
37
+ }
38
+ },
39
+ "@peculiar/webcrypto": {
40
+ "version": "1.0.8",
41
+ "resolved": "https://registry.npmjs.org/@peculiar/webcrypto/-/webcrypto-1.0.8.tgz",
42
+ "integrity": "sha512-zOCwDimHbQeUgSdBCHnw/69wbA1ks+aUt1MPAttcWNOlXaZjbUppc8shtwX/mzDQYctzNGFlI8Xrayl7lBUe5A==",
43
+ "requires": {
44
+ "@peculiar/asn1-schema": "^1.0.2",
45
+ "@peculiar/json-schema": "^1.1.5",
46
+ "asn1js": "^2.0.22",
47
+ "pvtsutils": "^1.0.4",
48
+ "tslib": "^1.9.3",
49
+ "webcrypto-core": "^1.0.10"
50
+ }
51
+ },
52
+ "@types/node": {
53
+ "version": "10.14.3",
54
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.3.tgz",
55
+ "integrity": "sha512-2lhc7S28vo8FwR3Jv3Ifyd77AxEsx+Nl9ajWiac6/eWuvZ84zPK4RE05pfqcn3acIzlZDpQj5F1rIKQZX3ptLQ=="
56
+ },
57
"accepts": {
58
"version": "1.3.5",
59
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
@@ -101,6 +151,24 @@
151
"safer-buffer": "~2.1.0"
152
}
153
},
154
+ "asn1.js": {
155
+ "version": "4.10.1",
156
+ "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz",
157
+ "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==",
158
+ "requires": {
159
+ "bn.js": "^4.0.0",
160
+ "inherits": "^2.0.1",
161
+ "minimalistic-assert": "^1.0.0"
162
+ }
163
+ },
164
+ "asn1js": {
165
+ "version": "2.0.22",
166
+ "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-2.0.22.tgz",
167
+ "integrity": "sha512-mKox8OHPmLZY0FUbd8JYsAu2lQk61yFH8gTq4N7AT7NzmUKISpy0LEjV/AfLyE/SNCUicdMDZUFbocsf/9qOTg==",
168
+ "requires": {
169
+ "pvutils": "^1.0.17"
170
+ }
171
+ },
172
"assert-plus": {
173
"version": "1.0.0",
174
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
@@ -146,6 +214,11 @@
214
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
215
"integrity": "sha1-yrHmEY8FEJXli1KBrqjBzSK/wOM="
216
},
217
+ "base64url": {
218
+ "version": "3.0.1",
219
+ "resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz",
220
+ "integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A=="
221
+ },
222
"bcrypt-pbkdf": {
223
"version": "1.0.2",
224
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
@@ -154,6 +227,11 @@
227
"tweetnacl": "^0.14.3"
228
}
229
},
230
+ "bignumber.js": {
231
+ "version": "8.1.1",
232
+ "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-8.1.1.tgz",
233
+ "integrity": "sha512-QD46ppGintwPGuL1KqmwhR0O+N2cZUg8JG/VzwI2e28sM9TqHjQB10lI4QAaMHVbLzwVLLAwEglpKPViWX+5NQ=="
234
+ },
235
"binary-search-tree": {
236
"version": "0.2.5",
237
"resolved": "https://registry.npmjs.org/binary-search-tree/-/binary-search-tree-0.2.5.tgz",
@@ -171,6 +249,11 @@
249
"safe-buffer": "^5.1.1"
250
}
251
},
252
+ "bn.js": {
253
+ "version": "4.11.8",
254
+ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
255
+ "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA=="
256
+ },
257
"body-parser": {
258
"version": "1.18.2",
259
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz",
@@ -243,10 +326,15 @@
326
"concat-map": "0.0.1"
327
}
328
},
329
+ "brorand": {
330
+ "version": "1.1.0",
331
+ "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
332
+ "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8="
333
+ },
334
"bson": {
335
"version": "1.0.9",
336
"resolved": "https://registry.npmjs.org/bson/-/bson-1.0.9.tgz",
249
- "integrity": "sha1-EjGfgyOxJUc5t8a++NPomuBaL1c="
337
+ "integrity": "sha512-IQX9/h7WdMBIW/q/++tGd+emQr0XMdeZ6icnT/74Xk9fnabWn+gZgpE+9V+gujL3hhJOoNrnDVY7tWdzc7NUTg=="
338
},
339
"buffer": {
340
"version": "5.2.1",
@@ -291,6 +379,11 @@
379
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
380
"integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg="
381
},
382
+ "bytestreamjs": {
383
+ "version": "1.0.27",
384
+ "resolved": "https://registry.npmjs.org/bytestreamjs/-/bytestreamjs-1.0.27.tgz",
385
+ "integrity": "sha512-P3eEIZi2olI+lgb7RpGRluJdGoDdSzh0A9hmNP4s7YHiuuw1KRKARxmkdDkDhQCGmV14OVkieTmE/F1/roxiWg=="
386
+ },
387
"camelcase": {
388
"version": "1.2.1",
389
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
@@ -302,6 +395,17 @@
395
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
396
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
397
},
398
+ "cbor": {
399
+ "version": "4.1.5",
400
+ "resolved": "https://registry.npmjs.org/cbor/-/cbor-4.1.5.tgz",
401
+ "integrity": "sha512-WqpISHl7/kk1u1uoaqctGyGiET3+wGN4A6pPsFCzEBztJJlCVxnMB4JwcuuNSrMiV4V6UBlxMkhNzJrUxDWO1A==",
402
+ "requires": {
403
+ "bignumber.js": "^8.0.2",
404
+ "commander": "^2.19.0",
405
+ "json-text-sequence": "^0.1",
406
+ "nofilter": "^1.0.1"
407
+ }
408
+ },
409
"center-align": {
410
"version": "0.1.3",
411
"resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz",
@@ -339,6 +443,11 @@
443
"delayed-stream": "~1.0.0"
444
}
445
},
446
+ "commander": {
447
+ "version": "2.19.0",
448
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz",
449
+ "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg=="
450
+ },
451
"compress-commons": {
452
"version": "1.2.2",
453
"resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-1.2.2.tgz",
@@ -502,6 +611,14 @@
611
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
612
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
613
},
614
+ "cose-to-jwk": {
615
+ "version": "1.1.0",
616
+ "resolved": "https://registry.npmjs.org/cose-to-jwk/-/cose-to-jwk-1.1.0.tgz",
617
+ "integrity": "sha512-DbR/XPptfo+kcoA77jWPTe4JS0MrpOXAg0sgVr2FeZMnTGGpppOL072e2hgPHTVbSoMkt5l0qDv/k2xCn+79Cg==",
618
+ "requires": {
619
+ "cbor": "^4.0.0"
620
+ }
621
+ },
622
"crc": {
623
"version": "3.8.0",
624
"resolved": "https://registry.npmjs.org/crc/-/crc-3.8.0.tgz",
@@ -555,6 +672,11 @@
672
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
673
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
674
},
675
+ "delimit-stream": {
676
+ "version": "0.1.0",
677
+ "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz",
678
+ "integrity": "sha1-m4MZR3wOX4rrPONXrjBfwl6hzSs="
679
+ },
680
"depd": {
681
"version": "1.1.2",
682
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
@@ -589,6 +711,20 @@
711
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
712
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
713
},
714
+ "elliptic": {
715
+ "version": "6.4.1",
716
+ "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",
717
+ "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==",
718
+ "requires": {
719
+ "bn.js": "^4.4.0",
720
+ "brorand": "^1.0.1",
721
+ "hash.js": "^1.0.0",
722
+ "hmac-drbg": "^1.0.0",
723
+ "inherits": "^2.0.1",
724
+ "minimalistic-assert": "^1.0.0",
725
+ "minimalistic-crypto-utils": "^1.0.0"
726
+ }
727
+ },
728
"encodeurl": {
729
"version": "1.0.2",
730
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
@@ -907,12 +1043,23 @@
1043
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz",
1044
"integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q="
1045
},
910
- "heapdump": {
911
- "version": "0.3.12",
912
- "resolved": "https://registry.npmjs.org/heapdump/-/heapdump-0.3.12.tgz",
913
- "integrity": "sha512-OSVdkxGd9xAJNEP0RA/ZvKEzGTEjCnkvmMEGF1ScR/87tH92v5Dpv6g/Fs8GvZA9UxdMpxU1G9NEC2D0OxZjJQ==",
1046
+ "hash.js": {
1047
+ "version": "1.1.7",
1048
+ "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz",
1049
+ "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==",
1050
+ "requires": {
1051
+ "inherits": "^2.0.3",
1052
+ "minimalistic-assert": "^1.0.1"
1053
+ }
1054
+ },
1055
+ "hmac-drbg": {
1056
+ "version": "1.0.1",
1057
+ "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
1058
+ "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=",
1059
"requires": {
915
- "nan": "^2.11.1"
1060
+ "hash.js": "^1.0.3",
1061
+ "minimalistic-assert": "^1.0.0",
1062
+ "minimalistic-crypto-utils": "^1.0.1"
1063
}
1064
},
1065
"http-errors": {
@@ -1045,6 +1192,14 @@
1192
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
1193
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
1194
},
1195
+ "json-text-sequence": {
1196
+ "version": "0.1.1",
1197
+ "resolved": "https://registry.npmjs.org/json-text-sequence/-/json-text-sequence-0.1.1.tgz",
1198
+ "integrity": "sha1-py8hfcSvxGKf/1/rME3BvVGi89I=",
1199
+ "requires": {
1200
+ "delimit-stream": "0.1.0"
1201
+ }
1202
+ },
1203
"jsprim": {
1204
"version": "1.4.1",
1205
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
@@ -1056,6 +1211,16 @@
1211
"verror": "1.10.0"
1212
}
1213
},
1214
+ "jwk-to-pem": {
1215
+ "version": "2.0.1",
1216
+ "resolved": "https://registry.npmjs.org/jwk-to-pem/-/jwk-to-pem-2.0.1.tgz",
1217
+ "integrity": "sha512-KKu0WuDDjqw2FlRFp9/vk9TMO/KvgpZVKzdhhYcNyy5OwE8dw9lOK5OQTQHIJ7m+HioI/4P44sAtVuDrQ8KQfw==",
1218
+ "requires": {
1219
+ "asn1.js": "^4.5.2",
1220
+ "elliptic": "^6.2.3",
1221
+ "safe-buffer": "^5.0.1"
1222
+ }
1223
+ },
1224
"keygrip": {
1225
"version": "1.0.2",
1226
"resolved": "https://registry.npmjs.org/keygrip/-/keygrip-1.0.2.tgz",
@@ -1140,6 +1305,11 @@
1305
"resolved": "https://registry.npmjs.org/lodash.union/-/lodash.union-4.6.0.tgz",
1306
"integrity": "sha1-SLtQiECfFvGCFmZkHETdGqrjzYg="
1307
},
1308
+ "long": {
1309
+ "version": "4.0.0",
1310
+ "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
1311
+ "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
1312
+ },
1313
"longest": {
1314
"version": "1.0.1",
1315
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
@@ -1179,6 +1349,16 @@
1349
"mime-db": "~1.37.0"
1350
}
1351
},
1352
+ "minimalistic-assert": {
1353
+ "version": "1.0.1",
1354
+ "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
1355
+ "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A=="
1356
+ },
1357
+ "minimalistic-crypto-utils": {
1358
+ "version": "1.0.1",
1359
+ "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz",
1360
+ "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo="
1361
+ },
1362
"minimatch": {
1363
"version": "3.0.4",
1364
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
@@ -1210,7 +1390,7 @@
1390
"mongodb": {
1391
"version": "2.2.36",
1392
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.36.tgz",
1213
- "integrity": "sha1-HFc2gLKEn7D0esu6PcX6Io3pdfU=",
1393
+ "integrity": "sha512-P2SBLQ8Z0PVx71ngoXwo12+FiSfbNfGOClAao03/bant5DgLNkOPAck5IaJcEk4gKlQhDEURzfR3xuBG1/B+IA==",
1394
"requires": {
1395
"es6-promise": "3.2.1",
1396
"mongodb-core": "2.1.20",
@@ -1239,7 +1419,7 @@
1419
"string_decoder": {
1420
"version": "1.0.3",
1421
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
1242
- "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=",
1422
+ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
1423
"requires": {
1424
"safe-buffer": "~5.1.0"
1425
}
@@ -1249,7 +1429,7 @@
1429
"mongodb-core": {
1430
"version": "2.1.20",
1431
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.20.tgz",
1252
- "integrity": "sha1-/s6N12tZ7n1/LTE7ZTIsFgSS2PE=",
1432
+ "integrity": "sha512-IN57CX5/Q1bhDq6ShAR6gIv4koFsZP7L8WOK1S0lR0pVDQaScffSMV5jxubLsmZ7J+UdqmykKw4r9hG3XQEGgQ==",
1433
"requires": {
1434
"bson": "~1.0.4",
1435
"require_optional": "~1.0.0"
@@ -1258,7 +1438,7 @@
1438
"mongojs": {
1439
"version": "2.6.0",
1440
"resolved": "https://registry.npmjs.org/mongojs/-/mongojs-2.6.0.tgz",
1261
- "integrity": "sha1-Mz9YBiGg3GSACGXjjjam5h/xaYk=",
1441
+ "integrity": "sha512-r6tj71DjYcaRTi2jpa+CA6Iq72cTZclB2JKy+Zub+0JPTEq/l2plsAYfF2eHqSYBtZbKNcObvhGYk9E9UKZWJg==",
1442
"requires": {
1443
"each-series": "^1.0.0",
1444
"mongodb": "^2.2.31",
@@ -1318,11 +1498,6 @@
1498
}
1499
}
1500
},
1321
- "nan": {
1322
- "version": "2.11.1",
1323
- "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz",
1324
- "integrity": "sha1-kOIrzLjKV+pM03zIPTgZtS7qZ2Y="
1325
- },
1501
"nedb": {
1502
"version": "1.8.0",
1503
"resolved": "https://registry.npmjs.org/nedb/-/nedb-1.8.0.tgz",
@@ -1345,6 +1520,31 @@
1520
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.6.tgz",
1521
"integrity": "sha512-sol30LUpz1jQFBjOKwbjxijiE3b6pjd74YwfD0fJOKPjF+fONKb2Yg8rYgS6+bK6VDl+/wfr4IYpC7jDzLUIfw=="
1522
},
1523
+ "node-jose": {
1524
+ "version": "1.1.3",
1525
+ "resolved": "https://registry.npmjs.org/node-jose/-/node-jose-1.1.3.tgz",
1526
+ "integrity": "sha512-kupfi4uGWhRjnOmtie2T64cLge5a1TZyalEa8uWWWBgtKBcu41A4IGKpI9twZAxRnmviamEUQRK7LSyfFb2w8A==",
1527
+ "requires": {
1528
+ "base64url": "^3.0.1",
1529
+ "es6-promise": "^4.2.6",
1530
+ "lodash": "^4.17.11",
1531
+ "long": "^4.0.0",
1532
+ "node-forge": "^0.8.1",
1533
+ "uuid": "^3.3.2"
1534
+ },
1535
+ "dependencies": {
1536
+ "es6-promise": {
1537
+ "version": "4.2.6",
1538
+ "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz",
1539
+ "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q=="
1540
+ },
1541
+ "node-forge": {
1542
+ "version": "0.8.2",
1543
+ "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.8.2.tgz",
1544
+ "integrity": "sha512-mXQ9GBq1N3uDCyV1pdSzgIguwgtVpM7f5/5J4ipz12PKWElmPpVWLDuWl8iXmhysr21+WmX/OJ5UKx82wjomgg=="
1545
+ }
1546
+ }
1547
+ },
1548
"node-windows": {
1549
"version": "0.1.14",
1550
"resolved": "https://registry.npmjs.org/node-windows/-/node-windows-0.1.14.tgz",
@@ -1354,6 +1554,11 @@
1554
"xml": "0.0.12"
1555
}
1556
},
1557
+ "nofilter": {
1558
+ "version": "1.0.2",
1559
+ "resolved": "https://registry.npmjs.org/nofilter/-/nofilter-1.0.2.tgz",
1560
+ "integrity": "sha512-d38SORxm9UNoDsnPXajV9nBEebKX4/paXAlyRGnSjZuFbLLZDFUO4objr+tbybqsbqGXDWllb6gQoKUDc9q3Cg=="
1561
+ },
1562
"normalize-path": {
1563
"version": "3.0.0",
1564
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@@ -1464,6 +1669,26 @@
1669
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
1670
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
1671
},
1672
+ "pkijs": {
1673
+ "version": "2.1.58",
1674
+ "resolved": "https://registry.npmjs.org/pkijs/-/pkijs-2.1.58.tgz",
1675
+ "integrity": "sha512-HEcJ4SbZNdyB7Jb1G7Ot3Y/gd7kZyTDJBMIIZOFselrKrCouhGbQu4rm9Lg8bumBACckq724G9uNsZbNJ6d2gw==",
1676
+ "requires": {
1677
+ "asn1js": "^2.0.22",
1678
+ "bytestreamjs": "^1.0.27",
1679
+ "pvutils": "^1.0.17"
1680
+ },
1681
+ "dependencies": {
1682
+ "asn1js": {
1683
+ "version": "2.0.22",
1684
+ "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-2.0.22.tgz",
1685
+ "integrity": "sha512-mKox8OHPmLZY0FUbd8JYsAu2lQk61yFH8gTq4N7AT7NzmUKISpy0LEjV/AfLyE/SNCUicdMDZUFbocsf/9qOTg==",
1686
+ "requires": {
1687
+ "pvutils": "^1.0.17"
1688
+ }
1689
+ }
1690
+ }
1691
+ },
1692
"process-nextick-args": {
1693
"version": "2.0.0",
1694
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
@@ -1496,6 +1721,20 @@
1721
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
1722
"integrity": "sha1-tYsBCsQMIsVldhbI0sLALHv0eew="
1723
},
1724
+ "pvtsutils": {
1725
+ "version": "1.0.4",
1726
+ "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.0.4.tgz",
1727
+ "integrity": "sha512-lBDyLfPIWZjxHr6Nnl83/iaZgVLczDcpEqWdqRnghzBKXifRU/7D5T6JPYWUAm0sJdFeF9+sNTKto6dj/3P/Kg==",
1728
+ "requires": {
1729
+ "@types/node": "^10.12.15",
1730
+ "tslib": "^1.9.3"
1731
+ }
1732
+ },
1733
+ "pvutils": {
1734
+ "version": "1.0.17",
1735
+ "resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.0.17.tgz",
1736
+ "integrity": "sha512-wLHYUQxWaXVQvKnwIDWFVKDJku9XDCvyhhxoq8dc5MFdIlRenyPI9eSfEtcvgHgD7FlvCyGAlWgOzRnZD99GZQ=="
1737
+ },
1738
"qs": {
1739
"version": "6.5.2",
1740
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
@@ -1604,7 +1843,7 @@
1843
"require_optional": {
1844
"version": "1.0.1",
1845
"resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
1607
- "integrity": "sha1-TPNaQkf2TKPfjC7yCMxJSxyo/C4=",
1846
+ "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==",
1847
"requires": {
1848
"resolve-from": "^2.0.0",
1849
"semver": "^5.1.0"
@@ -1637,7 +1876,7 @@
1876
"semver": {
1877
"version": "5.6.0",
1878
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
1640
- "integrity": "sha1-fnQlb7qknHWqfHogXMInmcrIAAQ="
1879
+ "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg=="
1880
},
1881
"send": {
1882
"version": "0.16.2",
@@ -1734,7 +1973,7 @@
1973
"thunky": {
1974
"version": "1.0.3",
1975
"resolved": "https://registry.npmjs.org/thunky/-/thunky-1.0.3.tgz",
1737
- "integrity": "sha1-9d9zJFNAewkZHa5z4qjMc/OBqCY="
1976
+ "integrity": "sha512-YwT8pjmNcAXBZqrubu22P4FYsh2D4dxRmnWBOL8Jk8bUcRUtc5326kx32tuTmFDAZtLOGEVNl8POAR8j896Iow=="
1977
},
1978
"to-buffer": {
1979
"version": "1.1.1",
@@ -1767,6 +2006,11 @@
2006
}
2007
}
2008
},
2009
+ "tslib": {
2010
+ "version": "1.9.3",
2011
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
2012
+ "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
2013
+ },
2014
"tunnel-agent": {
2015
"version": "0.6.0",
2016
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
@@ -1879,6 +2123,15 @@
2123
"extsprintf": "^1.2.0"
2124
}
2125
},
2126
+ "webcrypto-core": {
2127
+ "version": "1.0.11",
2128
+ "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.0.11.tgz",
2129
+ "integrity": "sha512-cHxOMKNzRkPlCcQyGTuyaZmAVZlbby0lH9ASaFk5w8x/i3Q809sISA28AMVnkebW2ekcQ2+UtdaVBFUf58xjyA==",
2130
+ "requires": {
2131
+ "pvtsutils": "^1.0.3",
2132
+ "tslib": "^1.9.3"
2133
+ }
2134
+ },
2135
"window-size": {
2136
"version": "0.1.0",
2137
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz",
package.json
-2
@@ -41,9 +41,7 @@
41
"multiparty": "^4.2.1",
42
"nedb": "^1.8.0",
43
"node-forge": "^0.7.6",
44
- "nodemailer": "^5.1.1",
44
"otplib": "^10.0.1",
46
- "util.promisify": "^1.0.0",
45
"ws": "^6.1.2",
46
"xmldom": "^0.1.27",
47
"yauzl": "^2.10.0",
views/default.handlebars
+3
-3
@@ -1494,9 +1494,9 @@
1494
}
1495
x += "</div>";
1496
x += "<div><input type=button value='Close' onclick=setDialogMode(0) style=float:right></input>";
1497
- x += "<input id=d2addkey1 type=button value='Add U2F Key' onclick='account_addhkey(1);'></input>";
1498
- if ((features & 0x4000) != 0) { x += "<input id=d2addkey2 type=button value='Add OTP Key' onclick='account_addhkey(2);'></input>"; }
1499
- x += "<input id=d2addkey3 type=button value='Add FIDO2 Key' onclick='account_addhkey(3);'></input>";
1497
+ if ((features & 0x00020000) == 0) { x += "<input id=d2addkey1 type=button value='Add Key' onclick='account_addhkey(1);'></input>"; }
1498
+ if ((features & 0x00020000) != 0) { x += "<input id=d2addkey3 type=button value='Add Key' onclick='account_addhkey(3);'></input>"; }
1499
+ if ((features & 0x00004000) != 0) { x += "<input id=d2addkey2 type=button value='Add YubiKey® OTP' onclick='account_addhkey(2);'></input>"; }
1500
x += "</div><br />";
1501
setDialogMode(2, "Manage Security Keys", 8, null, x, 'otpauth-hardware-manage');
1502
if (u2fSupported() == false) { QE('d2addkey1', false); }
webserver.js
+9
-7
@@ -61,12 +61,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
61
obj.interceptor = require('./interceptor');
62
const constants = (obj.crypto.constants ? obj.crypto.constants : require('constants')); // require('constants') is deprecated in Node 11.10, use require('crypto').constants instead.
63
64
- // Setup WebAuthn, this is an optional install.
65
- // "npm install @davedoesdev/fido2-lib"
66
- try {
67
- const { Fido2Lib } = require("@davedoesdev/fido2-lib");
68
- obj.f2l = new Fido2Lib({ attestation: "none" });
69
- } catch (ex) { console.log(ex); }
64
+ // Setup WebAuthn / FIDO2
65
+ try { const { Fido2Lib } = require("@davedoesdev/fido2-lib"); obj.f2l = new Fido2Lib({ attestation: "none" }); } catch (ex) { console.log(ex); }
66
67
// Variables
68
obj.parent = parent;
@@ -365,9 +361,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
361
362
// If we found a valid key to use, let's validate the response
363
if (webAuthnKey != null) {
364
+ // Figure out the origin
365
+ var httpport = ((args.aliasport != null) ? args.aliasport : args.port);
366
+ var origin = "https://" + (domain.dns ? domain.dns : parent.certificates.CommonName);
367
+ if (httpport != 443) { origin += ':' + httpport; }
368
+
369
var assertionExpectations = {
370
challenge: req.session.u2fchallenge,
370
- origin: "https://devbox.mesh.meshcentral.com",
371
+ origin: origin,
372
factor: "either",
373
publicKey: webAuthnKey.publicKey,
374
prevCounter: webAuthnKey.counter,
@@ -1160,6 +1161,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1161
if (domain.yubikey && domain.yubikey.id && domain.yubikey.secret) { features += 0x00004000; } // Indicates Yubikey support
1162
if (domain.geolocation == true) { features += 0x00008000; } // Enable geo-location features
1163
if ((domain.passwordrequirements != null) && (domain.passwordrequirements.hint === true)) { features += 0x00010000; } // Enable password hints
1164
+ if (obj.f2l != null) { features += 0x00020000; } // Enable WebAuthn/FIDO2 support
1165
1166
// Create a authentication cookie
1167
const authCookie = obj.parent.encodeCookie({ userid: user._id, domainid: domain.id }, obj.parent.loginCookieEncryptionKey);