cloudcms-server 3.2.321 → 3.2.324
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/README.md +1 -7
- package/index.js +0 -17
- package/middleware/authentication/authentication.js +0 -5
- package/middleware/authentication/providers/saml.js +8 -4
- package/middleware/config/adapter.js +0 -44
- package/middleware/deployment/deployment.js +0 -10
- package/middleware/registration/registration.js +0 -5
- package/middleware/stores/engines/empty.js +0 -4
- package/middleware/stores/engines/fs-caching-adapter.js +0 -5
- package/middleware/stores/engines/fs.js +0 -9
- package/middleware/stores/engines/s3.js +0 -5
- package/middleware/stores/engines/s3fs.js +0 -5
- package/middleware/stores/multistore.js +0 -29
- package/middleware/stores/store.js +0 -9
- package/middleware/virtual-config/virtual-config.js +127 -124
- package/old_package.json +119 -0
- package/package.json +44 -55
- package/server/index.js +42 -81
- package/server/standalone.js +0 -5
- package/util/util.js +12 -6
- package/duster/helpers/core/cloudcms/associations.js +0 -34
- package/duster/helpers/core/cloudcms/beta/markdown.js +0 -46
- package/duster/helpers/core/cloudcms/beta/nodeAttachmentText.js +0 -46
- package/duster/helpers/core/cloudcms/beta/params.js +0 -33
- package/duster/helpers/core/cloudcms/beta/processTemplate.js +0 -82
- package/duster/helpers/core/cloudcms/content.js +0 -34
- package/duster/helpers/core/cloudcms/expand.js +0 -38
- package/duster/helpers/core/cloudcms/form.js +0 -34
- package/duster/helpers/core/cloudcms/query.js +0 -34
- package/duster/helpers/core/cloudcms/queryOne.js +0 -34
- package/duster/helpers/core/cloudcms/relatives.js +0 -34
- package/duster/helpers/core/cloudcms/search.js +0 -34
- package/duster/helpers/core/cloudcms/searchOne.js +0 -34
- package/duster/helpers/core/cloudcms/wcm/dependency.js +0 -83
- package/duster/helpers/core/cloudcms/wcm/fragment.js +0 -34
- package/duster/helpers/core/dev/debug.js +0 -42
- package/duster/helpers/core/dom/block.js +0 -49
- package/duster/helpers/core/dom/include.js +0 -38
- package/duster/helpers/core/dom/layout.js +0 -49
- package/duster/helpers/core/dom/link.js +0 -81
- package/duster/helpers/core/dom/resource.js +0 -77
- package/duster/helpers/core/engine.js +0 -1580
- package/duster/helpers/core/ice/value.js +0 -65
- package/duster/helpers/core/index.js +0 -49
- package/duster/helpers/core/operators/if.js +0 -64
- package/duster/helpers/core/operators/iter.js +0 -45
- package/duster/helpers/core/operators/iterate.js +0 -129
- package/duster/helpers/sample/nyt.js +0 -114
- package/duster/index.js +0 -319
- package/duster/support.js +0 -436
- package/duster/tracker.js +0 -262
- package/middleware/authentication/providers/cas.js +0 -73
- package/middleware/authentication/providers/facebook.js +0 -120
- package/middleware/authentication/providers/github.js +0 -88
- package/middleware/authentication/providers/linkedin.js +0 -112
- package/middleware/authentication/providers/twitter.js +0 -120
- package/middleware/server-tags/server-tags.js +0 -113
- package/middleware/wcm/wcm.js +0 -1437
- package/temp/clusterlock/README.md +0 -6
- package/temp/clusterlock/index.js +0 -198
- package/temp/clusterlock/package.json +0 -24
- package/temp/passport-saml/LICENSE +0 -23
- package/temp/passport-saml/README.md +0 -406
- package/temp/passport-saml/lib/node-saml/algorithms.d.ts +0 -5
- package/temp/passport-saml/lib/node-saml/algorithms.js +0 -41
- package/temp/passport-saml/lib/node-saml/algorithms.js.map +0 -1
- package/temp/passport-saml/lib/node-saml/index.d.ts +0 -3
- package/temp/passport-saml/lib/node-saml/index.js +0 -6
- package/temp/passport-saml/lib/node-saml/index.js.map +0 -1
- package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.d.ts +0 -45
- package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js +0 -86
- package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js.map +0 -1
- package/temp/passport-saml/lib/node-saml/saml-post-signing.d.ts +0 -3
- package/temp/passport-saml/lib/node-saml/saml-post-signing.js +0 -15
- package/temp/passport-saml/lib/node-saml/saml-post-signing.js.map +0 -1
- package/temp/passport-saml/lib/node-saml/saml.d.ts +0 -77
- package/temp/passport-saml/lib/node-saml/saml.js +0 -1170
- package/temp/passport-saml/lib/node-saml/saml.js.map +0 -1
- package/temp/passport-saml/lib/node-saml/types.d.ts +0 -95
- package/temp/passport-saml/lib/node-saml/types.js +0 -8
- package/temp/passport-saml/lib/node-saml/types.js.map +0 -1
- package/temp/passport-saml/lib/node-saml/utility.d.ts +0 -3
- package/temp/passport-saml/lib/node-saml/utility.js +0 -19
- package/temp/passport-saml/lib/node-saml/utility.js.map +0 -1
- package/temp/passport-saml/lib/node-saml/xml.d.ts +0 -21
- package/temp/passport-saml/lib/node-saml/xml.js +0 -140
- package/temp/passport-saml/lib/node-saml/xml.js.map +0 -1
- package/temp/passport-saml/lib/passport-saml/index.d.ts +0 -6
- package/temp/passport-saml/lib/passport-saml/index.js +0 -11
- package/temp/passport-saml/lib/passport-saml/index.js.map +0 -1
- package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.d.ts +0 -13
- package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js +0 -63
- package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js.map +0 -1
- package/temp/passport-saml/lib/passport-saml/strategy.d.ts +0 -20
- package/temp/passport-saml/lib/passport-saml/strategy.js +0 -167
- package/temp/passport-saml/lib/passport-saml/strategy.js.map +0 -1
- package/temp/passport-saml/lib/passport-saml/types.d.ts +0 -51
- package/temp/passport-saml/lib/passport-saml/types.js +0 -11
- package/temp/passport-saml/lib/passport-saml/types.js.map +0 -1
- package/temp/passport-saml/package.json +0 -96
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ cloudcms-server
|
|
|
3
3
|
|
|
4
4
|
A Node.js module that provides a framework and server-side functionality for Cloud CMS deployed Node.js applications. This module provides the backbone capabilities for the application server tier of Cloud CMS as hosted at cloudcms.net.
|
|
5
5
|
|
|
6
|
-
For more information on Cloud CMS, please visit https://
|
|
6
|
+
For more information on Cloud CMS, please visit https://gitana.io.
|
|
7
7
|
|
|
8
8
|
## Configuration
|
|
9
9
|
|
|
@@ -22,7 +22,6 @@ This looks like:
|
|
|
22
22
|
"beforeFunctions": [],
|
|
23
23
|
"afterFunctions": [],
|
|
24
24
|
"reportFunctions": [],
|
|
25
|
-
"dustFunctions": [],
|
|
26
25
|
"initFunctions": [],
|
|
27
26
|
"viewEngine": "handlebars",
|
|
28
27
|
"storeEngines": {
|
|
@@ -116,11 +115,6 @@ This looks like:
|
|
|
116
115
|
"modules": "hosts_s3fs"
|
|
117
116
|
}
|
|
118
117
|
},
|
|
119
|
-
"duster": {
|
|
120
|
-
"fragments": {
|
|
121
|
-
"cache": true
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
118
|
"virtualHost": {
|
|
125
119
|
"enabled": false
|
|
126
120
|
},
|
package/index.js
CHANGED
|
@@ -239,12 +239,10 @@ exports = module.exports = function()
|
|
|
239
239
|
var registration = require("./middleware/registration/registration");
|
|
240
240
|
var resources = require("./middleware/resources/resources");
|
|
241
241
|
var runtime = require("./middleware/runtime/runtime");
|
|
242
|
-
var serverTags = require("./middleware/server-tags/server-tags");
|
|
243
242
|
var storeService = require("./middleware/stores/stores");
|
|
244
243
|
var templates = require("./middleware/templates/templates");
|
|
245
244
|
var virtualConfig = require("./middleware/virtual-config/virtual-config");
|
|
246
245
|
var virtualFiles = require("./middleware/virtual-files/virtual-files");
|
|
247
|
-
var wcm = require("./middleware/wcm/wcm");
|
|
248
246
|
var welcome = require("./middleware/welcome/welcome");
|
|
249
247
|
var awareness = require("./middleware/awareness/awareness");
|
|
250
248
|
var userAgent = require('express-useragent');
|
|
@@ -484,15 +482,6 @@ exports = module.exports = function()
|
|
|
484
482
|
|
|
485
483
|
// supports user-configured dynamic configuration
|
|
486
484
|
app.use(config.remoteConfigInterceptor());
|
|
487
|
-
|
|
488
|
-
// tag processing, injection of scripts, etc, kind of a catch all at the moment
|
|
489
|
-
app.use(serverTags.interceptor(configuration));
|
|
490
|
-
|
|
491
|
-
if (includeCloudCMS)
|
|
492
|
-
{
|
|
493
|
-
// handles retrieval of content from wcm
|
|
494
|
-
app.use(wcm.wcmInterceptor());
|
|
495
|
-
}
|
|
496
485
|
};
|
|
497
486
|
|
|
498
487
|
r.handlers = function(app, includeCloudCMS)
|
|
@@ -566,12 +555,6 @@ exports = module.exports = function()
|
|
|
566
555
|
// add User-Agent device info to req
|
|
567
556
|
app.use(userAgent.express());
|
|
568
557
|
|
|
569
|
-
if (includeCloudCMS)
|
|
570
|
-
{
|
|
571
|
-
// handles retrieval of content from wcm
|
|
572
|
-
app.use(wcm.wcmHandler());
|
|
573
|
-
}
|
|
574
|
-
|
|
575
558
|
// handles 404
|
|
576
559
|
app.use(final.finalHandler());
|
|
577
560
|
};
|
|
@@ -315,16 +315,11 @@ exports = module.exports = function()
|
|
|
315
315
|
registerAdapter("session", require("./adapters/session"));
|
|
316
316
|
|
|
317
317
|
// providers
|
|
318
|
-
registerProvider("cas", require("./providers/cas"));
|
|
319
|
-
registerProvider("facebook", require("./providers/facebook"));
|
|
320
|
-
registerProvider("github", require("./providers/github"));
|
|
321
318
|
registerProvider("google", require("./providers/google"));
|
|
322
319
|
registerProvider("keycloak", require("./providers/keycloak"));
|
|
323
|
-
registerProvider("linkedin", require("./providers/linkedin"));
|
|
324
320
|
registerProvider("local", require("./providers/local"));
|
|
325
321
|
registerProvider("saml", require("./providers/saml"));
|
|
326
322
|
registerProvider("trusted", require("./providers/trusted"));
|
|
327
|
-
registerProvider("twitter", require("./providers/twitter"));
|
|
328
323
|
|
|
329
324
|
// authenticators
|
|
330
325
|
registerAuthenticator("default", require("./authenticators/default"));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//var auth = require("../../../util/auth");
|
|
2
2
|
|
|
3
|
-
var SamlStrategy = require('passport-saml').Strategy;
|
|
3
|
+
var SamlStrategy = require('@node-saml/passport-saml').Strategy;
|
|
4
4
|
var AbstractProvider = require("./abstract");
|
|
5
5
|
|
|
6
6
|
if (!process.configuration) {
|
|
@@ -57,10 +57,14 @@ class SAMLProvider extends AbstractProvider
|
|
|
57
57
|
samlConfig.entryPoint = config.entryPoint;
|
|
58
58
|
}
|
|
59
59
|
if (config.cert) {
|
|
60
|
-
samlConfig.
|
|
60
|
+
samlConfig.idpCert = config.cert;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
var callbackUrl = config.callbackURL;
|
|
63
|
+
if (!callbackUrl) {
|
|
64
|
+
callbackUrl = config.callbackUrl;
|
|
65
|
+
}
|
|
66
|
+
if (callbackUrl) {
|
|
67
|
+
samlConfig.callbackUrl = "http://localhost:5000" + callbackUrl;
|
|
64
68
|
}
|
|
65
69
|
if (config.issuer) {
|
|
66
70
|
samlConfig.issuer = config.issuer;
|
|
@@ -359,50 +359,6 @@ module.exports = function(configStore)
|
|
|
359
359
|
|
|
360
360
|
// all done
|
|
361
361
|
callback(null, registry);
|
|
362
|
-
|
|
363
|
-
var _watchLog = function(text) {
|
|
364
|
-
process.log("[Configuration Watch] " + text);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
if (process.env.CLOUDCMS_APPSERVER_CONFIG_WATCH === "true" || process.env.CLOUDCMS_APPSERVER_CONFIG_WATCH === true)
|
|
368
|
-
{
|
|
369
|
-
_watchLog("Setting up live watch...");
|
|
370
|
-
|
|
371
|
-
// set a watch
|
|
372
|
-
// watch for changes and when they happen, reload context
|
|
373
|
-
(function (registry) {
|
|
374
|
-
|
|
375
|
-
configStore.watchDirectory("/", function () {
|
|
376
|
-
|
|
377
|
-
_watchLog("Detected changes on disk - reloading...");
|
|
378
|
-
|
|
379
|
-
var t1 = Date.now();
|
|
380
|
-
|
|
381
|
-
// reload context
|
|
382
|
-
loadContext(function (err, context) {
|
|
383
|
-
|
|
384
|
-
if (err) {
|
|
385
|
-
return _watchLog("Failed to load configuration context: " + err);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
try
|
|
389
|
-
{
|
|
390
|
-
compileContextToRegistry(context);
|
|
391
|
-
registry.reloadContext(context);
|
|
392
|
-
|
|
393
|
-
var t2 = Date.now();
|
|
394
|
-
_watchLog("Reloaded context in: " + (t2 - t1) + " ms");
|
|
395
|
-
}
|
|
396
|
-
catch (e)
|
|
397
|
-
{
|
|
398
|
-
_watchLog("Caught error while compiling and reloading context: " + err);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
})(registry);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
362
|
});
|
|
407
363
|
};
|
|
408
364
|
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
//var path = require('path');
|
|
2
|
-
//var fs = require('fs');
|
|
3
|
-
//var http = require('http');
|
|
4
1
|
var util = require("../../util/util");
|
|
5
|
-
//var uuidv4 = require("uuid/v4");
|
|
6
|
-
//var Gitana = require("gitana");
|
|
7
|
-
var duster = require("../../duster/index");
|
|
8
2
|
|
|
9
3
|
/**
|
|
10
4
|
* Deployment middleware.
|
|
@@ -304,10 +298,6 @@ exports = module.exports = function()
|
|
|
304
298
|
logFn("Invalidating application cache for application: " + descriptor.application.id);
|
|
305
299
|
process.cache.invalidateCacheForApp(descriptor.application.id);
|
|
306
300
|
|
|
307
|
-
// invalidate "duster" cache for this application
|
|
308
|
-
logFn("Invalidating duster cache for application: " + descriptor.application.id);
|
|
309
|
-
duster.invalidateCacheForApp(descriptor.application.id);
|
|
310
|
-
|
|
311
301
|
// invalidate gitana driver for this application
|
|
312
302
|
process.broadcast.publish("application_invalidation", {
|
|
313
303
|
"applicationId": descriptor.application.id,
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var fs = require('fs');
|
|
3
|
-
var http = require('http');
|
|
4
1
|
var util = require("../../util/util");
|
|
5
|
-
var Gitana = require("gitana");
|
|
6
|
-
var duster = require("../../duster/index");
|
|
7
2
|
var async = require("async");
|
|
8
3
|
var auth = require("../../util/auth");
|
|
9
4
|
|
|
@@ -84,10 +84,6 @@ exports = module.exports = function(engineId, engineType, engineConfig)
|
|
|
84
84
|
callback(null, null); //data
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
88
|
-
{
|
|
89
|
-
};
|
|
90
|
-
|
|
91
87
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
92
88
|
{
|
|
93
89
|
callback(null);
|
|
@@ -442,11 +442,6 @@ exports = module.exports = function(remoteStore, settings)
|
|
|
442
442
|
cacheStore.readFile(filePath, callback);
|
|
443
443
|
};
|
|
444
444
|
|
|
445
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
446
|
-
{
|
|
447
|
-
// NOT IMPLEMENTED
|
|
448
|
-
};
|
|
449
|
-
|
|
450
445
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
451
446
|
{
|
|
452
447
|
remoteStore.moveFile(originalFilePath, newFilePath, function(err) {
|
|
@@ -4,8 +4,6 @@ var http = require('http');
|
|
|
4
4
|
|
|
5
5
|
var util = require("../../../util/util");
|
|
6
6
|
|
|
7
|
-
var watch = require("watch");
|
|
8
|
-
|
|
9
7
|
var async = require("async");
|
|
10
8
|
|
|
11
9
|
/**
|
|
@@ -217,13 +215,6 @@ exports = module.exports = function(engineConfig)
|
|
|
217
215
|
});
|
|
218
216
|
};
|
|
219
217
|
|
|
220
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
221
|
-
{
|
|
222
|
-
watch.watchTree(toStoragePath(directoryPath), function(f, curr, prev) {
|
|
223
|
-
onChange(f, curr, prev);
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
|
|
227
218
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
228
219
|
{
|
|
229
220
|
fs.rename(toStoragePath(originalFilePath), newFilePath, function(err) {
|
|
@@ -408,11 +408,6 @@ exports = module.exports = function(engineConfig)
|
|
|
408
408
|
});
|
|
409
409
|
};
|
|
410
410
|
|
|
411
|
-
// NOT IMPLEMENTED IN S3
|
|
412
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
413
|
-
{
|
|
414
|
-
};
|
|
415
|
-
|
|
416
411
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
417
412
|
{
|
|
418
413
|
var originalKey = _toKey(originalFilePath);
|
|
@@ -79,11 +79,6 @@ exports = module.exports = function(engineConfig)
|
|
|
79
79
|
cachingAdapter.readFile(filePath, callback);
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
83
|
-
{
|
|
84
|
-
cachingAdapter.watchDirectory(directoryPath, onChange);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
82
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
88
83
|
{
|
|
89
84
|
cachingAdapter.moveFile(originalFilePath, newFilePath, callback);
|
|
@@ -283,35 +283,6 @@ exports = module.exports = function(originalStores)
|
|
|
283
283
|
});
|
|
284
284
|
};
|
|
285
285
|
|
|
286
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
287
|
-
{
|
|
288
|
-
findFileStores(directoryPath, function(err, stores) {
|
|
289
|
-
|
|
290
|
-
if (err) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (stores.length === 0) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
var fns = [];
|
|
299
|
-
for (var i = 0; i < stores.length; i++)
|
|
300
|
-
{
|
|
301
|
-
var fn = function(s, directoryPath) {
|
|
302
|
-
return function(done) {
|
|
303
|
-
s.watchDirectory(directoryPath, onChange);
|
|
304
|
-
done();
|
|
305
|
-
}
|
|
306
|
-
}(stores[i], directoryPath);
|
|
307
|
-
fns.push(fn);
|
|
308
|
-
}
|
|
309
|
-
async.series(fns, function() {
|
|
310
|
-
// done
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
|
|
315
286
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
316
287
|
{
|
|
317
288
|
// TODO: not implemented
|
|
@@ -236,15 +236,6 @@ exports = module.exports = function(engine, engineType, engineId, engineConfigur
|
|
|
236
236
|
});
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
240
|
-
{
|
|
241
|
-
debugStart("Start store.watchDirectory: " + _enginePath(directoryPath));
|
|
242
|
-
engine.watchDirectory(_enginePath(directoryPath), function(f, curr, prev) {
|
|
243
|
-
debugFinish("Finish store.watchDirectory");
|
|
244
|
-
onChange(f, curr, prev);
|
|
245
|
-
});
|
|
246
|
-
};
|
|
247
|
-
|
|
248
239
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
249
240
|
{
|
|
250
241
|
debugStart("Start store.moveFile");
|
|
@@ -165,169 +165,172 @@ exports = module.exports = function()
|
|
|
165
165
|
// so that only N number of virtual configs are loaded at a time
|
|
166
166
|
enqueueLoadVirtualConfig(function(host, rootStore, logMethod, callback) {
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// check cache to see if we already tried to load this in the past few minutes and were sorely disappointed
|
|
173
|
-
process.cache.read(VCSENTINEL_CACHE_KEY, function (err, doesNotExist) {
|
|
168
|
+
return function()
|
|
169
|
+
{
|
|
170
|
+
rootStore.existsFile("gitana.json", function(exists) {
|
|
174
171
|
|
|
175
|
-
|
|
176
|
-
return finishedLoading({
|
|
177
|
-
"message": "No virtual config found for host (from previous attempt)"
|
|
178
|
-
}, null, true);
|
|
179
|
-
}
|
|
172
|
+
var loadFromRemote = function(finishedLoading) {
|
|
180
173
|
|
|
181
|
-
// load the
|
|
182
|
-
|
|
174
|
+
// check cache to see if we already tried to load this in the past few minutes and were sorely disappointed
|
|
175
|
+
process.cache.read(VCSENTINEL_CACHE_KEY, function (err, doesNotExist) {
|
|
183
176
|
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return finishedLoading(err);
|
|
177
|
+
if (doesNotExist) {
|
|
178
|
+
return finishedLoading({
|
|
179
|
+
"message": "No virtual config found for host (from previous attempt)"
|
|
180
|
+
}, null, true);
|
|
189
181
|
}
|
|
190
182
|
|
|
191
|
-
|
|
192
|
-
{
|
|
193
|
-
// mark that it failed (30 minute TTL)
|
|
194
|
-
return process.cache.write(VCSENTINEL_CACHE_KEY, true, BLACKLIST_TTL_SECONDS, function() {
|
|
195
|
-
finishedLoading({
|
|
196
|
-
"message": "No virtual config found for host: " + host
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
}
|
|
183
|
+
// load the gitana.json file from Cloud CMS
|
|
184
|
+
loadConfigForVirtualHost(host, logMethod, function (err, virtualConfig) {
|
|
200
185
|
|
|
201
|
-
// populate gitana.json
|
|
202
|
-
var gitanaJson = {
|
|
203
|
-
"clientKey": virtualConfig.clientKey
|
|
204
|
-
};
|
|
205
|
-
if (virtualConfig.clientSecret) {
|
|
206
|
-
gitanaJson.clientSecret = virtualConfig.clientSecret;
|
|
207
|
-
}
|
|
208
|
-
if (virtualConfig.username) {
|
|
209
|
-
gitanaJson.username = virtualConfig.username;
|
|
210
|
-
}
|
|
211
|
-
if (virtualConfig.password) {
|
|
212
|
-
gitanaJson.password = virtualConfig.password;
|
|
213
|
-
}
|
|
214
|
-
if (virtualConfig.application) {
|
|
215
|
-
gitanaJson.application = virtualConfig.application;
|
|
216
|
-
}
|
|
217
|
-
if (virtualConfig.baseURL) {
|
|
218
|
-
gitanaJson.baseURL = virtualConfig.baseURL;
|
|
219
|
-
}
|
|
220
|
-
if (!gitanaJson.baseURL)
|
|
221
|
-
{
|
|
222
|
-
gitanaJson.baseURL = util.cleanupURL(util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH));
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// mark as retrieved from virtual driver
|
|
226
|
-
gitanaJson._virtual = true;
|
|
227
|
-
|
|
228
|
-
// write the gitana.json file
|
|
229
|
-
rootStore.writeFile("gitana.json", JSON.stringify(gitanaJson, null, " "), function (err) {
|
|
230
|
-
|
|
231
|
-
// if we failed to write the file, then delete and call back with error
|
|
232
186
|
if (err)
|
|
233
187
|
{
|
|
234
|
-
|
|
235
|
-
|
|
188
|
+
// something failed, perhaps a network issue
|
|
189
|
+
// don't store anything
|
|
190
|
+
return finishedLoading(err);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (!virtualConfig)
|
|
194
|
+
{
|
|
195
|
+
// mark that it failed (30 minute TTL)
|
|
196
|
+
return process.cache.write(VCSENTINEL_CACHE_KEY, true, BLACKLIST_TTL_SECONDS, function() {
|
|
197
|
+
finishedLoading({
|
|
198
|
+
"message": "No virtual config found for host: " + host
|
|
199
|
+
});
|
|
236
200
|
});
|
|
237
201
|
}
|
|
238
202
|
|
|
239
|
-
//
|
|
240
|
-
|
|
241
|
-
|
|
203
|
+
// populate gitana.json
|
|
204
|
+
var gitanaJson = {
|
|
205
|
+
"clientKey": virtualConfig.clientKey
|
|
206
|
+
};
|
|
207
|
+
if (virtualConfig.clientSecret) {
|
|
208
|
+
gitanaJson.clientSecret = virtualConfig.clientSecret;
|
|
209
|
+
}
|
|
210
|
+
if (virtualConfig.username) {
|
|
211
|
+
gitanaJson.username = virtualConfig.username;
|
|
212
|
+
}
|
|
213
|
+
if (virtualConfig.password) {
|
|
214
|
+
gitanaJson.password = virtualConfig.password;
|
|
215
|
+
}
|
|
216
|
+
if (virtualConfig.application) {
|
|
217
|
+
gitanaJson.application = virtualConfig.application;
|
|
218
|
+
}
|
|
219
|
+
if (virtualConfig.baseURL) {
|
|
220
|
+
gitanaJson.baseURL = virtualConfig.baseURL;
|
|
221
|
+
}
|
|
222
|
+
if (!gitanaJson.baseURL)
|
|
223
|
+
{
|
|
224
|
+
gitanaJson.baseURL = util.cleanupURL(util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// mark as retrieved from virtual driver
|
|
228
|
+
gitanaJson._virtual = true;
|
|
229
|
+
|
|
230
|
+
// write the gitana.json file
|
|
231
|
+
rootStore.writeFile("gitana.json", JSON.stringify(gitanaJson, null, " "), function (err) {
|
|
242
232
|
|
|
243
|
-
// if we failed to
|
|
244
|
-
if (err
|
|
233
|
+
// if we failed to write the file, then delete and call back with error
|
|
234
|
+
if (err)
|
|
245
235
|
{
|
|
246
236
|
return rootStore.deleteFile("gitana.json", function() {
|
|
247
|
-
finishedLoading(
|
|
248
|
-
"message": "There was a problem writing the driver configuration file. Please reload."
|
|
249
|
-
});
|
|
237
|
+
finishedLoading(err);
|
|
250
238
|
});
|
|
251
239
|
}
|
|
252
240
|
|
|
253
|
-
|
|
241
|
+
// make sure the file wrote successfully
|
|
242
|
+
// check stats, ensure non-error and file size > 0
|
|
243
|
+
rootStore.fileStats("gitana.json", function(err, stats) {
|
|
244
|
+
|
|
245
|
+
// if we failed to read stats, then delete and call back with error
|
|
246
|
+
if (err || stats.size === 0)
|
|
247
|
+
{
|
|
248
|
+
return rootStore.deleteFile("gitana.json", function() {
|
|
249
|
+
finishedLoading({
|
|
250
|
+
"message": "There was a problem writing the driver configuration file. Please reload."
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
finishedLoading(null, gitanaJson);
|
|
256
|
+
});
|
|
254
257
|
});
|
|
255
258
|
});
|
|
256
259
|
});
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
if (exists)
|
|
261
|
-
{
|
|
262
|
-
// read gitana json and send back
|
|
263
|
-
rootStore.readFile("gitana.json", function(err, data) {
|
|
260
|
+
};
|
|
264
261
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (!data)
|
|
271
|
-
{
|
|
272
|
-
return callback({
|
|
273
|
-
"message": "The gitana.json data read from disk was null or empty"
|
|
274
|
-
})
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// make sure not size 0
|
|
278
|
-
rootStore.fileStats("gitana.json", function(err, stats) {
|
|
262
|
+
if (exists)
|
|
263
|
+
{
|
|
264
|
+
// read gitana json and send back
|
|
265
|
+
rootStore.readFile("gitana.json", function(err, data) {
|
|
279
266
|
|
|
280
267
|
if (err)
|
|
281
268
|
{
|
|
282
269
|
return callback(err);
|
|
283
270
|
}
|
|
284
271
|
|
|
285
|
-
|
|
286
|
-
if (err || stats.size === 0)
|
|
272
|
+
if (!data)
|
|
287
273
|
{
|
|
288
|
-
return
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
});
|
|
292
|
-
});
|
|
274
|
+
return callback({
|
|
275
|
+
"message": "The gitana.json data read from disk was null or empty"
|
|
276
|
+
})
|
|
293
277
|
}
|
|
294
278
|
|
|
295
|
-
//
|
|
296
|
-
|
|
279
|
+
// make sure not size 0
|
|
280
|
+
rootStore.fileStats("gitana.json", function(err, stats) {
|
|
297
281
|
|
|
298
|
-
|
|
282
|
+
if (err)
|
|
283
|
+
{
|
|
284
|
+
return callback(err);
|
|
285
|
+
}
|
|
299
286
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
{
|
|
303
|
-
var newBaseURL = util.cleanupURL(gitanaJson.baseURL);
|
|
304
|
-
if (newBaseURL !== gitanaJson.baseURL)
|
|
287
|
+
// if we failed to read stats or file size 0, then delete and call back with error
|
|
288
|
+
if (err || stats.size === 0)
|
|
305
289
|
{
|
|
306
|
-
|
|
290
|
+
return rootStore.deleteFile("gitana.json", function() {
|
|
291
|
+
callback({
|
|
292
|
+
"message": "There was a problem writing the driver configuration file. Please reload."
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
}
|
|
307
296
|
|
|
308
|
-
|
|
297
|
+
// remove vcSentinel if it exists
|
|
298
|
+
process.cache.remove(VCSENTINEL_CACHE_KEY);
|
|
309
299
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
300
|
+
var gitanaJson = JSON.parse("" + data);
|
|
301
|
+
|
|
302
|
+
// auto-upgrade the host?
|
|
303
|
+
if (gitanaJson.baseURL)
|
|
304
|
+
{
|
|
305
|
+
var newBaseURL = util.cleanupURL(gitanaJson.baseURL);
|
|
306
|
+
if (newBaseURL !== gitanaJson.baseURL)
|
|
307
|
+
{
|
|
308
|
+
console.log("Auto-upgrade gitana.json from: " + gitanaJson.baseURL + ", to: " + newBaseURL);
|
|
309
|
+
|
|
310
|
+
gitanaJson.baseURL = newBaseURL;
|
|
311
|
+
|
|
312
|
+
// write the gitana.json file
|
|
313
|
+
rootStore.writeFile("gitana.json", JSON.stringify(gitanaJson, null, " "), function (err) {
|
|
314
|
+
// nada
|
|
315
|
+
});
|
|
316
|
+
}
|
|
314
317
|
}
|
|
315
|
-
}
|
|
316
318
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
+
// otherwise, fine!
|
|
320
|
+
callback(null, gitanaJson);
|
|
321
|
+
});
|
|
319
322
|
});
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
323
|
+
}
|
|
324
|
+
else
|
|
325
|
+
{
|
|
326
|
+
loadFromRemote(function(err, gitanaJson, doesNotExist) {
|
|
327
|
+
callback(err, gitanaJson, doesNotExist);
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
329
332
|
|
|
330
|
-
}(
|
|
333
|
+
}(host, rootStore, logMethod, callback));
|
|
331
334
|
};
|
|
332
335
|
|
|
333
336
|
r.interceptor = function()
|