@sassoftware/viya-serverjs 0.2.1 → 0.2.3
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/.env +4 -4
- package/.env.proxy +4 -3
- package/.env.server +5 -4
- package/Dockerfile +3 -3
- package/cli.js +2 -2
- package/lib/config.js +62 -62
- package/lib/handlers/logon.js +39 -39
- package/lib/handlers/proxyMapUri.js +49 -75
- package/lib/handlers/setCookies.js +73 -72
- package/lib/iService.js +401 -450
- package/lib/plugins/appCookie.js +98 -98
- package/lib/plugins/setDefaultRoutes.js +272 -222
- package/lib/plugins/setupAuth.js +68 -67
- package/package.json +1 -1
- package/public/index.html +8 -2
- package/public/indexProxy.html +1 -0
- package/server.js +5 -116
- package/src/handlers/proxyMapUri.js +2 -30
- package/src/handlers/setCookies.js +3 -1
- package/src/iService.js +13 -35
- package/src/plugins/appCookie.js +3 -3
- package/src/plugins/setDefaultRoutes.js +7 -3
- package/src/plugins/setupAuth.js +3 -1
- package/{packages/examples/app/certs/tls.sh → tls/viyatls.sh} +0 -2
- package/packages/core/config.js +0 -86
- package/packages/core/handlers/appCallback.js +0 -40
- package/packages/core/handlers/codeAuth.js +0 -31
- package/packages/core/handlers/decodeJwt.js +0 -11
- package/packages/core/handlers/favicon.js +0 -24
- package/packages/core/handlers/getApp.js +0 -41
- package/packages/core/handlers/getApp2.js +0 -26
- package/packages/core/handlers/getUser.js +0 -20
- package/packages/core/handlers/index.js +0 -36
- package/packages/core/handlers/keepAlive.js +0 -54
- package/packages/core/handlers/keepAlive2.js +0 -13
- package/packages/core/handlers/logon.js +0 -24
- package/packages/core/handlers/logout.js +0 -43
- package/packages/core/handlers/proxyMapUri.js +0 -53
- package/packages/core/handlers/proxyOnResponse.js +0 -12
- package/packages/core/handlers/reactDev.js +0 -30
- package/packages/core/handlers/setCookies.js +0 -78
- package/packages/core/iService.js +0 -369
- package/packages/core/index.js +0 -249
- package/packages/core/parseDocker.js +0 -33
- package/packages/core/plugins/SASauth.js +0 -79
- package/packages/core/plugins/appCookie.js +0 -49
- package/packages/core/plugins/setContext.js +0 -34
- package/packages/core/plugins/setDefaultRoutes.js +0 -262
- package/packages/core/plugins/setupAuth.js +0 -48
- package/packages/core/plugins/setupUserRoutes.js +0 -48
- package/packages/core/plugins/token.js +0 -10
- package/packages/core/schemes/SASTokenScheme.js +0 -43
- package/packages/core/visionIndex.html +0 -24
- package/packages/examples/apitest/.env +0 -11
- package/packages/examples/apitest/.eslintrc.json +0 -42
- package/packages/examples/apitest/Dockerfile +0 -41
- package/packages/examples/apitest/api.js +0 -88
- package/packages/examples/apitest/appenv.js +0 -6
- package/packages/examples/apitest/docker-compose.yml +0 -10
- package/packages/examples/apitest/package.json +0 -19
- package/packages/examples/apitest/public/data/Cluster_SDOH1.sas +0 -182
- package/packages/examples/apitest/public/data/Cluster_SDOH6.sas +0 -180
- package/packages/examples/apitest/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/apitest/public/data/NeuralNetwork_High_med.sas +0 -2409
- package/packages/examples/apitest/public/data/NeuralNetwork_high_med1.sas +0 -2409
- package/packages/examples/apitest/public/data/ast/GBlocalcopy.sasast +0 -0
- package/packages/examples/apitest/public/data/ast/LeNet_snzrle.astore +0 -0
- package/packages/examples/apitest/public/data/ast/gb_IrisGB.sasast +0 -0
- package/packages/examples/apitest/public/data/ast/paysimsvdd.sasast +0 -0
- package/packages/examples/apitest/public/data/ast/svmlocalcopy.sasast +0 -0
- package/packages/examples/apitest/public/data/cars.csv +0 -429
- package/packages/examples/apitest/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/apitest/public/data/cmdList.txt +0 -15
- package/packages/examples/apitest/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/apitest/public/data/iris.csv +0 -151
- package/packages/examples/apitest/public/data/model1.sas7bdat +0 -0
- package/packages/examples/apitest/public/favicon.ico +0 -0
- package/packages/examples/apitest/public/index.html +0 -316
- package/packages/examples/apitest/public/index2.html +0 -102
- package/packages/examples/apitest/public/logon.html +0 -42
- package/packages/examples/apitest/public/myapp/secondary.html +0 -1
- package/packages/examples/apitest/public/myapp/test.js +0 -2
- package/packages/examples/apitest/public/onlogoff.html +0 -53
- package/packages/examples/apitest/start.sh +0 -15
- package/packages/examples/app/.env +0 -32
- package/packages/examples/app/.envProxy +0 -19
- package/packages/examples/app/.envimpl +0 -12
- package/packages/examples/app/.eslintrc.json +0 -42
- package/packages/examples/app/Dockerfile +0 -42
- package/packages/examples/app/appenv.js +0 -6
- package/packages/examples/app/certs/ca.crt +0 -19
- package/packages/examples/app/certs/tls.crt +0 -25
- package/packages/examples/app/certs/tls.key +0 -28
- package/packages/examples/app/docker-compose.yml +0 -12
- package/packages/examples/app/index.js +0 -15
- package/packages/examples/app/package.json +0 -20
- package/packages/examples/app/public/casread.html +0 -324
- package/packages/examples/app/public/data/Cluster_SDOH1.sas +0 -182
- package/packages/examples/app/public/data/Cluster_SDOH6.sas +0 -180
- package/packages/examples/app/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/app/public/data/NeuralNetwork_High_med.sas +0 -2409
- package/packages/examples/app/public/data/NeuralNetwork_high_med1.sas +0 -2409
- package/packages/examples/app/public/data/ast/GBlocalcopy.sasast +0 -0
- package/packages/examples/app/public/data/ast/LeNet_snzrle.astore +0 -0
- package/packages/examples/app/public/data/ast/gb_IrisGB.sasast +0 -0
- package/packages/examples/app/public/data/ast/paysimsvdd.sasast +0 -0
- package/packages/examples/app/public/data/ast/svmlocalcopy.sasast +0 -0
- package/packages/examples/app/public/data/cars.csv +0 -429
- package/packages/examples/app/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/app/public/data/cmdList.txt +0 -15
- package/packages/examples/app/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/app/public/data/iris.csv +0 -151
- package/packages/examples/app/public/data/model1.sas7bdat +0 -0
- package/packages/examples/app/public/favicon.ico +0 -0
- package/packages/examples/app/public/index.html +0 -332
- package/packages/examples/app/public/indexProxy.html +0 -346
- package/packages/examples/app/public/indextest.html +0 -316
- package/packages/examples/app/public/logon.html +0 -44
- package/packages/examples/app/public/micburger.html +0 -345
- package/packages/examples/app/public/micburger.txt.html +0 -311
- package/packages/examples/app/public/myapp/secondary.html +0 -1
- package/packages/examples/app/public/myapp/test.js +0 -2
- package/packages/examples/app/public/sara.txt +0 -345
- package/packages/examples/app/public/testva2.html +0 -311
- package/packages/examples/app/startup.sh +0 -15
- package/packages/examples/appdocker/.env +0 -21
- package/packages/examples/appdocker/.envProxy +0 -22
- package/packages/examples/appdocker/.envimpl +0 -12
- package/packages/examples/appdocker/.eslintrc.json +0 -42
- package/packages/examples/appdocker/Dockerfile +0 -43
- package/packages/examples/appdocker/appenv.js +0 -6
- package/packages/examples/appdocker/certs/ca.crt +0 -19
- package/packages/examples/appdocker/certs/tls.crt +0 -25
- package/packages/examples/appdocker/certs/tls.key +0 -28
- package/packages/examples/appdocker/certs/tls.sh +0 -5
- package/packages/examples/appdocker/docker-compose.yml +0 -12
- package/packages/examples/appdocker/index.js +0 -15
- package/packages/examples/appdocker/package.json +0 -20
- package/packages/examples/appdocker/public/data/Cluster_SDOH1.sas +0 -182
- package/packages/examples/appdocker/public/data/Cluster_SDOH6.sas +0 -180
- package/packages/examples/appdocker/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/appdocker/public/data/NeuralNetwork_High_med.sas +0 -2409
- package/packages/examples/appdocker/public/data/NeuralNetwork_high_med1.sas +0 -2409
- package/packages/examples/appdocker/public/data/ast/GBlocalcopy.sasast +0 -0
- package/packages/examples/appdocker/public/data/ast/LeNet_snzrle.astore +0 -0
- package/packages/examples/appdocker/public/data/ast/gb_IrisGB.sasast +0 -0
- package/packages/examples/appdocker/public/data/ast/paysimsvdd.sasast +0 -0
- package/packages/examples/appdocker/public/data/ast/svmlocalcopy.sasast +0 -0
- package/packages/examples/appdocker/public/data/cars.csv +0 -429
- package/packages/examples/appdocker/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/appdocker/public/data/cmdList.txt +0 -15
- package/packages/examples/appdocker/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/appdocker/public/data/iris.csv +0 -151
- package/packages/examples/appdocker/public/data/model1.sas7bdat +0 -0
- package/packages/examples/appdocker/public/favicon.ico +0 -0
- package/packages/examples/appdocker/public/index.html +0 -346
- package/packages/examples/appdocker/public/indexProxy.html +0 -346
- package/packages/examples/appdocker/public/indextest.html +0 -316
- package/packages/examples/appdocker/public/logon.html +0 -44
- package/packages/examples/appdocker/public/myapp/secondary.html +0 -1
- package/packages/examples/appdocker/public/myapp/test.js +0 -2
- package/packages/examples/appdocker/startup.sh +0 -15
- package/packages/examples/apptest/.env +0 -28
- package/packages/examples/apptest/.envProxy +0 -22
- package/packages/examples/apptest/.envimpl +0 -12
- package/packages/examples/apptest/.eslintrc.json +0 -42
- package/packages/examples/apptest/Dockerfile +0 -44
- package/packages/examples/apptest/appDir/app1/design.html +0 -350
- package/packages/examples/apptest/appDir/app1/index.html +0 -353
- package/packages/examples/apptest/appDir/index.html +0 -350
- package/packages/examples/apptest/appenv.js +0 -6
- package/packages/examples/apptest/docker-compose.yml +0 -12
- package/packages/examples/apptest/index.js +0 -444
- package/packages/examples/apptest/package.json +0 -24
- package/packages/examples/apptest/public/casread2.html +0 -321
- package/packages/examples/apptest/public/data/Cluster_SDOH1.sas +0 -182
- package/packages/examples/apptest/public/data/Cluster_SDOH6.sas +0 -180
- package/packages/examples/apptest/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/apptest/public/data/NeuralNetwork_High_med.sas +0 -2409
- package/packages/examples/apptest/public/data/NeuralNetwork_high_med1.sas +0 -2409
- package/packages/examples/apptest/public/data/ast/GBlocalcopy.sasast +0 -0
- package/packages/examples/apptest/public/data/ast/LeNet_snzrle.astore +0 -0
- package/packages/examples/apptest/public/data/ast/gb_IrisGB.sasast +0 -0
- package/packages/examples/apptest/public/data/ast/paysimsvdd.sasast +0 -0
- package/packages/examples/apptest/public/data/ast/svmlocalcopy.sasast +0 -0
- package/packages/examples/apptest/public/data/cars.csv +0 -429
- package/packages/examples/apptest/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/apptest/public/data/cmdList.txt +0 -15
- package/packages/examples/apptest/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/apptest/public/data/iris.csv +0 -151
- package/packages/examples/apptest/public/data/model1.sas7bdat +0 -0
- package/packages/examples/apptest/public/design.html +0 -349
- package/packages/examples/apptest/public/favicon.ico +0 -0
- package/packages/examples/apptest/public/help.html +0 -1
- package/packages/examples/apptest/public/index.html +0 -353
- package/packages/examples/apptest/public/index2.html +0 -353
- package/packages/examples/apptest/public/indexProxy.html +0 -346
- package/packages/examples/apptest/public/indextest.html +0 -316
- package/packages/examples/apptest/public/logon.html +0 -44
- package/packages/examples/apptest/public/myapp/q.html +0 -349
- package/packages/examples/apptest/public/myapp/secondary.html +0 -1
- package/packages/examples/apptest/public/myapp/test.js +0 -2
- package/packages/examples/apptest/public/push1.html +0 -187
- package/packages/examples/apptest/startup.sh +0 -15
- package/packages/examples/apptesti/.env +0 -13
- package/packages/examples/apptesti/.eslintrc.json +0 -42
- package/packages/examples/apptesti/Dockerfile +0 -42
- package/packages/examples/apptesti/appenv.js +0 -6
- package/packages/examples/apptesti/certs/ca.crt +0 -19
- package/packages/examples/apptesti/certs/tls.crt +0 -25
- package/packages/examples/apptesti/certs/tls.key +0 -28
- package/packages/examples/apptesti/certs/tls.sh +0 -5
- package/packages/examples/apptesti/docker-compose.yml +0 -12
- package/packages/examples/apptesti/index.js +0 -7
- package/packages/examples/apptesti/package.json +0 -20
- package/packages/examples/apptesti/public/data/Cluster_SDOH1.sas +0 -182
- package/packages/examples/apptesti/public/data/Cluster_SDOH6.sas +0 -180
- package/packages/examples/apptesti/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/apptesti/public/data/NeuralNetwork_High_med.sas +0 -2409
- package/packages/examples/apptesti/public/data/NeuralNetwork_high_med1.sas +0 -2409
- package/packages/examples/apptesti/public/data/ast/GBlocalcopy.sasast +0 -0
- package/packages/examples/apptesti/public/data/ast/LeNet_snzrle.astore +0 -0
- package/packages/examples/apptesti/public/data/ast/gb_IrisGB.sasast +0 -0
- package/packages/examples/apptesti/public/data/ast/paysimsvdd.sasast +0 -0
- package/packages/examples/apptesti/public/data/ast/svmlocalcopy.sasast +0 -0
- package/packages/examples/apptesti/public/data/cars.csv +0 -429
- package/packages/examples/apptesti/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/apptesti/public/data/cmdList.txt +0 -15
- package/packages/examples/apptesti/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/apptesti/public/data/iris.csv +0 -151
- package/packages/examples/apptesti/public/data/model1.sas7bdat +0 -0
- package/packages/examples/apptesti/public/favicon.ico +0 -0
- package/packages/examples/apptesti/public/index.html +0 -346
- package/packages/examples/apptesti/public/indexProxy.html +0 -346
- package/packages/examples/apptesti/public/indextest.html +0 -316
- package/packages/examples/apptesti/public/logon.html +0 -44
- package/packages/examples/apptesti/public/main.html +0 -346
- package/packages/examples/apptesti/public/myapp/secondary.html +0 -1
- package/packages/examples/apptesti/public/myapp/test.js +0 -2
- package/packages/examples/apptesti/startup.sh +0 -15
- package/packages/examples/basic/.env +0 -10
- package/packages/examples/basic/.eslintrc.json +0 -42
- package/packages/examples/basic/Dockerfile +0 -41
- package/packages/examples/basic/api.js +0 -88
- package/packages/examples/basic/appenv.js +0 -6
- package/packages/examples/basic/docker-compose.yml +0 -10
- package/packages/examples/basic/package.json +0 -19
- package/packages/examples/basic/public/data/Cluster_SDOH1.sas +0 -182
- package/packages/examples/basic/public/data/Cluster_SDOH6.sas +0 -180
- package/packages/examples/basic/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/basic/public/data/NeuralNetwork_High_med.sas +0 -2409
- package/packages/examples/basic/public/data/NeuralNetwork_high_med1.sas +0 -2409
- package/packages/examples/basic/public/data/ast/GBlocalcopy.sasast +0 -0
- package/packages/examples/basic/public/data/ast/LeNet_snzrle.astore +0 -0
- package/packages/examples/basic/public/data/ast/gb_IrisGB.sasast +0 -0
- package/packages/examples/basic/public/data/ast/paysimsvdd.sasast +0 -0
- package/packages/examples/basic/public/data/ast/svmlocalcopy.sasast +0 -0
- package/packages/examples/basic/public/data/cars.csv +0 -429
- package/packages/examples/basic/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/basic/public/data/cmdList.txt +0 -15
- package/packages/examples/basic/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/basic/public/data/iris.csv +0 -151
- package/packages/examples/basic/public/data/model1.sas7bdat +0 -0
- package/packages/examples/basic/public/favicon.ico +0 -0
- package/packages/examples/basic/public/index.html +0 -29
- package/packages/examples/basic/public/index2.html +0 -102
- package/packages/examples/basic/public/logon.html +0 -42
- package/packages/examples/basic/public/myapp/secondary.html +0 -1
- package/packages/examples/basic/public/myapp/test.js +0 -2
- package/packages/examples/basic/public/onlogoff.html +0 -53
- package/packages/examples/basic/start.sh +0 -15
- package/packages/examples/proxytest/.env +0 -23
- package/packages/examples/proxytest/.envimpl +0 -11
- package/packages/examples/proxytest/.eslintrc.json +0 -42
- package/packages/examples/proxytest/Dockerfile +0 -42
- package/packages/examples/proxytest/appenv.js +0 -6
- package/packages/examples/proxytest/docker-compose.yml +0 -12
- package/packages/examples/proxytest/index.js +0 -57
- package/packages/examples/proxytest/package.json +0 -18
- package/packages/examples/proxytest/public/data/Cluster_SDOH1.sas +0 -182
- package/packages/examples/proxytest/public/data/Cluster_SDOH6.sas +0 -180
- package/packages/examples/proxytest/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/proxytest/public/data/NeuralNetwork_High_med.sas +0 -2409
- package/packages/examples/proxytest/public/data/NeuralNetwork_high_med1.sas +0 -2409
- package/packages/examples/proxytest/public/data/ast/GBlocalcopy.sasast +0 -0
- package/packages/examples/proxytest/public/data/ast/LeNet_snzrle.astore +0 -0
- package/packages/examples/proxytest/public/data/ast/gb_IrisGB.sasast +0 -0
- package/packages/examples/proxytest/public/data/ast/paysimsvdd.sasast +0 -0
- package/packages/examples/proxytest/public/data/ast/svmlocalcopy.sasast +0 -0
- package/packages/examples/proxytest/public/data/cars.csv +0 -429
- package/packages/examples/proxytest/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/proxytest/public/data/cmdList.txt +0 -15
- package/packages/examples/proxytest/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/proxytest/public/data/iris.csv +0 -151
- package/packages/examples/proxytest/public/data/model1.sas7bdat +0 -0
- package/packages/examples/proxytest/public/favicon.ico +0 -0
- package/packages/examples/proxytest/public/index.html +0 -357
- package/packages/examples/proxytest/public/index.js +0 -57
- package/packages/examples/proxytest/public/indextest.html +0 -316
- package/packages/examples/proxytest/public/logon.html +0 -44
- package/packages/examples/proxytest/public/main.html +0 -357
- package/packages/examples/proxytest/public/myapp/secondary.html +0 -1
- package/packages/examples/proxytest/public/myapp/test.js +0 -2
- package/packages/examples/proxytest/public/restaf.js +0 -2461
- package/packages/examples/proxytest/public/restaf.min.js +0 -11
- package/packages/examples/proxytest/public/sas/iris.txt +0 -10
- package/packages/examples/proxytest/startup.sh +0 -15
- package/public/casread2.html +0 -321
- package/public/design.html +0 -350
- package/public/display.html +0 -354
- package/public/index2.html +0 -353
- package/public/indextest.html +0 -316
- package/public/logon.html +0 -44
- package/public/myapp/q.html +0 -349
- package/public/myapp/secondary.html +0 -1
- package/public/myapp/test.js +0 -2
- package/public/push1.html +0 -187
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ------------------------------------------------------------------------------------
|
|
3
|
-
* * Copyright (c) SAS Institute Inc.
|
|
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
|
-
*/
|
|
18
|
-
|
|
19
|
-
let fs = require('fs');
|
|
20
|
-
let debug = require('debug')('service');
|
|
21
|
-
let debug2 = require('debug')('tls');
|
|
22
|
-
// let isDocker = require('is-docker');
|
|
23
|
-
let Hapi = require('@hapi/hapi');
|
|
24
|
-
let H202 = require('@hapi/h2o2');
|
|
25
|
-
// const { isSameSiteNoneCompatible } = require('should-send-same-site-none');
|
|
26
|
-
let NodeCache = require("node-cache-promise");
|
|
27
|
-
let Vision = require('@hapi/vision');
|
|
28
|
-
let inert = require('@hapi/inert');
|
|
29
|
-
let selfsigned = require('selfsigned');
|
|
30
|
-
import setupAuth from './plugins/setupAuth';
|
|
31
|
-
|
|
32
|
-
let os = require('os');
|
|
33
|
-
|
|
34
|
-
function iService (userRouteTable, useDefault, asset, allAppEnv, serverMode, userInfo) {
|
|
35
|
-
// process.env.APPHOST_ADDR = process.env.APPHOST;
|
|
36
|
-
const init = async () => {
|
|
37
|
-
|
|
38
|
-
if (process.env.APPHOST === '*') {
|
|
39
|
-
process.env.APPHOST = os.hostname();
|
|
40
|
-
}
|
|
41
|
-
let defaultMaxBytes = 10485760;
|
|
42
|
-
let maxBytes;
|
|
43
|
-
if (isNaN(process.env.PAYLOADMAXBYTES)) {
|
|
44
|
-
maxBytes = defaultMaxBytes;
|
|
45
|
-
} else {
|
|
46
|
-
maxBytes = Number(process.env.PAYLOADMAXBYTES);
|
|
47
|
-
}
|
|
48
|
-
let isSameSite = 'None';
|
|
49
|
-
let isSecure = false;
|
|
50
|
-
|
|
51
|
-
if (process.env.SAMESITE != null) {
|
|
52
|
-
let [s1, s2] = process.env.SAMESITE.split(',');
|
|
53
|
-
isSameSite = s1;
|
|
54
|
-
isSecure = s2 === 'secure' ? true : false;
|
|
55
|
-
if (process.env.HTTPS !== 'true') {
|
|
56
|
-
isSecure = false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
let sConfig = {
|
|
62
|
-
port: process.env.APPPORT,
|
|
63
|
-
host: process.env.APPHOST,
|
|
64
|
-
|
|
65
|
-
state: {
|
|
66
|
-
isSameSite: isSameSite,
|
|
67
|
-
isSecure : isSecure,
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
routes: {
|
|
73
|
-
payload: {
|
|
74
|
-
maxBytes: maxBytes
|
|
75
|
-
},
|
|
76
|
-
cors: {
|
|
77
|
-
origin : ['*'],
|
|
78
|
-
credentials: true,
|
|
79
|
-
|
|
80
|
-
"headers": ["Accept", "Authorization", "Content-Type", "If-None-Match", "Accept-language"]
|
|
81
|
-
/*
|
|
82
|
-
'Access-Control-Allow-Methods': ['GET', 'POST', 'OPTIONS'],
|
|
83
|
-
additionalHeaders : ['multipart/form-data', 'content-disposition'],
|
|
84
|
-
additionalExposedHeaders : ['location'],
|
|
85
|
-
*/
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
if (process.env.HAPIDEBUG === 'YES') {
|
|
91
|
-
sConfig.debug = { request: '*' };
|
|
92
|
-
}
|
|
93
|
-
debug(JSON.stringify(sConfig, null,4));
|
|
94
|
-
if (process.env.HTTPS === 'true') {
|
|
95
|
-
sConfig.tls = await getCertificates();
|
|
96
|
-
debug('Setup of SSL certificates completed');
|
|
97
|
-
} else {
|
|
98
|
-
debug('Running with no SSL certificates');
|
|
99
|
-
}
|
|
100
|
-
if (asset !== null) {
|
|
101
|
-
sConfig.routes.files= { relativeTo: asset };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
debug2(
|
|
105
|
-
`Application information:
|
|
106
|
-
APPLOC : ${process.env.APPLOC}
|
|
107
|
-
APPENTRY: ${process.env.APPENTRY}
|
|
108
|
-
`
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
let hapiServer = Hapi.server(sConfig);
|
|
112
|
-
|
|
113
|
-
/*
|
|
114
|
-
const cache = hapiServer.cache({ segment: 'sessions', expiresIn: 3 * 24 * 60 * 60 * 1000 });
|
|
115
|
-
hapiServer.app.cache = cache;
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
let nodeCacheOptions = {
|
|
119
|
-
stdTTL : 36000,
|
|
120
|
-
checkPeriod : 3600,
|
|
121
|
-
errorOnMissing: true,
|
|
122
|
-
useClones : false,
|
|
123
|
-
deleteOnExpire: true,
|
|
124
|
-
};
|
|
125
|
-
let storeCache = new NodeCache(nodeCacheOptions);
|
|
126
|
-
hapiServer.app.cache = storeCache;
|
|
127
|
-
|
|
128
|
-
// common plugins
|
|
129
|
-
let visionOptions = {
|
|
130
|
-
engines : { html: require('handlebars') },
|
|
131
|
-
relativeTo: __dirname,
|
|
132
|
-
path : '.',
|
|
133
|
-
};
|
|
134
|
-
await hapiServer.register(Vision);
|
|
135
|
-
hapiServer.views(visionOptions);
|
|
136
|
-
await hapiServer.register(inert);
|
|
137
|
-
if (process.env.HTTPS === 'true') {
|
|
138
|
-
await hapiServer.register({ plugin: require('hapi-require-https'), options: {} });
|
|
139
|
-
}
|
|
140
|
-
// register H202 for proxy handling
|
|
141
|
-
// https://hapi.dev/module/h2o2/api/?v=10.0.1
|
|
142
|
-
|
|
143
|
-
await hapiServer.register(H202);
|
|
144
|
-
/*
|
|
145
|
-
await hapiServer.register({
|
|
146
|
-
plugin : require('hapi-pino'),
|
|
147
|
-
options: {
|
|
148
|
-
prettyPrint: process.env.NODE_ENV !== 'production',
|
|
149
|
-
level : process.env.LOGLEVEL == null ? 'silent' : process.env.LOGLEVEL,
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
// setup authentication related plugins
|
|
155
|
-
let options = {
|
|
156
|
-
serverMode : (serverMode === null) ? 'app' : 'api', /* api or app */
|
|
157
|
-
authFlow : process.env.AUTHFLOW,
|
|
158
|
-
host : process.env.VIYA_SERVER,
|
|
159
|
-
isSameSite : isSameSite,
|
|
160
|
-
isSecure : isSecure,
|
|
161
|
-
ns : (allAppEnv.LOGONPAYLOAD != null) ? allAppEnv.LOGONPAYLOAD.ns : null,
|
|
162
|
-
nsHost : (allAppEnv.LOGONPAYLOAD != null) ? allAppEnv.LOGONPAYLOAD.nsHost : null,
|
|
163
|
-
redirect : process.env.REDIRECT,
|
|
164
|
-
clientId : process.env.CLIENTID,
|
|
165
|
-
clientSecret : process.env.CLIENTSECRET,
|
|
166
|
-
redirectTo : `/${process.env.APPNAME}/logon`,
|
|
167
|
-
allAppEnv : allAppEnv,
|
|
168
|
-
useHapiCookie : true,
|
|
169
|
-
appName : process.env.APPNAME,
|
|
170
|
-
appHost : process.env.APPHOST,
|
|
171
|
-
appPort : process.env.APPPORT,
|
|
172
|
-
userRouteTable: userRouteTable,
|
|
173
|
-
useDefault : useDefault, /* not used - left here for potential reuse */
|
|
174
|
-
userInfo : userInfo,
|
|
175
|
-
https : process.env.HTTPS,
|
|
176
|
-
authDefault : false, /* set later in setDefaultRoutes */
|
|
177
|
-
authLogon : false /* set later in setDefaultRoutes */
|
|
178
|
-
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
debug2('Options',options);
|
|
182
|
-
if (process.env.AUTHFLOW != null) {
|
|
183
|
-
await setupAuth(hapiServer, options);
|
|
184
|
-
if (process.env.PREAUTH === 'YES') {
|
|
185
|
-
console.log('Preauth enabled');
|
|
186
|
-
hapiServer.ext('onPreAuth', (request, h) => {
|
|
187
|
-
debugger;
|
|
188
|
-
if (!request.auth.isAuthenticated && !request.path.startsWith(`/login`)) {
|
|
189
|
-
const redirectTo = `${request.path}?${new URLSearchParams(request.query).toString()}`;
|
|
190
|
-
console.log('Redirect to login', {redirectTo});
|
|
191
|
-
debugger;
|
|
192
|
-
return h.redirect(`/login`).takeover();
|
|
193
|
-
}
|
|
194
|
-
return h.continue;
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
hapiServer.log('Plugin', process.env.PLUGIN);
|
|
199
|
-
|
|
200
|
-
if (process.env.PLUGIN === 'hapi-swagger' && serverMode !== null) {
|
|
201
|
-
let swaggerOptions = {
|
|
202
|
-
"info": {
|
|
203
|
-
"title" : `API for ${process.env.APPNAME}`,
|
|
204
|
-
"version" : "0.0.1",
|
|
205
|
-
"description": "This document was auto-generated at run time"
|
|
206
|
-
},
|
|
207
|
-
"schemes" : ["http", "https"],
|
|
208
|
-
"cors" : true,
|
|
209
|
-
"debug" : true,
|
|
210
|
-
"jsonPath" : `/${options.appName}/swagger.json`,
|
|
211
|
-
"jsonRoutePath" : `/${options.appName}/swagger.json`,
|
|
212
|
-
"documentationPage": true,
|
|
213
|
-
"documentationPath": `/${options.appName}/documentation`,
|
|
214
|
-
"swaggerUI" : true,
|
|
215
|
-
"swaggerUIPath" : `/${options.appName}/swaggerui`,
|
|
216
|
-
auth : options.authDefault
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
if (userInfo != null) {
|
|
220
|
-
let override = userInfo(options, 'SWAGGEROPTIONS');
|
|
221
|
-
swaggerOptions = {...swaggerOptions, ...override};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
debug('Swagger Options:' ,swaggerOptions);
|
|
225
|
-
await hapiServer.register({ plugin: serverMode, options: swaggerOptions });
|
|
226
|
-
} else if (process.env.PLUGIN == 'hapi-openapi' && serverMode !== null) {
|
|
227
|
-
console.log('hapi-openapi', 'coming soon');
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
//
|
|
232
|
-
// Start server
|
|
233
|
-
//
|
|
234
|
-
// eslint-disable-next-line no-unused-vars
|
|
235
|
-
let allRoutes = hapiServer.table();
|
|
236
|
-
await hapiServer.start();
|
|
237
|
-
let hh = hapiServer.info.uri;
|
|
238
|
-
hh = hh.replace(/0.0.0.0/, 'localhost');
|
|
239
|
-
console.log('====================================================================================');
|
|
240
|
-
console.log('Server Start Time: ', Date());
|
|
241
|
-
let msg =
|
|
242
|
-
options.serverMode === 'app'
|
|
243
|
-
? `Visit ${hh}/${process.env.APPNAME} to access application`
|
|
244
|
-
: `Visit ${hh}/${process.env.APPNAME}/api to access swagger`;
|
|
245
|
-
console.log('\x1b[1m%s\x1b[0m',msg);
|
|
246
|
-
console.log('NOTE: If running in container use the exported port');
|
|
247
|
-
process.env.APPSERVER = `${hh}/${process.env.APPNAME}`;
|
|
248
|
-
process.env.HEALTH = 'true';
|
|
249
|
-
console.log('====================================================================================');
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
process.on('unhandledRejection', (err) => {
|
|
253
|
-
console.log(err);
|
|
254
|
-
process.exit(1);
|
|
255
|
-
});
|
|
256
|
-
init();
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
async function getCertificates () {
|
|
260
|
-
|
|
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
|
-
debug2('TLS_CRT', process.env.TLS_CRT != null);
|
|
269
|
-
debug2('TLS_CREATE', process.env.TLS_CREATE != null);
|
|
270
|
-
if (process.env.TLS_CERT != null && process.env.TLS_CERT.length > 0) {
|
|
271
|
-
/* backward compatability */
|
|
272
|
-
debug2('TLS set: TLS_CERT');
|
|
273
|
-
tls.cert = fs.readFileSync(process.env.TLS_CERT);
|
|
274
|
-
tls.key = fs.readFileSync(process.env.TLS_KEY);
|
|
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;
|
|
280
|
-
}
|
|
281
|
-
} else if (process.env.TLS_CRT != null && process.env.TLS_CRT.trim().length > 0) {
|
|
282
|
-
/* new key names to conform to k8s*/
|
|
283
|
-
debug2('TLS set: TLS_CRT');
|
|
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) {
|
|
290
|
-
/* unsigned certificate */
|
|
291
|
-
debug2('TLS set: TLS_CREATE=', process.env.TLS_CREATE);
|
|
292
|
-
tls = await getTls();
|
|
293
|
-
}
|
|
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 {
|
|
302
|
-
console.log('Warning: The current host protocol is https: No TLS certificate information has been specified.');
|
|
303
|
-
return tls;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
async function getTls () {
|
|
308
|
-
let options = {
|
|
309
|
-
keySize : 2048,
|
|
310
|
-
days : 360,
|
|
311
|
-
algorithm : "sha256",
|
|
312
|
-
clientCertificate: true,
|
|
313
|
-
extensions : {},
|
|
314
|
-
};
|
|
315
|
-
let subjt = process.env.TLS_CREATE.replaceAll('"', '').trim();
|
|
316
|
-
let subj = subjt.split(',');
|
|
317
|
-
|
|
318
|
-
let d = {};
|
|
319
|
-
subj.map(c => {
|
|
320
|
-
let r = c.split(':');
|
|
321
|
-
d[ r[ 0 ] ] = r[ 1 ];
|
|
322
|
-
return { value: r[ 1 ] };
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// TLS_CREATE=C:US,ST:NC,L:Cary,O:SAS Institute,OU:STO,CN:localhost,ALT:na.sas.com
|
|
326
|
-
let attr = [
|
|
327
|
-
{
|
|
328
|
-
name : 'commonName',
|
|
329
|
-
value: d.CN /*process.env.APPHOST*/,
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
name : 'countryName',
|
|
333
|
-
value: d.C
|
|
334
|
-
}, {
|
|
335
|
-
shortName: 'ST',
|
|
336
|
-
value : d.ST
|
|
337
|
-
}, {
|
|
338
|
-
name : 'localityName',
|
|
339
|
-
value: d.L,
|
|
340
|
-
}, {
|
|
341
|
-
name : 'organizationName',
|
|
342
|
-
value: d.O
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
shortName: 'OU',
|
|
346
|
-
value : d.OU
|
|
347
|
-
}
|
|
348
|
-
];
|
|
349
|
-
|
|
350
|
-
options.extensions.altNames = [
|
|
351
|
-
// { type: 6, value: `http://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}` },
|
|
352
|
-
{ type: 6, value: `https://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}` },
|
|
353
|
-
{ type: 6, value: `https://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}/api` },
|
|
354
|
-
{ type: 6, value: `https://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}/logon` },
|
|
355
|
-
{ type: 6, value: `https://${process.env.APPHOST}/${process.env.APPNAME}` },
|
|
356
|
-
{ type: 6, value: `https://${process.env.APPHOST}/${process.env.APPNAME}/api` },
|
|
357
|
-
{ type: 6, value: `https://${process.env.APPHOST}/${process.env.APPNAME}/logon` },
|
|
358
|
-
];
|
|
359
|
-
debug('tls options ', JSON.stringify(options, null,4));
|
|
360
|
-
let pems = selfsigned.generate(attr, options);
|
|
361
|
-
let tls = {
|
|
362
|
-
cert: pems.cert,
|
|
363
|
-
key : pems.private
|
|
364
|
-
};
|
|
365
|
-
return tls;
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
export default iService;
|
package/packages/core/index.js
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ------------------------------------------------------------------------------------
|
|
3
|
-
* * Copyright (c) SAS Institute Inc.
|
|
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
|
-
*/
|
|
18
|
-
|
|
19
|
-
import "core-js/stable";
|
|
20
|
-
import "regenerator-runtime/runtime";
|
|
21
|
-
import fs from "fs";
|
|
22
|
-
import iService from "./iService";
|
|
23
|
-
import config from "./config";
|
|
24
|
-
let debug = require("debug")("startup");
|
|
25
|
-
|
|
26
|
-
module.exports = function core (
|
|
27
|
-
uTable,
|
|
28
|
-
useDefault,
|
|
29
|
-
serverMode,
|
|
30
|
-
customize,
|
|
31
|
-
swaggerfcn
|
|
32
|
-
) {
|
|
33
|
-
let argv = require("yargs").argv;
|
|
34
|
-
let env = argv.env == null ? null : argv.env;
|
|
35
|
-
let appenv = argv.appenv == null ? null : argv.appenv;
|
|
36
|
-
let docker = argv.docker == null ? null : argv.docker;
|
|
37
|
-
process.env.SERVERMODE = serverMode !== null ? "api" : "app";
|
|
38
|
-
|
|
39
|
-
if (useDefault == null) {
|
|
40
|
-
useDefault = true;
|
|
41
|
-
}
|
|
42
|
-
console.log(
|
|
43
|
-
"Initialization started ============================================================"
|
|
44
|
-
);
|
|
45
|
-
console.log(`version: 2, Build Date: `, Date());
|
|
46
|
-
console.log(
|
|
47
|
-
`\nCommand Line Configuration:
|
|
48
|
-
Dockerfile: ${docker}
|
|
49
|
-
env file : ${env}
|
|
50
|
-
appenv : ${appenv}
|
|
51
|
-
customize : ${customize != null}
|
|
52
|
-
`
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
iapp(null, env, docker, uTable, useDefault, serverMode, customize);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
function iapp (
|
|
59
|
-
appSrc,
|
|
60
|
-
rafEnv,
|
|
61
|
-
dockerFile,
|
|
62
|
-
uTable,
|
|
63
|
-
useDefault,
|
|
64
|
-
serverMode,
|
|
65
|
-
customize
|
|
66
|
-
) {
|
|
67
|
-
let asset = setup(rafEnv, dockerFile);
|
|
68
|
-
if (appSrc == null) {
|
|
69
|
-
appSrc = process.env.APPENV == null ? null : process.env.APPENV;
|
|
70
|
-
}
|
|
71
|
-
if (appSrc != null) {
|
|
72
|
-
console.log("appSrc",`+${appSrc}+`);
|
|
73
|
-
createPayload(appSrc, (err, r) => {
|
|
74
|
-
if (err) {
|
|
75
|
-
console.log(err);
|
|
76
|
-
console.log("createPayload failed");
|
|
77
|
-
process.exit(1);
|
|
78
|
-
} else {
|
|
79
|
-
iService(uTable, useDefault, asset, r, serverMode, customize);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
} else {
|
|
83
|
-
let appEnv = getAllEnv({});
|
|
84
|
-
iService(uTable, useDefault, asset, appEnv, serverMode, customize);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function setup (rafEnv, dockerFile) {
|
|
89
|
-
config(rafEnv, dockerFile);
|
|
90
|
-
let asset = process.env.APPLOC === "." ? process.cwd() : process.env.APPLOC;
|
|
91
|
-
process.env.APPASSET = asset;
|
|
92
|
-
return asset;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function createPayload (srcName, cb) {
|
|
96
|
-
let src = fs.readFileSync(srcName, "utf8");
|
|
97
|
-
if (src === null) {
|
|
98
|
-
cb(`Error: ${srcName} was not found. `);
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
// console.log(src);
|
|
102
|
-
let f = new Function(src);
|
|
103
|
-
console.log(`${srcName} compile completed`);
|
|
104
|
-
let r = f();
|
|
105
|
-
f = null;
|
|
106
|
-
|
|
107
|
-
let ar = getAllEnv(r);
|
|
108
|
-
cb(null, ar);
|
|
109
|
-
} catch (err) {
|
|
110
|
-
console.log(`${srcName} compile failed`);
|
|
111
|
-
cb(err);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function getAllEnv (userData) {
|
|
116
|
-
let env;
|
|
117
|
-
let l = null;
|
|
118
|
-
let host = trimit("VIYA_SERVER");
|
|
119
|
-
if (host === 'none'){
|
|
120
|
-
host = null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (process.env.AUTHTYPE != null) {
|
|
124
|
-
process.env.AUTHFLOW = process.env.AUTHTYPE;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
let authflow = trimit("AUTHFLOW");
|
|
128
|
-
if (authflow === "authorization_code" || authflow === "code") {
|
|
129
|
-
authflow = "server";
|
|
130
|
-
}
|
|
131
|
-
if (host === null ) {
|
|
132
|
-
authflow = "none";
|
|
133
|
-
}
|
|
134
|
-
process.env.AUTHFLOW = authflow;
|
|
135
|
-
// let redirect = (process.env.REDIRECT != null) ? process.env.REDIRECT : null;
|
|
136
|
-
let redirect = trimit("REDIRECT");
|
|
137
|
-
|
|
138
|
-
let clientID = trimit("CLIENTID");
|
|
139
|
-
|
|
140
|
-
// eslint-disable-next-line no-unused-vars
|
|
141
|
-
let clientSecret = trimit("CLIENTSECRET");
|
|
142
|
-
let keepAlive = trimit("KEEPALIVE");
|
|
143
|
-
let appName = trimit("APPNAME");
|
|
144
|
-
let ns = trimit("NAMESPACE");
|
|
145
|
-
let nsHost = trimit("NSHOST");
|
|
146
|
-
|
|
147
|
-
l = {
|
|
148
|
-
authType: authflow,
|
|
149
|
-
redirect: redirect,
|
|
150
|
-
|
|
151
|
-
host : host,
|
|
152
|
-
clientID: clientID,
|
|
153
|
-
appName : appName,
|
|
154
|
-
|
|
155
|
-
keepAlive: null,
|
|
156
|
-
useToken : process.env.USETOKEN,
|
|
157
|
-
|
|
158
|
-
ns : ns,
|
|
159
|
-
nsHost: nsHost,
|
|
160
|
-
};
|
|
161
|
-
if (authflow === "server" || authflow === "implicit") {
|
|
162
|
-
if (authflow === "implicit") {
|
|
163
|
-
if (redirect === null) {
|
|
164
|
-
redirect = `${appName}/callback`;
|
|
165
|
-
process.env.REDIRECT = "callback";
|
|
166
|
-
} else {
|
|
167
|
-
if (redirect !== null && redirect.indexOf("/") !== 0) {
|
|
168
|
-
redirect =
|
|
169
|
-
redirect.indexOf("http") != -1
|
|
170
|
-
? redirect
|
|
171
|
-
: `${process.env.APPNAME}/${redirect}`;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
l = {
|
|
176
|
-
authType : authflow,
|
|
177
|
-
redirect : redirect,
|
|
178
|
-
host : host,
|
|
179
|
-
clientID : clientID,
|
|
180
|
-
appName : appName,
|
|
181
|
-
keepAlive: null,
|
|
182
|
-
useToken : process.env.USETOKEN,
|
|
183
|
-
ns : ns,
|
|
184
|
-
nsHost : nsHost,
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
if (authflow === "server" && keepAlive === "YES") {
|
|
188
|
-
let protocol = process.env.HTTPS === "true" ? "https://" : "http://";
|
|
189
|
-
l.keepAlive = `${protocol}${process.env.APPHOST}:${process.env.APPPORT}/${appName}/keepAlive`;
|
|
190
|
-
l.keepAlive = l.keepAlive.replace(/0.0.0.0/, "localhost");
|
|
191
|
-
}
|
|
192
|
-
if (process.env.TIMERS != null) {
|
|
193
|
-
l.timers = process.env.TIMERS;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
// allow for no authtype
|
|
197
|
-
l = {
|
|
198
|
-
authType: authflow,
|
|
199
|
-
redirect: redirect,
|
|
200
|
-
|
|
201
|
-
host : host,
|
|
202
|
-
clientID: clientID,
|
|
203
|
-
appName : appName,
|
|
204
|
-
|
|
205
|
-
keepAlive: null,
|
|
206
|
-
useToken : process.env.USETOKEN,
|
|
207
|
-
|
|
208
|
-
ns : ns,
|
|
209
|
-
nsHost: nsHost,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// pick up the app env's - replacement for appenv.js
|
|
214
|
-
// appenv.js still supported for backward compatibility
|
|
215
|
-
for (let key in process.env) {
|
|
216
|
-
debug(key);
|
|
217
|
-
if (key.indexOf("APPENV_") === 0) {
|
|
218
|
-
let k = key.substring(7);
|
|
219
|
-
let v = process.env[key];
|
|
220
|
-
if (v != null && v.trim().length > 0) {
|
|
221
|
-
if (v.startsWith('$')) {
|
|
222
|
-
v = process.env[v.substring(1)];
|
|
223
|
-
}
|
|
224
|
-
userData[k] = (v != null) ? v.trim() : null;
|
|
225
|
-
} else {
|
|
226
|
-
userData[k] = null;
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
env = {
|
|
233
|
-
LOGONPAYLOAD: l,
|
|
234
|
-
APPENV : userData,
|
|
235
|
-
};
|
|
236
|
-
console.log("Final APPENV configuration for the server");
|
|
237
|
-
console.log(JSON.stringify(env, null, 4));
|
|
238
|
-
console.log(Date());
|
|
239
|
-
return env;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function trimit (e) {
|
|
243
|
-
let a = process.env[e];
|
|
244
|
-
if (a == null) {
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
a = a.trim();
|
|
248
|
-
return a.length === 0 ? null : a;
|
|
249
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
'use strict';
|
|
6
|
-
let parser = require('docker-file-parser');
|
|
7
|
-
let fs = require('fs');
|
|
8
|
-
|
|
9
|
-
function parseDocker (dockerFile) {
|
|
10
|
-
console.log('Parsing Dockerfile', dockerFile);
|
|
11
|
-
console.log(__dirname);
|
|
12
|
-
let d = fs.readFileSync(dockerFile, 'utf8');
|
|
13
|
-
let data = parser.parse(d);
|
|
14
|
-
data.forEach(d => {
|
|
15
|
-
if (d.name === 'EXPOSE') {
|
|
16
|
-
process.env.EXPOSEDPORT = d.args[0];
|
|
17
|
-
console.log(`Exposed port: ${process.env.EXPOSEDPORT}`);
|
|
18
|
-
} else if (d.name === 'ENV') {
|
|
19
|
-
for (let key in d.args) {
|
|
20
|
-
let v = d.args[key];
|
|
21
|
-
if (v.length === 0) {
|
|
22
|
-
console.log(
|
|
23
|
-
`Value for ${key} inherited as ${process.env[key]}`
|
|
24
|
-
);
|
|
25
|
-
} else {
|
|
26
|
-
process.env[key] = v;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default parseDocker;
|