@sassoftware/viya-serverjs 0.3.0 → 0.5.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 +42 -28
- package/.env.server +32 -30
- package/.eslintignore +3 -3
- package/.eslintrc.json +42 -42
- package/Dockerfile +44 -44
- package/README.md +67 -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 +51 -53
- package/lib/iService.js +105 -103
- package/lib/index.js +25 -30
- package/lib/parseDocker.js +3 -3
- package/lib/plugins/SASauth.js +34 -34
- package/lib/plugins/appCookie.js +35 -38
- package/lib/plugins/setContext.js +22 -25
- package/lib/plugins/setDefaultRoutes.js +71 -59
- package/lib/plugins/setupAuth.js +35 -38
- package/lib/plugins/setupUserRoutes.js +17 -16
- package/lib/plugins/token.js +9 -10
- package/lib/schemes/SASTokenScheme.js +24 -27
- package/mcpServer.js +364 -0
- 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 +360 -350
- package/public/indexProxy.html +351 -351
- package/public/simplesubmit.html +233 -0
- package/server.js +363 -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 +80 -79
- package/src/iService.js +360 -345
- package/src/index.js +247 -249
- package/src/parseDocker.js +32 -32
- package/src/plugins/SASauth.js +82 -78
- package/src/plugins/appCookie.js +50 -49
- package/src/plugins/setContext.js +33 -33
- package/src/plugins/setDefaultRoutes.js +261 -253
- package/src/plugins/setupAuth.js +49 -49
- package/src/plugins/setupUserRoutes.js +48 -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/.env.proxy +0 -32
- package/tls/viyatls.sh +0 -3
package/src/plugins/SASauth.js
CHANGED
|
@@ -1,79 +1,83 @@
|
|
|
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
|
-
|
|
20
|
-
let bell = require('@hapi/bell');
|
|
21
|
-
let uuid = require('uuid');
|
|
22
|
-
let debug = require('debug')('sasauth');
|
|
23
|
-
|
|
24
|
-
exports.plugin = {
|
|
25
|
-
name : 'SASauth',
|
|
26
|
-
version : '1.0.0',
|
|
27
|
-
register: iSASauth
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
async function iSASauth (server, options) {
|
|
31
|
-
debug('in iSASauth');
|
|
32
|
-
debug('options', options);
|
|
33
|
-
let bellAuthOptions;
|
|
34
|
-
let provider;
|
|
35
|
-
// test for k8s deployment
|
|
36
|
-
let host = options.host + '/SASLogon';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (options.ns != null) {
|
|
40
|
-
host = `https://sas-logon-app.${options.ns}.svc.cluster.local`;
|
|
41
|
-
} else if (options.nsHost != null) {
|
|
42
|
-
host = options.nsHost;
|
|
43
|
-
}
|
|
44
|
-
// ...
|
|
45
|
-
debug(host);
|
|
46
|
-
provider = {
|
|
47
|
-
name : 'sas',
|
|
48
|
-
protocol : 'oauth2',
|
|
49
|
-
useParamsAuth: false,
|
|
50
|
-
auth : host + '/oauth/authorize',
|
|
51
|
-
token : host + '/oauth/token',
|
|
52
|
-
|
|
53
|
-
profileMethod: 'get',
|
|
54
|
-
|
|
55
|
-
profile: async function (credentials, params, get) {
|
|
56
|
-
|
|
57
|
-
server.log('SASAuth profile', credentials);
|
|
58
|
-
debug('credentials', credentials);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
bellAuthOptions = {
|
|
65
|
-
provider : provider,
|
|
66
|
-
password : uuid.v4(),
|
|
67
|
-
clientId : options.clientId,
|
|
68
|
-
clientSecret: options.clientSecret,
|
|
69
|
-
// isSameSite : options.isSameSite,
|
|
70
|
-
isSecure : options.isSecure
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
|
|
20
|
+
let bell = require('@hapi/bell');
|
|
21
|
+
let uuid = require('uuid');
|
|
22
|
+
let debug = require('debug')('sasauth');
|
|
23
|
+
|
|
24
|
+
exports.plugin = {
|
|
25
|
+
name : 'SASauth',
|
|
26
|
+
version : '1.0.0',
|
|
27
|
+
register: iSASauth
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
async function iSASauth (server, options) {
|
|
31
|
+
debug('in iSASauth');
|
|
32
|
+
debug('options', options);
|
|
33
|
+
let bellAuthOptions;
|
|
34
|
+
let provider;
|
|
35
|
+
// test for k8s deployment
|
|
36
|
+
let host = options.host + '/SASLogon';
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if (options.ns != null) {
|
|
40
|
+
host = `https://sas-logon-app.${options.ns}.svc.cluster.local`;
|
|
41
|
+
} else if (options.nsHost != null) {
|
|
42
|
+
host = options.nsHost;
|
|
43
|
+
}
|
|
44
|
+
// ...
|
|
45
|
+
debug(host);
|
|
46
|
+
provider = {
|
|
47
|
+
name : 'sas',
|
|
48
|
+
protocol : 'oauth2',
|
|
49
|
+
useParamsAuth: false,
|
|
50
|
+
auth : host + '/oauth/authorize',
|
|
51
|
+
token : host + '/oauth/token',
|
|
52
|
+
|
|
53
|
+
profileMethod: 'get',
|
|
54
|
+
|
|
55
|
+
profile: async function (credentials, params, get) {
|
|
56
|
+
|
|
57
|
+
server.log('SASAuth profile', credentials);
|
|
58
|
+
debug('credentials', credentials);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
bellAuthOptions = {
|
|
65
|
+
provider : provider,
|
|
66
|
+
password : uuid.v4(),
|
|
67
|
+
clientId : options.clientId,
|
|
68
|
+
clientSecret: (options.clientSecret == null) ? '' : options.clientSecret,
|
|
69
|
+
// isSameSite : options.isSameSite,
|
|
70
|
+
isSecure : options.isSecure
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (options.pkce === true) {
|
|
74
|
+
bellAuthOptions.pkce = 'S256';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
debug('belloptions', bellAuthOptions);
|
|
78
|
+
server.log('SASAuth',bellAuthOptions);
|
|
79
|
+
await server.register(bell);
|
|
80
|
+
server.auth.strategy('sas', 'bell', bellAuthOptions);
|
|
81
|
+
|
|
82
|
+
}
|
|
79
83
|
|
package/src/plugins/appCookie.js
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
let uuid = require('uuid');
|
|
3
|
-
let debug = require('debug')('cookie');
|
|
4
|
-
|
|
5
|
-
module.exports = async function appCookie (server, options){
|
|
6
|
-
|
|
7
|
-
await server.register(require('@hapi/cookie'));
|
|
8
|
-
|
|
9
|
-
debug('in appCookie');
|
|
10
|
-
debug(options.redirectTo);
|
|
11
|
-
let cookieOptions = {
|
|
12
|
-
cookie: {
|
|
13
|
-
name : 'cookie',
|
|
14
|
-
password : uuid.v4(),
|
|
15
|
-
isSecure : options.isSecure,
|
|
16
|
-
isSameSite: options.isSameSite
|
|
17
|
-
},
|
|
18
|
-
redirectTo : options.redirectTo,
|
|
19
|
-
appendNext : {name: 'next'},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
|
|
2
|
+
let uuid = require('uuid');
|
|
3
|
+
let debug = require('debug')('cookie');
|
|
4
|
+
|
|
5
|
+
module.exports = async function appCookie (server, options){
|
|
6
|
+
|
|
7
|
+
await server.register(require('@hapi/cookie'));
|
|
8
|
+
|
|
9
|
+
debug('in appCookie');
|
|
10
|
+
debug('redirecTo', options.redirectTo);
|
|
11
|
+
let cookieOptions = {
|
|
12
|
+
cookie: {
|
|
13
|
+
name : 'cookie',
|
|
14
|
+
password : uuid.v4(),
|
|
15
|
+
isSecure : options.isSecure,
|
|
16
|
+
isSameSite: options.isSameSite
|
|
17
|
+
},
|
|
18
|
+
redirectTo : options.redirectTo,
|
|
19
|
+
appendNext : {name: 'next'},
|
|
20
|
+
validate: async (req, session) => {
|
|
21
|
+
debugger;
|
|
22
|
+
debug('Cookie validate', `path - ${req.path}`);
|
|
23
|
+
|
|
24
|
+
if (session == null) {
|
|
25
|
+
console.log('session is null');
|
|
26
|
+
return {isValid: false};
|
|
27
|
+
}
|
|
28
|
+
let credentials = null;
|
|
29
|
+
let sid;
|
|
30
|
+
if (Array.isArray(session) === true && session.length > 0) {
|
|
31
|
+
sid = session[0].sid;
|
|
32
|
+
} else {
|
|
33
|
+
sid = session.sid;
|
|
34
|
+
}
|
|
35
|
+
if (sid != null) {
|
|
36
|
+
credentials = await req.server.app.cache.get(sid);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (credentials == null) {
|
|
40
|
+
return {isValid: false};
|
|
41
|
+
}
|
|
42
|
+
debug('Cookie validate', sid);
|
|
43
|
+
return {isValid: true, credentials: credentials};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
// console.log('cookie options', cookieOptions);
|
|
47
|
+
debug('Cookie Options',cookieOptions);
|
|
48
|
+
server.auth.strategy('session', 'cookie', cookieOptions);
|
|
49
|
+
|
|
50
|
+
};
|
|
@@ -1,34 +1,34 @@
|
|
|
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
|
-
|
|
20
|
-
async function setContext (req,h){
|
|
21
|
-
let credentials = req.auth.credentials;
|
|
22
|
-
|
|
23
|
-
let context = {
|
|
24
|
-
path : req.path,
|
|
25
|
-
params : req.params,
|
|
26
|
-
query : req.query,
|
|
27
|
-
payload: req.payload,
|
|
28
|
-
queryOrig: (credentials != null) ? credentials.query : {},
|
|
29
|
-
token : (credentials != null) ? `bearer ${credentials.token}` : null,
|
|
30
|
-
host : process.env.VIYA_SERVER
|
|
31
|
-
};
|
|
32
|
-
return context;
|
|
33
|
-
}
|
|
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
|
+
|
|
20
|
+
async function setContext (req,h){
|
|
21
|
+
let credentials = req.auth.credentials;
|
|
22
|
+
|
|
23
|
+
let context = {
|
|
24
|
+
path : req.path,
|
|
25
|
+
params : req.params,
|
|
26
|
+
query : req.query,
|
|
27
|
+
payload: req.payload,
|
|
28
|
+
queryOrig: (credentials != null) ? credentials.query : {},
|
|
29
|
+
token : (credentials != null) ? `bearer ${credentials.token}` : null,
|
|
30
|
+
host : process.env.VIYA_SERVER
|
|
31
|
+
};
|
|
32
|
+
return context;
|
|
33
|
+
}
|
|
34
34
|
export default setContext;
|