Fixed 2FA when in LAN mode.
Ylian Saint-Hilaire committed
Aug 22, 2019 at 17:05 UTC
9e4b21bb60b69318088a06b9973536cc68b2e388
4 files changed
+11
-144
agents/modules_meshcore/linux-dbus.js
deleted
-128
@@ -1,128 +0,0 @@
1
-/*
2
-Copyright 2018-2019 Intel Corporation
3
-
4
-Licensed under the Apache License, Version 2.0 (the "License");
5
-you may not use this file except in compliance with the License.
6
-You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
-Unless required by applicable law or agreed to in writing, software
11
-distributed under the License is distributed on an "AS IS" BASIS,
12
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
-See the License for the specific language governing permissions and
14
-limitations under the License.
15
-*/
16
-
17
-try { Object.defineProperty(Array.prototype, "peek", { value: function () { return (this.length > 0 ? this[this.length - 1] : undefined); } }); } catch (e) { }
18
-
19
-
20
-
21
-function dbus(address, uid)
22
-{
23
- this._ObjectID = 'linux-dbus';
24
- require('events').EventEmitter.call(this, true)
25
- .createEvent('signal');
26
- Object.defineProperty(this, "uid", { value: uid });
27
- this._child = require('child_process').execFile("/bin/sh", ["sh"], { type: require('child_process').SpawnTypes.TERM, uid: uid == null ? -1 : uid });
28
- this._child.stdin.write('dbus-monitor --session "type=\'signal\', interface=\'' + address + '\'" | ( while read X; do echo "$X"; done )\n');
29
- this._child.stdout.dbus = this;
30
- this._child.stdout.on('data', function (chunk)
31
- {
32
- // Parse DBUS Data
33
- if (!this.ready) { this.ready = true; return; }
34
-
35
- var lines = [];
36
- var tokens = chunk.toString().split('\r\n');
37
- for (var i in tokens)
38
- {
39
- if (tokens[i] == '')
40
- {
41
- // End of record
42
- this.dbus.preParseRecords(lines);
43
- lines = [];
44
- }
45
- else
46
- {
47
- lines.push(tokens[i]);
48
- }
49
- }
50
- });
51
- this.preParseRecords = function (lines)
52
- {
53
- var record = [];
54
- for (var i in lines)
55
- {
56
- if(lines[i].startsWith('signal '))
57
- {
58
- if(record.length>0)
59
- {
60
- this.parseRecords(record);
61
- }
62
- record = [];
63
- }
64
- record.push(lines[i]);
65
- }
66
- if (record.length > 0)
67
- {
68
- this.parseRecords(record);
69
- }
70
- }
71
- this.parseRecords = function (lines)
72
- {
73
- if (lines[0].startsWith('signal '))
74
- {
75
- var signal = {};
76
- var sigtokens = lines[0].split(' ');
77
- sigtokens.shift();
78
-
79
- for (var i in sigtokens) {
80
- var sigitems = sigtokens[i].split('=');
81
- if (sigitems.length == 2) {
82
- signal[sigitems[0]] = sigitems[1];
83
- }
84
- }
85
-
86
- lines.shift();
87
- signal.data = lines;
88
-
89
- this.parseSignal(signal);
90
- }
91
- }
92
- this.parseSignal = function(signal)
93
- {
94
- var data = signal.data;
95
- signal.data = [];
96
-
97
- for(var i=0; i<data.length; ++i)
98
- {
99
- if (data[i].startsWith('array '))
100
- {
101
- signal.data.push([]);
102
- for(i=i+1; i<data.length; ++i)
103
- {
104
- this.parseSignal2(data[i], signal.data.peek());
105
- }
106
- }
107
- else
108
- {
109
- this.parseSignal2(data[i], signal.data);
110
- }
111
- }
112
-
113
- this.emit('signal', signal);
114
- }
115
- this.parseSignal2 = function (inputStr, outArray)
116
- {
117
- if(inputStr.startsWith('string '))
118
- {
119
- outArray.push(JSON.parse(inputStr.slice(7)));
120
- }
121
- else if(inputStr.startsWith('boolean '))
122
- {
123
- outArray.push(JSON.parse(inputStr.slice(8)));
124
- }
125
- }
126
-}
127
-
128
-module.exports = dbus;
agents/modules_meshcore_min/linux-dbus.min.js
deleted
-1
@@ -1 +0,0 @@
1
-try{Object.defineProperty(Array.prototype,"peek",{value:function(){return(this.length>0?this[this.length-1]:undefined)}})}catch(e){}function dbus(a,b){this._ObjectID="linux-dbus";require("events").EventEmitter.call(this,true).createEvent("signal");Object.defineProperty(this,"uid",{value:b});this._child=require("child_process").execFile("/bin/sh",["sh"],{type:require("child_process").SpawnTypes.TERM,uid:b==null?-1:b});this._child.stdin.write("dbus-monitor --session \"type='signal', interface='"+a+'\'" | ( while read X; do echo "$X"; done )\n');this._child.stdout.dbus=this;this._child.stdout.on("data",function(c){if(!this.ready){this.ready=true;return}var f=[];var g=c.toString().split("\r\n");for(var d in g){if(g[d]==""){this.dbus.preParseRecords(f);f=[]}else{f.push(g[d])}}});this.preParseRecords=function(d){var f=[];for(var c in d){if(d[c].startsWith("signal ")){if(f.length>0){this.parseRecords(f)}f=[]}f.push(d[c])}if(f.length>0){this.parseRecords(f)}};this.parseRecords=function(d){if(d[0].startsWith("signal ")){var g={};var h=d[0].split(" ");h.shift();for(var c in h){var f=h[c].split("=");if(f.length==2){g[f[0]]=f[1]}}d.shift();g.data=d;this.parseSignal(g)}};this.parseSignal=function(f){var c=f.data;f.data=[];for(var d=0;d<c.length;++d){if(c[d].startsWith("array ")){f.data.push([]);for(d=d+1;d<c.length;++d){this.parseSignal2(c[d],f.data.peek())}}else{this.parseSignal2(c[d],f.data)}}this.emit("signal",f)};this.parseSignal2=function(c,d){if(c.startsWith("string ")){d.push(JSON.parse(c.slice(7)))}else{if(c.startsWith("boolean ")){d.push(JSON.parse(c.slice(8)))}}}}module.exports=dbus;
\ No newline at end of file
meshuser.js
+10
-14
@@ -2376,7 +2376,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2376
case 'otpauth-request':
2377
{
2378
// Check is 2-step login is supported
2379
- const twoStepLoginSupported = ((domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.lanonly !== true) && (args.nousers !== true));
2379
+ const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
2380
if (twoStepLoginSupported) {
2381
// Request a one time password to be setup
2382
var otplib = null;
@@ -2390,7 +2390,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2390
case 'otpauth-setup':
2391
{
2392
// Check is 2-step login is supported
2393
- const twoStepLoginSupported = ((domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.lanonly !== true) && (args.nousers !== true));
2393
+ const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
2394
if (twoStepLoginSupported) {
2395
// Perform the one time password setup
2396
var otplib = null;
@@ -2418,7 +2418,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2418
case 'otpauth-clear':
2419
{
2420
// Check is 2-step login is supported
2421
- const twoStepLoginSupported = ((domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.lanonly !== true) && (args.nousers !== true));
2421
+ const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
2422
if (twoStepLoginSupported) {
2423
// Clear the one time password secret
2424
if (user.otpsecret) {
@@ -2441,7 +2441,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2441
case 'otpauth-getpasswords':
2442
{
2443
// Check is 2-step login is supported
2444
- const twoStepLoginSupported = ((domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.lanonly !== true) && (args.nousers !== true));
2444
+ const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
2445
if (twoStepLoginSupported == false) break;
2446
2447
// Perform a sub-action
@@ -2476,7 +2476,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2476
case 'otp-hkey-get':
2477
{
2478
// Check is 2-step login is supported
2479
- const twoStepLoginSupported = ((domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.lanonly !== true) && (args.nousers !== true));
2479
+ const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
2480
if (twoStepLoginSupported == false) break;
2481
2482
// Send back the list of keys we have, just send the list of names and index
@@ -2489,7 +2489,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2489
case 'otp-hkey-remove':
2490
{
2491
// Check is 2-step login is supported
2492
- const twoStepLoginSupported = ((domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.lanonly !== true) && (args.nousers !== true));
2492
+ const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
2493
if (twoStepLoginSupported == false || command.index == null) break;
2494
2495
// Remove a key
@@ -2510,14 +2510,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2510
}
2511
case 'otp-hkey-yubikey-add':
2512
{
2513
- if (parent.parent.config.settings.no2factorauth === true) return;
2514
-
2513
// Yubico API id and signature key can be requested from https://upgrade.yubico.com/getapikey/
2514
var yubikeyotp = null;
2515
try { yubikeyotp = require('yubikeyotp'); } catch (ex) { }
2516
2517
// Check is 2-step login is supported
2520
- const twoStepLoginSupported = ((domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.lanonly !== true) && (args.nousers !== true));
2518
+ const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
2519
if ((yubikeyotp == null) || (twoStepLoginSupported == false) || (typeof command.otp != 'string')) {
2520
ws.send(JSON.stringify({ action: 'otp-hkey-yubikey-add', result: false, name: command.name }));
2521
break;
@@ -2565,10 +2563,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2563
}
2564
case 'webauthn-startregister':
2565
{
2568
- if (parent.parent.config.settings.no2factorauth === true) return;
2569
-
2566
// Check is 2-step login is supported
2571
- const twoStepLoginSupported = ((domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.lanonly !== true) && (args.nousers !== true));
2567
+ const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
2568
if ((twoStepLoginSupported == false) || (command.name == null)) break;
2569
2570
// Send the registration request
@@ -2579,8 +2575,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2575
}
2576
case 'webauthn-endregister':
2577
{
2582
- if (parent.parent.config.settings.no2factorauth === true) return;
2583
- if (obj.webAuthnReqistrationRequest == null) return;
2578
+ const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
2579
+ if ((twoStepLoginSupported == false) || (obj.webAuthnReqistrationRequest == null)) return;
2580
2581
// Figure out the origin
2582
var httpport = ((args.aliasport != null) ? args.aliasport : args.port);
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.4.0-e",
3
+ "version": "0.4.0-f",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",