@sassoftware/viya-serverjs 0.2.0 → 0.2.2
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/Dockerfile +3 -3
- package/cli.js +4 -4
- package/lib/config.js +1 -1
- package/lib/handlers/appCallback.js +1 -1
- package/lib/handlers/codeAuth.js +1 -1
- package/lib/handlers/decodeJwt.js +1 -1
- package/lib/handlers/getApp.js +1 -1
- package/lib/handlers/getUser.js +1 -1
- package/lib/handlers/index.js +1 -1
- package/lib/handlers/keepAlive.js +1 -1
- package/lib/handlers/keepAlive2.js +1 -1
- package/lib/handlers/logon.js +5 -6
- package/lib/handlers/logout.js +1 -1
- package/lib/handlers/proxyMapUri.js +6 -8
- package/lib/handlers/setCookies.js +9 -7
- package/lib/iService.js +16 -65
- package/lib/index.js +14 -7
- package/lib/parseDocker.js +1 -1
- package/lib/plugins/setDefaultRoutes.js +27 -27
- package/package.json +1 -1
- package/server.js +157 -127
- package/src/config.js +1 -1
- package/src/handlers/appCallback.js +1 -1
- package/src/handlers/codeAuth.js +1 -1
- package/src/handlers/decodeJwt.js +1 -1
- package/src/handlers/getApp.js +1 -1
- package/src/handlers/getUser.js +1 -1
- package/src/handlers/index.js +1 -1
- package/src/handlers/keepAlive.js +1 -1
- package/src/handlers/keepAlive2.js +1 -1
- package/src/handlers/logon.js +3 -3
- package/src/handlers/logout.js +1 -1
- package/src/handlers/proxyMapUri.js +6 -9
- package/src/handlers/setCookies.js +4 -2
- package/src/iService.js +14 -37
- package/src/index.js +12 -6
- package/src/parseDocker.js +1 -1
- package/src/plugins/setDefaultRoutes.js +6 -8
package/Dockerfile
CHANGED
|
@@ -23,7 +23,7 @@ ENV APPNAME=appBuilder
|
|
|
23
23
|
ENV AUTHFLOW=
|
|
24
24
|
ENV CLIENTID=appBuilder
|
|
25
25
|
ENV CLIENTSECRET=jellico
|
|
26
|
-
ENV HAPIDEBUG=
|
|
26
|
+
ENV HAPIDEBUG=NO
|
|
27
27
|
# ENV LOGLEVEL=info
|
|
28
28
|
# ENV USETOKEN=YES
|
|
29
29
|
|
|
@@ -31,8 +31,8 @@ ENV HAPIDEBUG=YES
|
|
|
31
31
|
ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:SAS Institute,OU:STO,CN:localhost"
|
|
32
32
|
|
|
33
33
|
# You can specify your own cet and key
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
ENV TLS_CRT=./tls/tls.crt
|
|
35
|
+
ENV TLS_KEY=./tls/tls.key
|
|
36
36
|
|
|
37
37
|
# Samesite specification
|
|
38
38
|
ENV SAMESITE=None,secure
|
package/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
/*
|
|
3
3
|
* Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
//let appServer = require('./lib/index.js');
|
|
7
|
-
let
|
|
8
|
-
console.log('Starting the cli for @sassoftware/viya-
|
|
9
|
-
|
|
7
|
+
let core = require('./lib/index.js');
|
|
8
|
+
console.log('Starting the cli for @sassoftware/viya-serverjs');
|
|
9
|
+
core(null, true, 'app', null);
|
package/lib/config.js
CHANGED
|
@@ -26,7 +26,7 @@ var _parseDocker = _interopRequireDefault(require("./parseDocker"));
|
|
|
26
26
|
var _debug = _interopRequireDefault(require("debug"));
|
|
27
27
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
28
28
|
var fs = require('fs');
|
|
29
|
-
var configDebug = (0, _debug["default"])('
|
|
29
|
+
var configDebug = (0, _debug["default"])('configserver');
|
|
30
30
|
function config(appEnv, dockerFile) {
|
|
31
31
|
if (dockerFile != null) {
|
|
32
32
|
(0, _parseDocker["default"])(dockerFile);
|
package/lib/handlers/codeAuth.js
CHANGED
|
@@ -7,7 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _jwtDecode = _interopRequireDefault(require("jwt-decode"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
9
|
/*
|
|
10
|
-
* Copyright ©
|
|
10
|
+
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
11
11
|
* SPDX-License-Identifier: Apache-2.0
|
|
12
12
|
*/
|
|
13
13
|
|
package/lib/handlers/getApp.js
CHANGED
|
@@ -10,7 +10,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
10
10
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
11
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
12
12
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } /*
|
|
13
|
-
* Copyright ©
|
|
13
|
+
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
15
15
|
*/
|
|
16
16
|
var debug = require('debug')('getapp');
|
package/lib/handlers/getUser.js
CHANGED
package/lib/handlers/index.js
CHANGED
package/lib/handlers/logon.js
CHANGED
|
@@ -10,7 +10,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
10
10
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
11
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
12
12
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } /*
|
|
13
|
-
* Copyright ©
|
|
13
|
+
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
15
15
|
*/
|
|
16
16
|
var debug = require('debug')('logon');
|
|
@@ -25,15 +25,14 @@ function _logon() {
|
|
|
25
25
|
case 0:
|
|
26
26
|
debugger;
|
|
27
27
|
debug('.................................................in logon');
|
|
28
|
-
|
|
29
|
-
_context.next = 5;
|
|
28
|
+
_context.next = 4;
|
|
30
29
|
return (0, _setCookies["default"])(req, h, null);
|
|
31
|
-
case
|
|
30
|
+
case 4:
|
|
32
31
|
r = _context.sent;
|
|
33
32
|
debug(r.redirect);
|
|
34
|
-
|
|
33
|
+
debug('in logon after setcookie', r.redirect);
|
|
35
34
|
return _context.abrupt("return", h.redirect(r.redirect));
|
|
36
|
-
case
|
|
35
|
+
case 8:
|
|
37
36
|
case "end":
|
|
38
37
|
return _context.stop();
|
|
39
38
|
}
|
package/lib/handlers/logout.js
CHANGED
|
@@ -18,28 +18,26 @@ function _proxyMapUri() {
|
|
|
18
18
|
while (1) switch (_context.prev = _context.next) {
|
|
19
19
|
case 0:
|
|
20
20
|
credentials = req.auth.credentials;
|
|
21
|
+
console.log('------------------------------------------');
|
|
21
22
|
if (credentials != null) {
|
|
22
23
|
sid = credentials.sid;
|
|
23
|
-
console.log(credentials);
|
|
24
24
|
console.log('sid=', sid);
|
|
25
25
|
}
|
|
26
26
|
path = process.env.PROXYSERVER;
|
|
27
|
-
console.log('
|
|
28
|
-
console.log('Proxying to ', path);
|
|
27
|
+
console.log('proxying to= ', path);
|
|
29
28
|
params = req.params;
|
|
30
|
-
console.log('
|
|
29
|
+
console.log('params=', params);
|
|
31
30
|
search = req.url.search;
|
|
32
|
-
console.log('
|
|
31
|
+
console.log('query=', search);
|
|
33
32
|
uri = path + '/' + params.param;
|
|
34
33
|
if (search != null && search.trim().length > 0) {
|
|
35
34
|
uri = uri + search;
|
|
36
35
|
}
|
|
37
|
-
console.log('
|
|
38
|
-
console.log('-----------------------------------------------------------');
|
|
36
|
+
console.log('destination= ', uri);
|
|
39
37
|
return _context.abrupt("return", {
|
|
40
38
|
uri: uri
|
|
41
39
|
});
|
|
42
|
-
case
|
|
40
|
+
case 13:
|
|
43
41
|
case "end":
|
|
44
42
|
return _context.stop();
|
|
45
43
|
}
|
|
@@ -9,7 +9,7 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
9
9
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
10
10
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
11
11
|
/*
|
|
12
|
-
* Copyright ©
|
|
12
|
+
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
13
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
14
14
|
*/
|
|
15
15
|
var uuid = require('uuid');
|
|
@@ -25,9 +25,9 @@ function _setCookies() {
|
|
|
25
25
|
case 0:
|
|
26
26
|
credentials = req.auth.credentials;
|
|
27
27
|
debug('setcookie', credentials);
|
|
28
|
-
|
|
28
|
+
debug('setcookie', credentials);
|
|
29
29
|
if (!(credentials != null && req.auth.error != null)) {
|
|
30
|
-
_context.next =
|
|
30
|
+
_context.next = 6;
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
debug('logon failed');
|
|
@@ -35,7 +35,7 @@ function _setCookies() {
|
|
|
35
35
|
status: false,
|
|
36
36
|
error: req.auth.error
|
|
37
37
|
});
|
|
38
|
-
case
|
|
38
|
+
case 6:
|
|
39
39
|
// create a cookie(sid) and save credentials in cache
|
|
40
40
|
sid = uuid.v4();
|
|
41
41
|
credentials.sid = sid;
|
|
@@ -44,9 +44,11 @@ function _setCookies() {
|
|
|
44
44
|
options.allAppEnv.LOGONPAYLOAD.tokenType = 'bearer';
|
|
45
45
|
debug(options.allAppEnv.LOGONPAYLOAD);
|
|
46
46
|
}
|
|
47
|
-
_context.next =
|
|
47
|
+
_context.next = 11;
|
|
48
48
|
return req.server.app.cache.set(sid, credentials, 0);
|
|
49
|
-
case
|
|
49
|
+
case 11:
|
|
50
|
+
// Can we get away without setting cookie for this session?
|
|
51
|
+
// Need to also modify keepAlive
|
|
50
52
|
if (process.env.COOKIES !== 'NO') {
|
|
51
53
|
debugger;
|
|
52
54
|
req.cookieAuth.set({
|
|
@@ -62,7 +64,7 @@ function _setCookies() {
|
|
|
62
64
|
error: null,
|
|
63
65
|
redirect: redirect
|
|
64
66
|
});
|
|
65
|
-
case
|
|
67
|
+
case 17:
|
|
66
68
|
case "end":
|
|
67
69
|
return _context.stop();
|
|
68
70
|
}
|
package/lib/iService.js
CHANGED
|
@@ -133,7 +133,7 @@ function iService(userRouteTable, useDefault, asset, allAppEnv, serverMode, user
|
|
|
133
133
|
hapiServer.app.cache = cache;
|
|
134
134
|
*/
|
|
135
135
|
nodeCacheOptions = {
|
|
136
|
-
stdTTL:
|
|
136
|
+
stdTTL: 24 * 60 * 60 * 1000,
|
|
137
137
|
checkPeriod: 3600,
|
|
138
138
|
errorOnMissing: true,
|
|
139
139
|
useClones: false,
|
|
@@ -314,81 +314,32 @@ function _getCertificates() {
|
|
|
314
314
|
while (1) switch (_context2.prev = _context2.next) {
|
|
315
315
|
case 0:
|
|
316
316
|
tls = {};
|
|
317
|
-
debug2('Getting tls certificates');
|
|
318
|
-
debug2('tls.crt', process.env['tls.crt'] != null);
|
|
319
|
-
debug2('tls.key', process.env['tls.key'] != null);
|
|
320
|
-
debug2('TLS_PFX', process.env.TLS_PFX != null);
|
|
321
|
-
debug2('TLS_PW', process.env.TLS_PW != null);
|
|
322
|
-
debug2('TLS_CERT', process.env.TLS_CERT != null);
|
|
323
317
|
debug2('TLS_CRT', process.env.TLS_CRT != null);
|
|
324
318
|
debug2('TLS_CREATE', process.env.TLS_CREATE != null);
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
tls.cert = fs.readFileSync(process.env.TLS_CERT);
|
|
332
|
-
tls.key = fs.readFileSync(process.env.TLS_KEY);
|
|
333
|
-
_context2.next = 37;
|
|
334
|
-
break;
|
|
335
|
-
case 15:
|
|
336
|
-
if (!(process.env.TLS_PFX != null)) {
|
|
337
|
-
_context2.next = 21;
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
debug2('TLS set: PFX');
|
|
341
|
-
tls.pfx = fs.readFileSync(process.env.TLS_PFX);
|
|
342
|
-
if (process.env.TLS_PW != null) {
|
|
343
|
-
tls.passphrase = process.env.TLS_PW;
|
|
344
|
-
}
|
|
345
|
-
_context2.next = 37;
|
|
346
|
-
break;
|
|
347
|
-
case 21:
|
|
348
|
-
if (!(process.env.TLS_CRT != null && process.env.TLS_CRT.trim().length > 0)) {
|
|
349
|
-
_context2.next = 27;
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
/* new key names to conform to k8s*/
|
|
353
|
-
debug2('TLS set: TLS_CRT');
|
|
354
|
-
tls.cert = process.env.TLS_CRT;
|
|
355
|
-
tls.key = process.env.TLS_KEY;
|
|
356
|
-
_context2.next = 37;
|
|
357
|
-
break;
|
|
358
|
-
case 27:
|
|
359
|
-
if (!(process.env['tls.crt'] != null)) {
|
|
360
|
-
_context2.next = 32;
|
|
361
|
-
break;
|
|
319
|
+
if (process.env.TLS_CRT != null && process.env.TLS_CRT.length > 0) {
|
|
320
|
+
if (fs.existsSync(process.env.TLS_CRT) && fs.existsSync(process.env.TLS_KEY)) {
|
|
321
|
+
console.log('TLS_CRT and TLS_KEY exist');
|
|
322
|
+
tls.cert = fs.readFileSync(process.env.TLS_CRT);
|
|
323
|
+
tls.key = fs.readFileSync(process.env.TLS_KEY);
|
|
324
|
+
}
|
|
362
325
|
}
|
|
363
|
-
tls.cert
|
|
364
|
-
|
|
365
|
-
_context2.next = 37;
|
|
366
|
-
break;
|
|
367
|
-
case 32:
|
|
368
|
-
if (!(process.env.TLS_CREATE != null)) {
|
|
369
|
-
_context2.next = 37;
|
|
326
|
+
if (!(tls.cert == null && process.env.TLS_CREATE != null)) {
|
|
327
|
+
_context2.next = 10;
|
|
370
328
|
break;
|
|
371
329
|
}
|
|
372
330
|
/* unsigned certificate */
|
|
331
|
+
console.log('Creating selfsigned certificate');
|
|
373
332
|
debug2('TLS set: TLS_CREATE=', process.env.TLS_CREATE);
|
|
374
|
-
_context2.next =
|
|
333
|
+
_context2.next = 9;
|
|
375
334
|
return getTls();
|
|
376
|
-
case
|
|
335
|
+
case 9:
|
|
377
336
|
tls = _context2.sent;
|
|
378
|
-
case
|
|
379
|
-
if (
|
|
380
|
-
|
|
337
|
+
case 10:
|
|
338
|
+
if (Object.keys(tls).length === 0) {
|
|
339
|
+
console.log('Warning: The current host protocol is https: No TLS certificate information has been specified.');
|
|
381
340
|
}
|
|
382
|
-
debug2('TLS', tls);
|
|
383
|
-
if (!(Object.keys(tls).length > 0)) {
|
|
384
|
-
_context2.next = 43;
|
|
385
|
-
break;
|
|
386
|
-
}
|
|
387
|
-
return _context2.abrupt("return", tls);
|
|
388
|
-
case 43:
|
|
389
|
-
console.log('Warning: The current host protocol is https: No TLS certificate information has been specified.');
|
|
390
341
|
return _context2.abrupt("return", tls);
|
|
391
|
-
case
|
|
342
|
+
case 12:
|
|
392
343
|
case "end":
|
|
393
344
|
return _context2.stop();
|
|
394
345
|
}
|
package/lib/index.js
CHANGED
|
@@ -25,19 +25,19 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
var debug = require("debug")("startup");
|
|
28
|
-
module.exports = function
|
|
28
|
+
module.exports = function core(uTable, useDefault, serverMode, customize, swaggerfcn) {
|
|
29
29
|
var argv = require("yargs").argv;
|
|
30
30
|
var env = argv.env == null ? null : argv.env;
|
|
31
31
|
var appenv = argv.appenv == null ? null : argv.appenv;
|
|
32
32
|
var docker = argv.docker == null ? null : argv.docker;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
//process.env.SERVERMODE = serverMode !== null ? "api" : "app";
|
|
34
|
+
|
|
35
35
|
if (useDefault == null) {
|
|
36
36
|
useDefault = true;
|
|
37
37
|
}
|
|
38
38
|
console.log("Initialization started ============================================================");
|
|
39
39
|
console.log("version: 2, Build Date: ", Date());
|
|
40
|
-
console.log("\nCommand Line Configuration:\n Dockerfile: ".concat(docker, "\n env file : ").concat(env, "\n appenv : ").concat(appenv, "\n customize : ").concat(customize != null, "
|
|
40
|
+
console.log("\nCommand Line Configuration:\n Dockerfile: ".concat(docker, "\n env file : ").concat(env, "\n appenv : ").concat(appenv, "\n customize : ").concat(customize != null, "\n "));
|
|
41
41
|
iapp(null, env, docker, uTable, useDefault, serverMode, customize);
|
|
42
42
|
};
|
|
43
43
|
function iapp(appSrc, rafEnv, dockerFile, uTable, useDefault, serverMode, customize) {
|
|
@@ -93,13 +93,20 @@ function getAllEnv(userData) {
|
|
|
93
93
|
console.log('Note: setting host to null');
|
|
94
94
|
host = null;
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
if (process.env.AUTHTYPE != null) {
|
|
99
|
+
process.env.AUTHFLOW = process.env.AUTHTYPE;
|
|
100
|
+
}
|
|
101
|
+
*/
|
|
102
|
+
|
|
99
103
|
var authflow = trimit("AUTHFLOW");
|
|
100
104
|
if (authflow === "authorization_code" || authflow === "code") {
|
|
101
105
|
authflow = "server";
|
|
102
106
|
}
|
|
107
|
+
if (authflow === null) {
|
|
108
|
+
host = null;
|
|
109
|
+
}
|
|
103
110
|
if (host === null) {
|
|
104
111
|
authflow = null;
|
|
105
112
|
console.log('Note: setting authflow to null');
|
package/lib/parseDocker.js
CHANGED
|
@@ -166,7 +166,6 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
166
166
|
allAppEnv.credentials = options.credentials;
|
|
167
167
|
var s = "let LOGONPAYLOAD = ".concat(JSON.stringify(allAppEnv.LOGONPAYLOAD), ";") + "let APPENV = ".concat(JSON.stringify(allAppEnv.APPENV), ";");
|
|
168
168
|
if (process.env.SHOWENV != null) {
|
|
169
|
-
console.log(options.allAppEnv);
|
|
170
169
|
console.log(s);
|
|
171
170
|
}
|
|
172
171
|
debug(s);
|
|
@@ -189,21 +188,25 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
189
188
|
allAppEnv.credentials = options.credentials;
|
|
190
189
|
var s = "let LOGONPAYLOAD = ".concat(JSON.stringify(allAppEnv.LOGONPAYLOAD), ";") + "let APPENV = ".concat(JSON.stringify(allAppEnv.APPENV), ";");
|
|
191
190
|
if (process.env.SHOWENV != null) {
|
|
192
|
-
|
|
193
|
-
console.log(s);
|
|
191
|
+
debug(options.allAppEnv);
|
|
194
192
|
}
|
|
195
193
|
debug(s);
|
|
196
194
|
return s;
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
197
|
+
},
|
|
198
|
+
/*
|
|
199
|
+
{
|
|
200
|
+
method: ["GET"],
|
|
201
|
+
path: `${appName}/{param*}`,
|
|
202
|
+
options: {
|
|
203
|
+
auth: authDefault,
|
|
204
|
+
handler: getApp2,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
{
|
|
207
210
|
method: ["GET"],
|
|
208
211
|
path: "/{param*}",
|
|
209
212
|
options: {
|
|
@@ -225,24 +228,21 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
225
228
|
handler: _handlers.keepAlive2
|
|
226
229
|
}
|
|
227
230
|
}];
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
passThrough: true
|
|
238
|
-
}
|
|
231
|
+
var pr = {
|
|
232
|
+
method: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
|
|
233
|
+
path: "".concat(appName, "/proxy/{param*}"),
|
|
234
|
+
options: {
|
|
235
|
+
handler: {
|
|
236
|
+
proxy: {
|
|
237
|
+
mapUri: _handlers.proxyMapUri,
|
|
238
|
+
xforward: true,
|
|
239
|
+
passThrough: true
|
|
239
240
|
}
|
|
240
241
|
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
console.log(uTable);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
debug(pr);
|
|
245
|
+
defaultTable.push(pr);
|
|
246
246
|
var routeTables = uTable !== null ? defaultTable.concat(uTable) : defaultTable;
|
|
247
247
|
server.route(routeTables);
|
|
248
248
|
};
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -2,161 +2,191 @@
|
|
|
2
2
|
* Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
let
|
|
5
|
+
let core = require('./lib/index.js');
|
|
6
6
|
debugger;
|
|
7
|
-
|
|
7
|
+
core(getCustomHandler, true, 'app', customize);
|
|
8
8
|
function customize(key, _options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
debugger;
|
|
10
|
+
let info = {
|
|
11
|
+
SWAGGEROPTIONS: {},
|
|
12
|
+
APPENV: null,
|
|
13
|
+
};
|
|
14
|
+
return info[key];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function getCustomHandler() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
let appName = `/${process.env.APPNAME}`; /* does not have to be this - your choice */
|
|
19
|
+
debugger;
|
|
20
|
+
let routes = [
|
|
21
|
+
{
|
|
22
|
+
method: ["GET"],
|
|
23
|
+
path: "/help",
|
|
24
|
+
options: {
|
|
25
25
|
files: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
relativeTo: "./public",
|
|
27
|
+
},
|
|
28
|
+
handler: async (req, h) => {
|
|
29
|
+
debugger;
|
|
30
|
+
let hf = 'help.html';
|
|
31
|
+
return h.file(hf);
|
|
32
|
+
},
|
|
33
|
+
auth: false,
|
|
34
|
+
description: "Help",
|
|
35
|
+
notes: "Help",
|
|
36
|
+
tags: ["app"],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
method: ["GET"],
|
|
41
|
+
path: `${appName}/new`,
|
|
42
|
+
options: {
|
|
43
|
+
files: {
|
|
44
|
+
relativeTo: process.env.APPDIR,
|
|
45
|
+
},
|
|
46
|
+
handler: async (req, h) => {
|
|
29
47
|
console.log('in new');
|
|
30
48
|
let q = req.pre.context;
|
|
31
49
|
console.log('query', q.query);
|
|
32
50
|
console.log('queryOrig', q.queryOrig);
|
|
33
51
|
let hf = null;
|
|
34
|
-
if (q.query != null
|
|
52
|
+
if (q.query != null) {
|
|
35
53
|
let app = q.query;
|
|
36
54
|
if (app.edit != null) {
|
|
37
|
-
hf = app.edit+ '/design.html';
|
|
55
|
+
hf = app.edit + '/design.html';
|
|
38
56
|
} else if (app.view != null) {
|
|
39
|
-
hf= app.view + '/index.html';
|
|
40
|
-
}
|
|
57
|
+
hf = app.view + '/index.html';
|
|
58
|
+
}
|
|
41
59
|
}
|
|
42
60
|
console.log('hf=', hf);
|
|
43
61
|
if (hf === null) {
|
|
44
62
|
hf = getIndex();
|
|
45
|
-
return h.response(hf).header('contentType','text/html');
|
|
63
|
+
return h.response(hf).header('contentType', 'text/html');
|
|
46
64
|
} else {
|
|
47
|
-
|
|
65
|
+
return h.file(hf);
|
|
48
66
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
|
|
68
|
+
},
|
|
69
|
+
// auth: 'logon',
|
|
70
|
+
description: "Create new application",
|
|
71
|
+
notes: "Index file created from env data",
|
|
72
|
+
tags: ["app"],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
57
75
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
76
|
+
method: ["GET"],
|
|
77
|
+
path: `${appName}/ntest/{app?}`,
|
|
78
|
+
options: {
|
|
79
|
+
|
|
80
|
+
handler: async (req, h) => {
|
|
63
81
|
params = req.params;
|
|
64
82
|
console.log('params', params.app);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
83
|
+
let hf = req.pre.context.queryOrig.app;
|
|
84
|
+
console.log('hf=', hf);
|
|
85
|
+
return h.file('help.html');
|
|
86
|
+
},
|
|
87
|
+
// auth: 'logon',
|
|
88
|
+
description: "App Route",
|
|
89
|
+
notes: "Default App Route",
|
|
90
|
+
tags: ["app"],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
method: ["GET"],
|
|
95
|
+
path: `${appName}/view`,
|
|
96
|
+
options: {
|
|
97
|
+
|
|
98
|
+
handler: async (req, h) => {
|
|
99
|
+
let hf = req.pre.context.queryOrig.app;
|
|
100
|
+
console.log('hf=', hf);
|
|
101
|
+
return h.file('help.html');
|
|
102
|
+
},
|
|
103
|
+
// auth: 'logon',
|
|
104
|
+
description: "App Route",
|
|
105
|
+
notes: "Default App Route",
|
|
106
|
+
tags: ["app"],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
method: ["GET"],
|
|
111
|
+
path: `${appName}/edit`,
|
|
112
|
+
options: {
|
|
113
|
+
files: {
|
|
114
|
+
relativeTo: process.env.APPDIR,
|
|
115
|
+
},
|
|
116
|
+
handler: async (req, h) => {
|
|
117
|
+
let hf = req.pre.context.queryOrig.app;
|
|
118
|
+
console.log('hf=', hf);
|
|
119
|
+
return h.file(hf + '/design.html');
|
|
120
|
+
},
|
|
121
|
+
// auth: 'logon',
|
|
122
|
+
description: "App Route",
|
|
123
|
+
notes: "Default App Route",
|
|
124
|
+
tags: ["app"],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
method: ["GET"],
|
|
129
|
+
path: `${appName}/test`,
|
|
130
|
+
options: {
|
|
131
|
+
handler: async (req, h) => {
|
|
132
|
+
debugger;
|
|
133
|
+
console.log("++++++++++++++++++++++ in post");
|
|
134
|
+
let context = req.pre.context;
|
|
135
|
+
console.log(context);
|
|
136
|
+
let loc = req.context.queryOrig.h;
|
|
137
|
+
console.log(loc);
|
|
138
|
+
return h.file(loc);
|
|
139
|
+
},
|
|
140
|
+
auth: false,
|
|
141
|
+
description:
|
|
142
|
+
"Another test",
|
|
143
|
+
notes: "second test",
|
|
144
|
+
tags: ["api"],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
method: ["GET"],
|
|
149
|
+
path: `${appName}/{param*}`,
|
|
150
|
+
|
|
151
|
+
options: {
|
|
152
|
+
handler: async (req, h) => {
|
|
153
|
+
console.log('in get param');
|
|
154
|
+
console.log(req.params);
|
|
155
|
+
return ('hi');
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
return routes;
|
|
131
161
|
}
|
|
132
162
|
function customize(key, options) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
163
|
+
let info = {
|
|
164
|
+
swaggerOptions: {
|
|
165
|
+
info: {
|
|
166
|
+
title: "Test API",
|
|
167
|
+
version: "0.0.1",
|
|
168
|
+
description: "This document was auto-generated at run time",
|
|
169
|
+
},
|
|
170
|
+
documentationPage: true,
|
|
171
|
+
documentationPath: `/${process.env.APPNAME}/documentation`,
|
|
172
|
+
swaggerUI: true,
|
|
173
|
+
swaggerUIPath: `/${process.env.APPNAME}/swaggerui`,
|
|
174
|
+
schemes: ["https", "http"],
|
|
175
|
+
cors: true,
|
|
176
|
+
auth: options.authDefault,
|
|
177
|
+
},
|
|
178
|
+
APPENV: {
|
|
179
|
+
x: 1,
|
|
180
|
+
y: 2,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
let r = info[key];
|
|
184
|
+
return r == null ? {} : r;
|
|
155
185
|
}
|
|
156
186
|
|
|
157
187
|
function getIndex() {
|
|
158
188
|
|
|
159
|
-
|
|
189
|
+
let template = `
|
|
160
190
|
<html lang="en">
|
|
161
191
|
<head>
|
|
162
192
|
<meta charset="UTF-8" />
|
|
@@ -440,5 +470,5 @@ function getIndex() {
|
|
|
440
470
|
</body>
|
|
441
471
|
</html>
|
|
442
472
|
`;
|
|
443
|
-
return template;
|
|
473
|
+
return template;
|
|
444
474
|
}
|
package/src/config.js
CHANGED
package/src/handlers/codeAuth.js
CHANGED
package/src/handlers/getApp.js
CHANGED
package/src/handlers/getUser.js
CHANGED
package/src/handlers/index.js
CHANGED
package/src/handlers/logon.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -8,11 +8,11 @@ let debug = require('debug')('logon');
|
|
|
8
8
|
async function logon (req, h) {
|
|
9
9
|
debugger;
|
|
10
10
|
debug('.................................................in logon');
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
|
|
13
13
|
let r = await setCookies(req, h, null);
|
|
14
14
|
debug(r.redirect);
|
|
15
|
-
|
|
15
|
+
debug('in logon after setcookie', r.redirect);
|
|
16
16
|
return h.redirect(r.redirect);
|
|
17
17
|
}
|
|
18
18
|
|
package/src/handlers/logout.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
async function proxyMapUri (req) {
|
|
2
2
|
let credentials = req.auth.credentials;
|
|
3
|
-
|
|
3
|
+
console.log('------------------------------------------');
|
|
4
4
|
if (credentials != null) {
|
|
5
5
|
let sid = credentials.sid;
|
|
6
|
-
console.log(credentials);
|
|
7
6
|
console.log('sid=', sid);
|
|
8
7
|
}
|
|
9
|
-
|
|
8
|
+
|
|
10
9
|
let path = process.env.PROXYSERVER;
|
|
11
|
-
console.log('
|
|
12
|
-
console.log('Proxying to ', path);
|
|
10
|
+
console.log('proxying to= ', path);
|
|
13
11
|
let params = req.params;
|
|
14
|
-
console.log('
|
|
12
|
+
console.log('params=', params);
|
|
15
13
|
let search = req.url.search;
|
|
16
|
-
console.log('
|
|
14
|
+
console.log('query=', search);
|
|
17
15
|
let uri = path + '/' + params.param;
|
|
18
16
|
if (search != null && search.trim().length > 0) {
|
|
19
17
|
uri = uri + search;
|
|
20
18
|
}
|
|
21
|
-
console.log('
|
|
22
|
-
console.log('-----------------------------------------------------------');
|
|
19
|
+
console.log('destination= ',uri);
|
|
23
20
|
return {
|
|
24
21
|
uri: uri
|
|
25
22
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
let uuid = require('uuid');
|
|
@@ -8,7 +8,7 @@ let debug = require('debug')('setcookies');
|
|
|
8
8
|
async function setCookies (req, h, options) {
|
|
9
9
|
let credentials = req.auth.credentials;
|
|
10
10
|
debug('setcookie', credentials);
|
|
11
|
-
|
|
11
|
+
debug('setcookie', credentials);
|
|
12
12
|
if (credentials != null && req.auth.error != null) {
|
|
13
13
|
debug('logon failed');
|
|
14
14
|
return { status: false, error: req.auth.error };
|
|
@@ -25,6 +25,8 @@ async function setCookies (req, h, options) {
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
await req.server.app.cache.set(sid, credentials, 0);
|
|
28
|
+
// Can we get away without setting cookie for this session?
|
|
29
|
+
// Need to also modify keepAlive
|
|
28
30
|
if (process.env.COOKIES !== 'NO') {
|
|
29
31
|
debugger;
|
|
30
32
|
req.cookieAuth.set({ sid });
|
package/src/iService.js
CHANGED
|
@@ -116,7 +116,7 @@ function iService (userRouteTable, useDefault, asset, allAppEnv, serverMode, use
|
|
|
116
116
|
*/
|
|
117
117
|
|
|
118
118
|
let nodeCacheOptions = {
|
|
119
|
-
stdTTL :
|
|
119
|
+
stdTTL : 24*60*60*1000,
|
|
120
120
|
checkPeriod : 3600,
|
|
121
121
|
errorOnMissing: true,
|
|
122
122
|
useClones : false,
|
|
@@ -197,7 +197,7 @@ function iService (userRouteTable, useDefault, asset, allAppEnv, serverMode, use
|
|
|
197
197
|
}
|
|
198
198
|
hapiServer.log('Plugin', process.env.PLUGIN);
|
|
199
199
|
|
|
200
|
-
if (process.env.PLUGIN === 'hapi-swagger' && serverMode ===
|
|
200
|
+
if (process.env.PLUGIN === 'hapi-swagger' && serverMode ==='api') {
|
|
201
201
|
let swaggerOptions = {
|
|
202
202
|
"info": {
|
|
203
203
|
"title" : `API for ${process.env.APPNAME}`,
|
|
@@ -259,49 +259,26 @@ function iService (userRouteTable, useDefault, asset, allAppEnv, serverMode, use
|
|
|
259
259
|
async function getCertificates () {
|
|
260
260
|
|
|
261
261
|
let tls = {};
|
|
262
|
-
debug2('Getting tls certificates');
|
|
263
|
-
debug2('tls.crt', process.env['tls.crt'] != null);
|
|
264
|
-
debug2('tls.key', process.env['tls.key'] != null);
|
|
265
|
-
debug2('TLS_PFX', process.env.TLS_PFX != null);
|
|
266
|
-
debug2('TLS_PW', process.env.TLS_PW != null);
|
|
267
|
-
debug2('TLS_CERT', process.env.TLS_CERT != null);
|
|
268
262
|
debug2('TLS_CRT', process.env.TLS_CRT != null);
|
|
269
263
|
debug2('TLS_CREATE', process.env.TLS_CREATE != null);
|
|
270
|
-
if (process.env.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
} else if (process.env.TLS_PFX != null) {
|
|
276
|
-
debug2('TLS set: PFX');
|
|
277
|
-
tls.pfx = fs.readFileSync(process.env.TLS_PFX);
|
|
278
|
-
if (process.env.TLS_PW != null) {
|
|
279
|
-
tls.passphrase = process.env.TLS_PW;
|
|
264
|
+
if (process.env.TLS_CRT != null && process.env.TLS_CRT.length > 0) {
|
|
265
|
+
if (fs.existsSync(process.env.TLS_CRT) && fs.existsSync(process.env.TLS_KEY)) {
|
|
266
|
+
console.log('TLS_CRT and TLS_KEY exist');
|
|
267
|
+
tls.cert = fs.readFileSync(process.env.TLS_CRT);
|
|
268
|
+
tls.key = fs.readFileSync(process.env.TLS_KEY);
|
|
280
269
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
tls.cert = process.env.TLS_CRT;
|
|
285
|
-
tls.key = process.env.TLS_KEY;
|
|
286
|
-
} else if (process.env['tls.crt'] != null) {
|
|
287
|
-
tls.cert = process.env['tls.crt'];
|
|
288
|
-
tls.key = process.env['tls.key'];
|
|
289
|
-
} else if (process.env.TLS_CREATE != null) {
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
if (tls.cert == null && process.env.TLS_CREATE != null) {
|
|
290
273
|
/* unsigned certificate */
|
|
274
|
+
console.log('Creating selfsigned certificate');
|
|
291
275
|
debug2('TLS set: TLS_CREATE=', process.env.TLS_CREATE);
|
|
292
276
|
tls = await getTls();
|
|
293
277
|
}
|
|
294
|
-
|
|
295
|
-
if (process.env.TLS_CABUNDLE != null) {
|
|
296
|
-
tls.CA = fs.readFileSync(process.env.TLS_CABUNDLE);
|
|
297
|
-
}
|
|
298
|
-
debug2('TLS', tls);
|
|
299
|
-
if (Object.keys(tls).length > 0) {
|
|
300
|
-
return tls;
|
|
301
|
-
} else {
|
|
278
|
+
if (Object.keys(tls).length === 0){
|
|
302
279
|
console.log('Warning: The current host protocol is https: No TLS certificate information has been specified.');
|
|
303
|
-
|
|
304
|
-
|
|
280
|
+
}
|
|
281
|
+
return tls;
|
|
305
282
|
}
|
|
306
283
|
|
|
307
284
|
async function getTls () {
|
package/src/index.js
CHANGED
|
@@ -23,18 +23,19 @@ import iService from "./iService";
|
|
|
23
23
|
import config from "./config";
|
|
24
24
|
let debug = require("debug")("startup");
|
|
25
25
|
|
|
26
|
-
module.exports = function
|
|
26
|
+
module.exports = function core(
|
|
27
27
|
uTable,
|
|
28
28
|
useDefault,
|
|
29
29
|
serverMode,
|
|
30
|
-
customize
|
|
30
|
+
customize,
|
|
31
|
+
swaggerfcn
|
|
31
32
|
) {
|
|
32
33
|
let argv = require("yargs").argv;
|
|
33
34
|
let env = argv.env == null ? null : argv.env;
|
|
34
35
|
let appenv = argv.appenv == null ? null : argv.appenv;
|
|
35
36
|
let docker = argv.docker == null ? null : argv.docker;
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
//process.env.SERVERMODE = serverMode !== null ? "api" : "app";
|
|
38
|
+
|
|
38
39
|
|
|
39
40
|
if (useDefault == null) {
|
|
40
41
|
useDefault = true;
|
|
@@ -48,8 +49,7 @@ module.exports = function appServer(
|
|
|
48
49
|
Dockerfile: ${docker}
|
|
49
50
|
env file : ${env}
|
|
50
51
|
appenv : ${appenv}
|
|
51
|
-
customize : ${customize != null}
|
|
52
|
-
serverMode: ${serverMode}
|
|
52
|
+
customize : ${customize != null}
|
|
53
53
|
`
|
|
54
54
|
);
|
|
55
55
|
|
|
@@ -122,13 +122,19 @@ function getAllEnv(userData) {
|
|
|
122
122
|
host = null;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/*
|
|
125
126
|
if (process.env.AUTHTYPE != null) {
|
|
126
127
|
process.env.AUTHFLOW = process.env.AUTHTYPE;
|
|
127
128
|
}
|
|
129
|
+
*/
|
|
128
130
|
|
|
129
131
|
let authflow = trimit("AUTHFLOW");
|
|
130
132
|
if (authflow === "authorization_code" || authflow === "code") {
|
|
131
133
|
authflow = "server";
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (authflow === null) {
|
|
137
|
+
host = null;
|
|
132
138
|
}
|
|
133
139
|
|
|
134
140
|
if (host === null) {
|
package/src/parseDocker.js
CHANGED
|
@@ -165,7 +165,6 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
165
165
|
`let LOGONPAYLOAD = ${JSON.stringify(allAppEnv.LOGONPAYLOAD)};` +
|
|
166
166
|
`let APPENV = ${JSON.stringify(allAppEnv.APPENV)};`;
|
|
167
167
|
if (process.env.SHOWENV != null) {
|
|
168
|
-
console.log(options.allAppEnv);
|
|
169
168
|
console.log(s);
|
|
170
169
|
}
|
|
171
170
|
debug(s);
|
|
@@ -192,15 +191,15 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
192
191
|
`let LOGONPAYLOAD = ${JSON.stringify(allAppEnv.LOGONPAYLOAD)};` +
|
|
193
192
|
`let APPENV = ${JSON.stringify(allAppEnv.APPENV)};`;
|
|
194
193
|
if (process.env.SHOWENV != null) {
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
debug(options.allAppEnv);
|
|
195
|
+
|
|
197
196
|
}
|
|
198
197
|
debug(s)
|
|
199
198
|
return s;
|
|
200
199
|
},
|
|
201
200
|
},
|
|
202
201
|
},
|
|
203
|
-
|
|
202
|
+
/*
|
|
204
203
|
{
|
|
205
204
|
method: ["GET"],
|
|
206
205
|
path: `${appName}/{param*}`,
|
|
@@ -210,6 +209,7 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
210
209
|
handler: getApp2,
|
|
211
210
|
},
|
|
212
211
|
},
|
|
212
|
+
*/
|
|
213
213
|
|
|
214
214
|
{
|
|
215
215
|
method: ["GET"],
|
|
@@ -238,7 +238,6 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
238
238
|
},
|
|
239
239
|
];
|
|
240
240
|
|
|
241
|
-
if (process.env.PROXYSERVER != null) {
|
|
242
241
|
let pr = {
|
|
243
242
|
method: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
|
|
244
243
|
path: `${appName}/proxy/{param*}`,
|
|
@@ -252,10 +251,9 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
252
251
|
},
|
|
253
252
|
},
|
|
254
253
|
};
|
|
255
|
-
|
|
254
|
+
debug(pr);
|
|
256
255
|
defaultTable.push(pr);
|
|
257
|
-
|
|
258
|
-
console.log(uTable);
|
|
256
|
+
|
|
259
257
|
let routeTables =
|
|
260
258
|
uTable !== null ? defaultTable.concat(uTable) : defaultTable;
|
|
261
259
|
server.route(routeTables);
|