@node-red/editor-api 4.0.0-beta.3-1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth/index.js +23 -13
- package/lib/auth/permissions.js +2 -2
- package/lib/auth/users.js +7 -7
- package/lib/editor/theme.js +1 -1
- package/package.json +8 -8
package/lib/auth/index.js
CHANGED
|
@@ -160,20 +160,30 @@ function completeVerify(profile,done) {
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
function genericStrategy(adminApp,strategy) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
const crypto = require("crypto")
|
|
164
|
+
const session = require('express-session')
|
|
165
|
+
const MemoryStore = require('memorystore')(session)
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
167
|
+
const sessionOptions = {
|
|
168
|
+
// As the session is only used across the life-span of an auth
|
|
169
|
+
// hand-shake, we can use a instance specific random string
|
|
170
|
+
secret: crypto.randomBytes(20).toString('hex'),
|
|
171
|
+
resave: false,
|
|
172
|
+
saveUninitialized: false,
|
|
173
|
+
store: new MemoryStore({
|
|
174
|
+
checkPeriod: 86400000 // prune expired entries every 24h
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
if (settings.httpAdminCookieOptions) {
|
|
178
|
+
sessionOptions.cookie = {
|
|
179
|
+
path: '/',
|
|
180
|
+
httpOnly: true,
|
|
181
|
+
secure: false,
|
|
182
|
+
maxAge: null,
|
|
183
|
+
...settings.httpAdminCookieOptions
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
adminApp.use(session(sessionOptions));
|
|
177
187
|
//TODO: all passport references ought to be in ./auth
|
|
178
188
|
adminApp.use(passport.initialize());
|
|
179
189
|
adminApp.use(passport.session());
|
package/lib/auth/permissions.js
CHANGED
|
@@ -25,7 +25,7 @@ function hasPermission(userScope,permission) {
|
|
|
25
25
|
}
|
|
26
26
|
var i;
|
|
27
27
|
|
|
28
|
-
if (
|
|
28
|
+
if (Array.isArray(permission)) {
|
|
29
29
|
// Multiple permissions requested - check each one
|
|
30
30
|
for (i=0;i<permission.length;i++) {
|
|
31
31
|
if (!hasPermission(userScope,permission[i])) {
|
|
@@ -36,7 +36,7 @@ function hasPermission(userScope,permission) {
|
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
if (
|
|
39
|
+
if (Array.isArray(userScope)) {
|
|
40
40
|
if (userScope.length === 0) {
|
|
41
41
|
return false;
|
|
42
42
|
}
|
package/lib/auth/users.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
var util = require("util");
|
|
18
18
|
var clone = require("clone");
|
|
19
19
|
var bcrypt;
|
|
20
|
-
try { bcrypt = require('bcrypt'); }
|
|
20
|
+
try { bcrypt = require('@node-rs/bcrypt'); }
|
|
21
21
|
catch(e) { bcrypt = require('bcryptjs'); }
|
|
22
22
|
var users = {};
|
|
23
23
|
var defaultUser = null;
|
|
@@ -33,11 +33,11 @@ function authenticate() {
|
|
|
33
33
|
if (args.length === 2) {
|
|
34
34
|
// Username/password authentication
|
|
35
35
|
var password = args[1];
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
36
|
+
return bcrypt.compare(password, user.password).then(res => {
|
|
37
|
+
return res ? cleanUser(user) : null
|
|
38
|
+
}).catch(err => {
|
|
39
|
+
return null
|
|
40
|
+
})
|
|
41
41
|
} else {
|
|
42
42
|
// Try to extract common profile information
|
|
43
43
|
if (args[0].hasOwnProperty('photos') && args[0].photos.length > 0) {
|
|
@@ -74,7 +74,7 @@ function init(config) {
|
|
|
74
74
|
} else {
|
|
75
75
|
var us = config.users;
|
|
76
76
|
/* istanbul ignore else */
|
|
77
|
-
if (!
|
|
77
|
+
if (!Array.isArray(us)) {
|
|
78
78
|
us = [us];
|
|
79
79
|
}
|
|
80
80
|
for (var i=0;i<us.length;i++) {
|
package/lib/editor/theme.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-red/editor-api",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -16,25 +16,25 @@
|
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@node-red/util": "4.0.0
|
|
20
|
-
"@node-red/editor-client": "4.0.0
|
|
19
|
+
"@node-red/util": "4.0.0",
|
|
20
|
+
"@node-red/editor-client": "4.0.0",
|
|
21
21
|
"bcryptjs": "2.4.3",
|
|
22
22
|
"body-parser": "1.20.2",
|
|
23
23
|
"clone": "2.1.2",
|
|
24
24
|
"cors": "2.8.5",
|
|
25
|
-
"express-session": "1.
|
|
25
|
+
"express-session": "1.18.0",
|
|
26
26
|
"express": "4.19.2",
|
|
27
27
|
"memorystore": "1.6.7",
|
|
28
28
|
"mime": "3.0.0",
|
|
29
29
|
"multer": "1.4.5-lts.1",
|
|
30
30
|
"mustache": "4.2.0",
|
|
31
|
-
"oauth2orize": "1.
|
|
31
|
+
"oauth2orize": "1.12.0",
|
|
32
32
|
"passport-http-bearer": "1.0.1",
|
|
33
33
|
"passport-oauth2-client-password": "0.1.2",
|
|
34
|
-
"passport": "0.
|
|
35
|
-
"ws": "7.5.
|
|
34
|
+
"passport": "0.7.0",
|
|
35
|
+
"ws": "7.5.10"
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"bcrypt": "
|
|
38
|
+
"@node-rs/bcrypt": "1.10.4"
|
|
39
39
|
}
|
|
40
40
|
}
|