@sassoftware/viya-serverjs 0.2.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +6 -6
- package/.dockerignore +2 -2
- package/.env +29 -29
- package/.env.proxy +32 -32
- package/.env.server +30 -30
- package/.eslintignore +3 -3
- package/.eslintrc.json +42 -42
- package/Dockerfile +44 -44
- package/README.md +99 -99
- package/cli.js +9 -9
- package/lib/config.js +16 -16
- package/lib/handlers/appCallback.js +23 -24
- package/lib/handlers/codeAuth.js +17 -18
- package/lib/handlers/decodeJwt.js +3 -3
- package/lib/handlers/favicon.js +22 -25
- package/lib/handlers/getApp.js +20 -21
- package/lib/handlers/getApp2.js +22 -25
- package/lib/handlers/getUser.js +14 -17
- package/lib/handlers/index.js +3 -3
- package/lib/handlers/keepAlive.js +28 -31
- package/lib/handlers/keepAlive2.js +9 -12
- package/lib/handlers/logon.js +12 -15
- package/lib/handlers/logout.js +24 -28
- package/lib/handlers/proxyMapUri.js +6 -11
- package/lib/handlers/proxyOnResponse.js +6 -7
- package/lib/handlers/reactDev.js +22 -25
- package/lib/handlers/setCookies.js +52 -53
- package/lib/iService.js +106 -104
- package/lib/index.js +23 -21
- package/lib/parseDocker.js +3 -3
- package/lib/plugins/SASauth.js +30 -32
- package/lib/plugins/appCookie.js +36 -38
- package/lib/plugins/setContext.js +22 -25
- package/lib/plugins/setDefaultRoutes.js +61 -58
- package/lib/plugins/setupAuth.js +35 -38
- package/lib/plugins/setupUserRoutes.js +16 -16
- package/lib/plugins/token.js +9 -10
- package/lib/schemes/SASTokenScheme.js +24 -27
- package/package.json +85 -79
- package/public/data/Cluster_SDOH1.sas +181 -181
- package/public/data/Cluster_SDOH6.sas +179 -179
- package/public/data/NeuralNetwork_High_med.sas +2408 -2408
- package/public/data/NeuralNetwork_high_med1.sas +2408 -2408
- package/public/data/cars.csv +429 -429
- package/public/data/cmdList.txt +15 -15
- package/public/data/iris.csv +151 -151
- package/public/index.html +355 -360
- package/public/indexProxy.html +351 -351
- package/public/simplesubmit.html +233 -0
- package/server.js +362 -362
- package/src/config.js +90 -90
- package/src/handlers/appCallback.js +40 -40
- package/src/handlers/codeAuth.js +31 -31
- package/src/handlers/decodeJwt.js +10 -10
- package/src/handlers/favicon.js +23 -23
- package/src/handlers/getApp.js +52 -52
- package/src/handlers/getApp2.js +25 -25
- package/src/handlers/getUser.js +20 -20
- package/src/handlers/index.js +36 -36
- package/src/handlers/keepAlive.js +53 -53
- package/src/handlers/keepAlive2.js +12 -12
- package/src/handlers/logon.js +23 -23
- package/src/handlers/logout.js +42 -42
- package/src/handlers/proxyMapUri.js +25 -25
- package/src/handlers/proxyOnResponse.js +11 -11
- package/src/handlers/reactDev.js +29 -29
- package/src/handlers/setCookies.js +81 -79
- package/src/iService.js +346 -347
- package/src/index.js +251 -249
- package/src/parseDocker.js +32 -32
- package/src/plugins/SASauth.js +78 -78
- package/src/plugins/appCookie.js +51 -49
- package/src/plugins/setContext.js +33 -33
- package/src/plugins/setDefaultRoutes.js +256 -253
- package/src/plugins/setupAuth.js +49 -49
- package/src/plugins/setupUserRoutes.js +47 -47
- package/src/plugins/token.js +10 -10
- package/src/schemes/SASTokenScheme.js +43 -43
- package/src/visionIndex.html +23 -23
- package/start.sh +14 -14
- package/tls/viyatls.sh +2 -2
|
@@ -1,48 +1,48 @@
|
|
|
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
|
-
import setContext from './setContext';
|
|
19
|
-
|
|
20
|
-
function setupUserRoutes (u, options) {
|
|
21
|
-
if (u == null) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let ux = (typeof u === 'function') ? u() : u;
|
|
26
|
-
let routes = ux.map(rx => {
|
|
27
|
-
//let rx = {...r};
|
|
28
|
-
/* change it to options */
|
|
29
|
-
if (rx.config != null) {
|
|
30
|
-
rx.options = {...rx.config};
|
|
31
|
-
delete rx.config;
|
|
32
|
-
}
|
|
33
|
-
if (rx.options.pre == null) {
|
|
34
|
-
rx.options.pre = [{method: setContext, assign: 'context'}];
|
|
35
|
-
} else{
|
|
36
|
-
rx.options.pre.push([{method: setContext, assign: 'context'}]);
|
|
37
|
-
}
|
|
38
|
-
if (rx.options.auth === true) {
|
|
39
|
-
rx.options.auth = options.authDefault;
|
|
40
|
-
} else if (rx.options.auth === 'logon') {
|
|
41
|
-
rx.options.auth = options.authLogon;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return rx;
|
|
45
|
-
});
|
|
46
|
-
return routes;
|
|
47
|
-
}
|
|
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
|
+
import setContext from './setContext';
|
|
19
|
+
|
|
20
|
+
function setupUserRoutes (u, options) {
|
|
21
|
+
if (u == null) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let ux = (typeof u === 'function') ? u() : u;
|
|
26
|
+
let routes = ux.map(rx => {
|
|
27
|
+
//let rx = {...r};
|
|
28
|
+
/* change it to options */
|
|
29
|
+
if (rx.config != null) {
|
|
30
|
+
rx.options = {...rx.config};
|
|
31
|
+
delete rx.config;
|
|
32
|
+
}
|
|
33
|
+
if (rx.options.pre == null) {
|
|
34
|
+
rx.options.pre = [{method: setContext, assign: 'context'}];
|
|
35
|
+
} else{
|
|
36
|
+
rx.options.pre.push([{method: setContext, assign: 'context'}]);
|
|
37
|
+
}
|
|
38
|
+
if (rx.options.auth === true) {
|
|
39
|
+
rx.options.auth = options.authDefault;
|
|
40
|
+
} else if (rx.options.auth === 'logon') {
|
|
41
|
+
rx.options.auth = options.authLogon;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return rx;
|
|
45
|
+
});
|
|
46
|
+
return routes;
|
|
47
|
+
}
|
|
48
48
|
export default setupUserRoutes;
|
package/src/plugins/token.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
exports.plugin = {
|
|
2
|
-
name : 'token',
|
|
3
|
-
version : '1.0.0',
|
|
4
|
-
register: itoken
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
async function itoken (server){
|
|
8
|
-
await server.auth.scheme('SAStoken',require('../schemes/SASTokenScheme'));
|
|
9
|
-
server.auth.strategy('token', 'SAStoken');
|
|
10
|
-
}
|
|
1
|
+
exports.plugin = {
|
|
2
|
+
name : 'token',
|
|
3
|
+
version : '1.0.0',
|
|
4
|
+
register: itoken
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
async function itoken (server){
|
|
8
|
+
await server.auth.scheme('SAStoken',require('../schemes/SASTokenScheme'));
|
|
9
|
+
server.auth.strategy('token', 'SAStoken');
|
|
10
|
+
}
|
|
@@ -1,43 +1,43 @@
|
|
|
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
|
-
// lean code to handle of incoming tokens if present
|
|
19
|
-
// designed to used with appCookie and SASauth
|
|
20
|
-
|
|
21
|
-
const Boom = require('@hapi/boom');
|
|
22
|
-
|
|
23
|
-
module.exports = function SASTokenScheme (server, options) {
|
|
24
|
-
|
|
25
|
-
const scheme = {
|
|
26
|
-
authenticate: async function (request, h) {
|
|
27
|
-
const authorization = request.headers.authorization;
|
|
28
|
-
server.log('SASToken', authorization);
|
|
29
|
-
|
|
30
|
-
if (!authorization) {
|
|
31
|
-
throw Boom.unauthorized(null, 'session');
|
|
32
|
-
}
|
|
33
|
-
const [tokenType, token] = authorization.split(' ');
|
|
34
|
-
let credentials = {
|
|
35
|
-
token : token,
|
|
36
|
-
tokenType: tokenType
|
|
37
|
-
};
|
|
38
|
-
return h.authenticated({credentials: credentials});
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return scheme;
|
|
43
|
-
};
|
|
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
|
+
// lean code to handle of incoming tokens if present
|
|
19
|
+
// designed to used with appCookie and SASauth
|
|
20
|
+
|
|
21
|
+
const Boom = require('@hapi/boom');
|
|
22
|
+
|
|
23
|
+
module.exports = function SASTokenScheme (server, options) {
|
|
24
|
+
|
|
25
|
+
const scheme = {
|
|
26
|
+
authenticate: async function (request, h) {
|
|
27
|
+
const authorization = request.headers.authorization;
|
|
28
|
+
server.log('SASToken', authorization);
|
|
29
|
+
|
|
30
|
+
if (!authorization) {
|
|
31
|
+
throw Boom.unauthorized(null, 'session');
|
|
32
|
+
}
|
|
33
|
+
const [tokenType, token] = authorization.split(' ');
|
|
34
|
+
let credentials = {
|
|
35
|
+
token : token,
|
|
36
|
+
tokenType: tokenType
|
|
37
|
+
};
|
|
38
|
+
return h.authenticated({credentials: credentials});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return scheme;
|
|
43
|
+
};
|
package/src/visionIndex.html
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<body>
|
|
3
|
-
<div>
|
|
4
|
-
<h1 style="background-color:blue;">{{title}}</h1>
|
|
5
|
-
<div style="border-style:solid; border-width: 2px;"><pre>{{message}}<pre></pre></div>
|
|
6
|
-
</div>
|
|
7
|
-
|
|
8
|
-
<h2>Hints for Logon Error - Contact your administrator</h2>
|
|
9
|
-
|
|
10
|
-
<ul>
|
|
11
|
-
<li>SAMESITE setting is not correct for your environment (contact your administrator)</li>
|
|
12
|
-
<li>Presence of self-signed certificates - might have to set NODE_TLS_REJECT_UNAUTHORIZED=0 in the env file</li>
|
|
13
|
-
<li>You might have to clear the cookies for your Viya Server</li>
|
|
14
|
-
<li>You might have to clear the cookies set by this app server</li>
|
|
15
|
-
</ul>
|
|
16
|
-
|
|
17
|
-
<h2>404</h2>
|
|
18
|
-
<ul>
|
|
19
|
-
<li> Make sure the proper appname is used in script tags for /appenv and /user</li>
|
|
20
|
-
<li> Make sure you are starting the application at the proper url</li>
|
|
21
|
-
</ul>
|
|
22
|
-
|
|
23
|
-
</body>
|
|
1
|
+
<html>
|
|
2
|
+
<body>
|
|
3
|
+
<div>
|
|
4
|
+
<h1 style="background-color:blue;">{{title}}</h1>
|
|
5
|
+
<div style="border-style:solid; border-width: 2px;"><pre>{{message}}<pre></pre></div>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<h2>Hints for Logon Error - Contact your administrator</h2>
|
|
9
|
+
|
|
10
|
+
<ul>
|
|
11
|
+
<li>SAMESITE setting is not correct for your environment (contact your administrator)</li>
|
|
12
|
+
<li>Presence of self-signed certificates - might have to set NODE_TLS_REJECT_UNAUTHORIZED=0 in the env file</li>
|
|
13
|
+
<li>You might have to clear the cookies for your Viya Server</li>
|
|
14
|
+
<li>You might have to clear the cookies set by this app server</li>
|
|
15
|
+
</ul>
|
|
16
|
+
|
|
17
|
+
<h2>404</h2>
|
|
18
|
+
<ul>
|
|
19
|
+
<li> Make sure the proper appname is used in script tags for /appenv and /user</li>
|
|
20
|
+
<li> Make sure you are starting the application at the proper url</li>
|
|
21
|
+
</ul>
|
|
22
|
+
|
|
23
|
+
</body>
|
|
24
24
|
</html>
|
package/start.sh
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Azure wants to prefix the app env
|
|
3
|
-
# Use this to set the env that this server expects
|
|
4
|
-
|
|
5
|
-
# https://docs.microsoft.com/en-us/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet
|
|
6
|
-
env | grep APPSETTING_
|
|
7
|
-
|
|
8
|
-
if [[ ! -z "$APPSETTING_VIYA_SERVER" ]];
|
|
9
|
-
then
|
|
10
|
-
export VIYA_SERVER=$APPSETTING_VIYA_SERVER
|
|
11
|
-
echo VIYA SERVER= $VIYA_SERVER
|
|
12
|
-
else
|
|
13
|
-
echo "No custom application overrides"
|
|
14
|
-
fi
|
|
1
|
+
#
|
|
2
|
+
# Azure wants to prefix the app env
|
|
3
|
+
# Use this to set the env that this server expects
|
|
4
|
+
|
|
5
|
+
# https://docs.microsoft.com/en-us/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet
|
|
6
|
+
env | grep APPSETTING_
|
|
7
|
+
|
|
8
|
+
if [[ ! -z "$APPSETTING_VIYA_SERVER" ]];
|
|
9
|
+
then
|
|
10
|
+
export VIYA_SERVER=$APPSETTING_VIYA_SERVER
|
|
11
|
+
echo VIYA SERVER= $VIYA_SERVER
|
|
12
|
+
else
|
|
13
|
+
echo "No custom application overrides"
|
|
14
|
+
fi
|
|
15
15
|
node server.js
|
package/tls/viyatls.sh
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
kubectl cp $(kubectl get pod | grep "sas-consul-server-0" | awk -F" " '{print $1}'):security/ca.crt ./ca.crt
|
|
2
|
-
kubectl cp $(kubectl get pod | grep "sas-consul-server-0" | awk -F" " '{print $1}'):security/tls.crt ./tls.crt
|
|
1
|
+
kubectl cp $(kubectl get pod | grep "sas-consul-server-0" | awk -F" " '{print $1}'):security/ca.crt ./ca.crt
|
|
2
|
+
kubectl cp $(kubectl get pod | grep "sas-consul-server-0" | awk -F" " '{print $1}'):security/tls.crt ./tls.crt
|
|
3
3
|
kubectl cp $(kubectl get pod | grep "sas-consul-server-0" | awk -F" " '{print $1}'):security/tls.key ./tls.key
|