@sassoftware/viya-serverjs 0.5.4 → 0.5.5
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 +3 -2
- package/Dockerfile +37 -31
- package/lib/handlers/setCookies.js +4 -0
- package/lib/plugins/SASauth.js +7 -3
- package/package.json +3 -2
- package/public/auth.html +5 -4
- package/src/handlers/setCookies.js +3 -0
- package/src/plugins/SASauth.js +6 -3
package/.env
CHANGED
package/Dockerfile
CHANGED
|
@@ -8,37 +8,43 @@ RUN npm install
|
|
|
8
8
|
|
|
9
9
|
# will auto change to localhost in non-docker environments
|
|
10
10
|
ENV APPHOST=0.0.0.0
|
|
11
|
+
ENV APPLOC=./public
|
|
11
12
|
ENV PORT=8080
|
|
12
13
|
EXPOSE 8080
|
|
13
14
|
ENV HTTPS=true
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
ENV
|
|
24
|
-
ENV
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
15
|
+
|
|
16
|
+
ENV APPPORT=8080
|
|
17
|
+
ENV APPNAME=mcpserver
|
|
18
|
+
ENV AUTHFLOW=code
|
|
19
|
+
ENV CLIENTID=mcpserver
|
|
20
|
+
ENV CLIENTSECRET=jellico
|
|
21
|
+
ENV USELOGON=FALSE
|
|
22
|
+
ENV USETOKEN=TRUE
|
|
23
|
+
|
|
24
|
+
ENV SSLCERT=
|
|
25
|
+
ENV VIYACERT=
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Most modern browsers do not accept self-signed certs from localhost
|
|
29
|
+
# Options:
|
|
30
|
+
|
|
31
|
+
# 1. provide signed certificates for localhost
|
|
32
|
+
# 2. Use libraries like mkcert to create temporary trusted certs for localhost
|
|
33
|
+
# 3. Use the app server as a proxy to the Viya server to avoid CORS issues.
|
|
34
|
+
# This requires that the app redirect all Viya API calls to the app server proxy endpoint
|
|
35
|
+
# Users of restaf can simply set the APPENV_PROXY env to TRUE to enable this behavior
|
|
36
|
+
# 4. set USETOKEN to TRUE and use the token in the APPENV object to make the calls
|
|
37
|
+
# either use the proper ssl/tsl certs or use the "proxy" method
|
|
38
|
+
# to avoid CORS issues with self-signed certs
|
|
39
|
+
# so run all apps thru the proxy and call Viya from there
|
|
40
|
+
|
|
41
|
+
ENV APPENV_PROXY=false
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# APPENV_PROXYSERVER=true
|
|
45
|
+
# USETOKEN=true
|
|
46
|
+
ENV SHOWENV=true
|
|
47
|
+
|
|
48
|
+
ENV APPENV_XYZ=AA
|
|
49
|
+
ENV APPENV_BAD=
|
|
50
|
+
CMD ["npm", "start"]
|
|
@@ -45,6 +45,9 @@ function _setCookies() {
|
|
|
45
45
|
_context.n = 1;
|
|
46
46
|
return req.server.app.cache.set(sid, credentials, 0);
|
|
47
47
|
case 1:
|
|
48
|
+
_context.n = 2;
|
|
49
|
+
return req.server.app.cache.set('credentials', credentials, 0);
|
|
50
|
+
case 2:
|
|
48
51
|
// Can we get away without setting cookie for this session?
|
|
49
52
|
// Need to also modify keepAlive
|
|
50
53
|
if (process.env.COOKIES !== 'NO') {
|
|
@@ -52,6 +55,7 @@ function _setCookies() {
|
|
|
52
55
|
req.cookieAuth.set({
|
|
53
56
|
sid: sid
|
|
54
57
|
});
|
|
58
|
+
// req.cookieAuth.set({auth: credentials});
|
|
55
59
|
}
|
|
56
60
|
;
|
|
57
61
|
debug('credentials query', credentials.query);
|
package/lib/plugins/SASauth.js
CHANGED
|
@@ -75,6 +75,13 @@ function _iSASauth() {
|
|
|
75
75
|
return profile;
|
|
76
76
|
}()
|
|
77
77
|
};
|
|
78
|
+
// Reference: https://github.com/hapijs/bell/blob/master/lib/oauth.js
|
|
79
|
+
// for some reason the bell doc is out of date on pkce
|
|
80
|
+
|
|
81
|
+
console.log('pkce', options.pkce);
|
|
82
|
+
if (options.pkce === true) {
|
|
83
|
+
provider.pkce = 'S256';
|
|
84
|
+
}
|
|
78
85
|
bellAuthOptions = {
|
|
79
86
|
provider: provider,
|
|
80
87
|
password: uuid.v4(),
|
|
@@ -83,9 +90,6 @@ function _iSASauth() {
|
|
|
83
90
|
// isSameSite : options.isSameSite,
|
|
84
91
|
isSecure: options.isSecure
|
|
85
92
|
};
|
|
86
|
-
if (options.pkce === true) {
|
|
87
|
-
bellAuthOptions.pkce = 'S256';
|
|
88
|
-
}
|
|
89
93
|
debug('belloptions', bellAuthOptions);
|
|
90
94
|
server.log('SASAuth', bellAuthOptions);
|
|
91
95
|
_context2.n = 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sassoftware/viya-serverjs",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Easy to use app server for SAS Viya applications",
|
|
5
5
|
"author": "Deva Kumaraswamy <deva.kumar@sas.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"debug": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node --inspect-brk server.js --env=./.env.server --docker=./Dockerfile",
|
|
36
36
|
"proxy": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node cli --env=./.env.proxy --docker=./Dockerfile",
|
|
37
37
|
"pub": "npm publish --tag alpha --access public",
|
|
38
|
-
"lint": "npx eslint --fix src/*.js"
|
|
38
|
+
"lint": "npx eslint --fix src/*.js",
|
|
39
|
+
"indocker": "npx @sassoftware/sas-score-mcp-serverjs@alpha"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"@hapi/bell": "^13.1.0",
|
package/public/auth.html
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
<!DOCTYPE html>
|
|
3
2
|
<html>
|
|
4
3
|
<body>
|
|
@@ -15,10 +14,12 @@
|
|
|
15
14
|
} catch (e) {
|
|
16
15
|
// ignore
|
|
17
16
|
}
|
|
18
|
-
// Attempt to close the popup.
|
|
19
|
-
|
|
17
|
+
// Attempt to close the popup after 5 seconds.
|
|
18
|
+
setTimeout(function() {
|
|
19
|
+
window.close();
|
|
20
|
+
}, 5000);
|
|
20
21
|
})();
|
|
21
22
|
</script>
|
|
22
23
|
<p>Server is active. You can close this window.</p>
|
|
23
24
|
</body>
|
|
24
|
-
</html
|
|
25
|
+
</html>
|
|
@@ -29,11 +29,14 @@ async function setCookies (req, h, options) {
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
await req.server.app.cache.set(sid, credentials, 0);
|
|
32
|
+
await req.server.app.cache.set('credentials', credentials, 0);
|
|
33
|
+
|
|
32
34
|
// Can we get away without setting cookie for this session?
|
|
33
35
|
// Need to also modify keepAlive
|
|
34
36
|
if (process.env.COOKIES !== 'NO') {
|
|
35
37
|
debugger;
|
|
36
38
|
req.cookieAuth.set({ sid });
|
|
39
|
+
// req.cookieAuth.set({auth: credentials});
|
|
37
40
|
};
|
|
38
41
|
debug('credentials query', credentials.query);
|
|
39
42
|
let redirect = (credentials.query != null && credentials.query.next != null) ? credentials.query.next : null;
|
package/src/plugins/SASauth.js
CHANGED
|
@@ -60,7 +60,13 @@ async function iSASauth (server, options) {
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
};
|
|
63
|
+
// Reference: https://github.com/hapijs/bell/blob/master/lib/oauth.js
|
|
64
|
+
// for some reason the bell doc is out of date on pkce
|
|
63
65
|
|
|
66
|
+
console.log('pkce', options.pkce);
|
|
67
|
+
if (options.pkce === true) {
|
|
68
|
+
provider.pkce = 'S256';
|
|
69
|
+
}
|
|
64
70
|
bellAuthOptions = {
|
|
65
71
|
provider : provider,
|
|
66
72
|
password : uuid.v4(),
|
|
@@ -70,9 +76,6 @@ async function iSASauth (server, options) {
|
|
|
70
76
|
isSecure : options.isSecure
|
|
71
77
|
};
|
|
72
78
|
|
|
73
|
-
if (options.pkce === true) {
|
|
74
|
-
bellAuthOptions.pkce = 'S256';
|
|
75
|
-
}
|
|
76
79
|
|
|
77
80
|
debug('belloptions', bellAuthOptions);
|
|
78
81
|
server.log('SASAuth',bellAuthOptions);
|