@sassoftware/viya-serverjs 0.5.5 → 0.6.1-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/.env +15 -32
- package/.env.proxy +24 -0
- package/.env.server +20 -35
- package/Dockerfile +24 -30
- package/README.md +69 -37
- package/cli.js +2 -1
- package/lib/handlers/codeAuth.js +11 -9
- package/lib/handlers/getApp.js +5 -2
- package/lib/handlers/logon.js +4 -5
- package/lib/handlers/proxyMapUri.js +1 -1
- package/lib/handlers/setCookies.js +22 -15
- package/lib/iService.js +98 -234
- package/lib/index.js +29 -15
- package/lib/plugins/SASauth.js +2 -8
- package/lib/plugins/appCookie.js +3 -4
- package/lib/plugins/setContext.js +3 -1
- package/lib/plugins/setDefaultRoutes.js +33 -61
- package/lib/plugins/setupUserRoutes.js +11 -5
- package/lib/readCerts.js +38 -0
- package/package.json +15 -21
- package/public/help.html +1 -1
- package/public/index.html +302 -304
- package/public/indexold.html +356 -0
- package/server.js +10 -11
- package/src/handlers/codeAuth.js +10 -10
- package/src/handlers/getApp.js +4 -1
- package/src/handlers/logon.js +3 -4
- package/src/handlers/proxyMapUri.js +3 -3
- package/src/handlers/setCookies.js +8 -11
- package/src/iService.js +82 -173
- package/src/index.js +30 -17
- package/src/plugins/SASauth.js +2 -9
- package/src/plugins/appCookie.js +4 -5
- package/src/plugins/setContext.js +3 -2
- package/src/plugins/setDefaultRoutes.js +19 -25
- package/src/plugins/setupUserRoutes.js +6 -3
- package/src/readCerts.js +33 -0
- package/tls/viyatls.sh +3 -0
- package/mcpServer.js +0 -364
- package/public/auth.html +0 -25
- package/testca.js +0 -10
package/.env
CHANGED
|
@@ -1,44 +1,27 @@
|
|
|
1
|
+
|
|
1
2
|
APPHOST=localhost
|
|
2
|
-
|
|
3
|
+
APPENTRY=index.html
|
|
3
4
|
APPLOC=./public
|
|
4
|
-
# VIYA_SERVER=your viya server
|
|
5
5
|
|
|
6
6
|
APPPORT=8080
|
|
7
|
-
APPNAME=
|
|
8
|
-
AUTHFLOW=
|
|
9
|
-
CLIENTID=
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
USETOKEN=TRUE
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# REDIRECT=mcp
|
|
7
|
+
APPNAME=viyaapp
|
|
8
|
+
AUTHFLOW=server
|
|
9
|
+
CLIENTID=viyaapp
|
|
10
|
+
CLIENTSECRET=jellico
|
|
11
|
+
REDIRECT=
|
|
16
12
|
# APPDIR=./appDir
|
|
17
13
|
HTTPS=true
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# 2. Use libraries like mkcert to create temporary trusted certs for localhost
|
|
24
|
-
# 3. Use the app server as a proxy to the Viya server to avoid CORS issues.
|
|
25
|
-
# This requires that the app redirect all Viya API calls to the app server proxy endpoint
|
|
26
|
-
# Users of restaf can simply set the APPENV_PROXY env to TRUE to enable this behavior
|
|
27
|
-
# 4. set USETOKEN to TRUE and use the token in the APPENV object to make the calls
|
|
28
|
-
// either use the proper ssl/tsl certs or use the "proxy" method
|
|
29
|
-
// to avoid CORS issues with self-signed certs
|
|
30
|
-
// so run all apps thru the proxy and call Viya from there
|
|
31
|
-
|
|
32
|
-
APPENV_PROXY=false
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
# APPENV_PROXYSERVER=true
|
|
36
|
-
# USETOKEN=true
|
|
37
|
-
SHOWENV=true
|
|
38
|
-
|
|
14
|
+
USETOKEN=YES
|
|
15
|
+
USELOGON=YES
|
|
16
|
+
SHOWENV=YES
|
|
17
|
+
VIYACERT=c:\Users\kumar\viyaCert
|
|
18
|
+
NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
39
19
|
APPENV_XYZ=AA
|
|
40
20
|
APPENV_BAD=
|
|
41
21
|
|
|
22
|
+
# APPENV_PUPID=NS=https://sas-logon-app.viya.svc.cluster.local
|
|
23
|
+
|
|
24
|
+
# NAMESPACE=viya
|
|
42
25
|
|
|
43
26
|
|
|
44
27
|
|
package/.env.proxy
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
APPHOST=localhost
|
|
2
|
+
# APPENTRY=index.html
|
|
3
|
+
APPENTRY=index.html
|
|
4
|
+
APPLOC=./public
|
|
5
|
+
VIYA_SERVER=
|
|
6
|
+
# APPENV_PROXYSERVER=https://localhost:8080/viyaapp/proxy
|
|
7
|
+
APPENV_USEPROXY=YES
|
|
8
|
+
APPPORT=8080
|
|
9
|
+
APPNAME=viyaapp
|
|
10
|
+
AUTHFLOW=server
|
|
11
|
+
CLIENTID=viyaapp
|
|
12
|
+
CLIENTSECRET=jellico
|
|
13
|
+
|
|
14
|
+
REDIRECT=
|
|
15
|
+
|
|
16
|
+
# APPDIR=./appDir
|
|
17
|
+
# HTTPS=true
|
|
18
|
+
USELOGON=NO
|
|
19
|
+
USETOKEN=YES
|
|
20
|
+
SHOWENV=YES
|
|
21
|
+
VIYACERT=c:\Users\kumar\viyaCert
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
package/.env.server
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
1
|
APPHOST=localhost
|
|
2
|
-
|
|
2
|
+
APPENTRY=indexProxy.html
|
|
3
3
|
APPLOC=./public
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
VIYA_SERVER=
|
|
5
|
+
# APPENV_PROXYSERVER=https://localhost:8080/viyaapp/proxy
|
|
6
|
+
APPENV_USEPROXY=YES
|
|
6
7
|
APPPORT=8080
|
|
7
|
-
APPNAME=
|
|
8
|
-
AUTHFLOW=
|
|
9
|
-
CLIENTID=
|
|
8
|
+
APPNAME=viyaapp
|
|
9
|
+
AUTHFLOW=server
|
|
10
|
+
CLIENTID=viyaapp
|
|
10
11
|
CLIENTSECRET=jellico
|
|
11
|
-
|
|
12
|
-
USETOKEN=TRUE
|
|
13
|
-
|
|
14
|
-
REDIRECT=mcp
|
|
12
|
+
REDIRECT=
|
|
15
13
|
# APPDIR=./appDir
|
|
16
|
-
HTTPS=true
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
|
|
28
|
-
// to avoid CORS issues with self-signed certs
|
|
29
|
-
// so run all apps thru the proxy and call Viya from there
|
|
30
|
-
APPENV_PROXY=false
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# APPENV_PROXYSERVER=true
|
|
34
|
-
# USETOKEN=true
|
|
35
|
-
SHOWENV=true
|
|
36
|
-
|
|
37
|
-
APPENV_XYZ=AA
|
|
38
|
-
APPENV_BAD=
|
|
39
|
-
|
|
40
|
-
|
|
14
|
+
# HTTPS=true
|
|
15
|
+
USELOGON=YES
|
|
16
|
+
USETOKEN=YES
|
|
17
|
+
# SHOWENV=YES
|
|
18
|
+
# APPENV=
|
|
19
|
+
VIYACERT=c:\Users\kumar\viyaCert
|
|
20
|
+
NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# NAMESPACE=viya
|
|
24
|
+
# TLS_CERT=./certs/tls.crt
|
|
25
|
+
# TLS_KEY=./certs/tls.key
|
|
41
26
|
|
|
42
27
|
|
|
43
28
|
|
package/Dockerfile
CHANGED
|
@@ -8,43 +8,37 @@ 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
|
|
12
11
|
ENV PORT=8080
|
|
13
12
|
EXPOSE 8080
|
|
14
13
|
ENV HTTPS=true
|
|
14
|
+
# ENV APPSERVERLEVEL=v2
|
|
15
|
+
#######################################################################
|
|
16
|
+
# You can override these(but in container leave APPHOST as shown below)
|
|
17
|
+
########################################################################
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
ENV
|
|
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=
|
|
19
|
+
# set this the same as EXPOSE here and override in env or as -p option in dockerrun
|
|
20
|
+
# ENV APPPORT=8080
|
|
26
21
|
|
|
22
|
+
ENV APPNAME=viyaapp
|
|
23
|
+
# ENV AUTHFLOW=
|
|
24
|
+
ENV CLIENTID=viyaapp
|
|
25
|
+
ENV CLIENTSECRET=jellico
|
|
26
|
+
ENV HAPIDEBUG=NO
|
|
27
|
+
# ENV LOGLEVEL=info
|
|
28
|
+
# ENV USETOKEN=YES
|
|
27
29
|
|
|
28
|
-
#
|
|
29
|
-
|
|
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
|
|
30
|
+
#sample setup for creating a temporary cert and key
|
|
31
|
+
ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:SAS Institute,OU:STO,CN:localhost"
|
|
40
32
|
|
|
41
|
-
|
|
33
|
+
# You can specify your own cet and key
|
|
34
|
+
# ENV TLS_CRT=./tls/tls.crt
|
|
35
|
+
# ENV TLS_KEY=./tls/tls.key
|
|
42
36
|
|
|
37
|
+
# Samesite specification
|
|
38
|
+
ENV SAMESITE=None,secure
|
|
43
39
|
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
ENV SHOWENV=true
|
|
40
|
+
# If your Viya instance still has a unsigned certificate set this value prior to invoking the server
|
|
41
|
+
# ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
CMD ["npm", "start"]
|
|
43
|
+
#####################################################################
|
|
44
|
+
CMD ["npm", "run", "indocker"]
|
package/README.md
CHANGED
|
@@ -1,67 +1,99 @@
|
|
|
1
|
-
# `Application
|
|
1
|
+
# `Application servers for use with SAS Viya`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package has two servers:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
1. viya-appserverjs - Use this for developing an app server for web applications(see packages/appjs)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
2. Extendable with additional end points
|
|
7
|
+
2. viya-apiserverjs - Use this to develop rest api servers(see packages/apijs)
|
|
9
8
|
|
|
10
9
|
## Usage
|
|
11
10
|
|
|
11
|
+
Specify it as a dependency in your package.json just as you do with other dependencies
|
|
12
|
+
|
|
12
13
|
Use npx command to start the server
|
|
13
14
|
|
|
14
15
|
```sh
|
|
15
|
-
npx @sassoftware/
|
|
16
|
+
npx @sassoftware/viyaappserverjs
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
## `Basic configuration`
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
1. Set the default settings in Dockerfile. This will ensure these are set when you build containers.
|
|
22
|
+
2. The defaults can be overriden using environment variables.
|
|
21
23
|
|
|
22
24
|
### `Sample env file`
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
When running on a non-docker environment, you can use a .env
|
|
25
27
|
|
|
26
28
|
```env
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# https://localhost:8080/viyaapp
|
|
31
|
-
#
|
|
32
|
-
APPHOST=localhost
|
|
33
|
-
APPPORT=8080
|
|
34
|
-
HTTPS=true
|
|
29
|
+
VIYA_SERVER=<your viya server>
|
|
30
|
+
APPHOST=localhost < can also be dns name of your server. ex: viyaiscool.unx.sas.com>
|
|
31
|
+
APPPORT=5000 <any port of your choice>
|
|
35
32
|
APPNAME=viyaapp
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# Options:
|
|
41
|
-
# 1. provide signed certificates for localhost
|
|
42
|
-
# 2. Use libraries like mkcert to create temporary trusted certs for localhost
|
|
43
|
-
# 3. For other options see the Advanced Section
|
|
44
|
-
SSLCERT=./tls
|
|
34
|
+
CLIENTID=viyaapp
|
|
35
|
+
CLIENTSECRET=secret
|
|
36
|
+
```
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
### `Sample Dockerfile`
|
|
39
|
+
|
|
40
|
+
```env
|
|
41
|
+
FROM node:12.16.1-alpine
|
|
42
|
+
LABEL maintainer="your email"
|
|
43
|
+
WORKDIR /usr/src/app
|
|
44
|
+
COPY . .
|
|
45
|
+
RUN npm install
|
|
46
|
+
# RUN npm run build (if you have to build something)
|
|
47
|
+
EXPOSE 8080
|
|
48
|
+
ENV APPHOST=0.0.0.0
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
AUTHFLOW=code
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
# The following are defaults. Override them as needed
|
|
53
|
+
# APPLOC - where the file specified in APPENTRY is
|
|
54
|
+
# APPENTRY - the main entry of the application
|
|
55
|
+
ENV APPLOC=./public
|
|
56
|
+
ENV APPENTRY=index.html
|
|
57
|
+
# if your app takes advantage of appenv.js to pass configuration to the web application
|
|
58
|
+
# ENV APPENV=appenv.js
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
APPENV_PROXY=false
|
|
59
|
-
USETOKEN=false
|
|
60
|
+
# See notes below on running with SSL enabled
|
|
61
|
+
ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:yourcompany,OU:STO,CN:localhost"
|
|
62
|
+
ENV SAMESITE=None,secure
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
# It is better to set this before invoking the server
|
|
65
|
+
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
66
|
+
|
|
67
|
+
# set this to YES if you want access to the authentication token in the app
|
|
68
|
+
ENV USETOKEN=NO
|
|
69
|
+
|
|
70
|
+
CMD ["npx", "@sassoftware/viya-appserverjs"]
|
|
63
71
|
|
|
64
72
|
```
|
|
65
73
|
|
|
74
|
+
### `Running with SSL enabled -- Recommended`
|
|
75
|
+
|
|
76
|
+
This is the recommended setting. This will also make browsers like Chrome run with the SAMESITE settings set to Default - your users will thank you.
|
|
77
|
+
|
|
78
|
+
Make sure you specify the VIYA_SERVER with a protocol of https.
|
|
66
79
|
|
|
80
|
+
### `TLS certificates`
|
|
67
81
|
|
|
82
|
+
- Option 1: Let server create a temporary unsigned certificate
|
|
83
|
+
|
|
84
|
+
```env
|
|
85
|
+
ENV TLS_CREATE=C:US,ST:NC,L:Cary,O:YourCompany,OU:yourgroup,CN:localhost
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- Option 2: Provide your own key and certificate key
|
|
89
|
+
|
|
90
|
+
```env
|
|
91
|
+
ENV TLS_KEY=../certs/self/key.pem
|
|
92
|
+
ENV TLS_CERT=../certs/self/certificate.pem
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- Option 3: Provide key and certificate as a pfx file
|
|
96
|
+
|
|
97
|
+
```env
|
|
98
|
+
ENV TLS_PFX=../certs/sascert/sascert2.pfx
|
|
99
|
+
```
|
package/cli.js
CHANGED
package/lib/handlers/codeAuth.js
CHANGED
|
@@ -20,7 +20,7 @@ function codeAuth(_x, _x2, _x3) {
|
|
|
20
20
|
}
|
|
21
21
|
function _codeAuth() {
|
|
22
22
|
_codeAuth = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(req, h, options) {
|
|
23
|
-
var indexHTML
|
|
23
|
+
var indexHTML;
|
|
24
24
|
return _regenerator().w(function (_context) {
|
|
25
25
|
while (1) switch (_context.n) {
|
|
26
26
|
case 0:
|
|
@@ -29,20 +29,22 @@ function _codeAuth() {
|
|
|
29
29
|
return (0, _setCookies["default"])(req, h, options);
|
|
30
30
|
case 1:
|
|
31
31
|
debug(options);
|
|
32
|
-
// add support for REDIRECT env variable
|
|
33
32
|
indexHTML = process.env.APPENTRY == null ? 'index.html' : process.env.APPENTRY;
|
|
34
|
-
redirectPath = null;
|
|
35
33
|
if (process.env.REDIRECT != null) {
|
|
36
|
-
|
|
34
|
+
debug('using REDIRECT env variable', process.env.REDIRECT);
|
|
35
|
+
indexHTML = process.env.REDIRECT;
|
|
37
36
|
}
|
|
38
|
-
debug(indexHTML);
|
|
39
|
-
|
|
40
|
-
if (!(redirectPath !== null)) {
|
|
37
|
+
debug('..................', indexHTML);
|
|
38
|
+
if (!(indexHTML.indexOf('/') === 0)) {
|
|
41
39
|
_context.n = 2;
|
|
42
40
|
break;
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
// added to support create-react-restaf-viya-app cli
|
|
43
|
+
if (indexHTML !== '/develop') {
|
|
44
|
+
indexHTML = "/".concat(process.env.APPNAME).concat(indexHTML);
|
|
45
|
+
}
|
|
46
|
+
console.log("Redirecting to ".concat(indexHTML));
|
|
47
|
+
return _context.a(2, h.redirect(indexHTML));
|
|
46
48
|
case 2:
|
|
47
49
|
console.log("Visiting ".concat(indexHTML));
|
|
48
50
|
return _context.a(2, h.file(indexHTML));
|
package/lib/handlers/getApp.js
CHANGED
|
@@ -19,10 +19,11 @@ function getApp(_x, _x2, _x3) {
|
|
|
19
19
|
}
|
|
20
20
|
function _getApp() {
|
|
21
21
|
_getApp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, req, h) {
|
|
22
|
-
var x, redirect, redirectUri, protocol, url, indexHTML;
|
|
22
|
+
var x, redirect, redirectUri, protocol, url, r, indexHTML;
|
|
23
23
|
return _regenerator().w(function (_context) {
|
|
24
24
|
while (1) switch (_context.n) {
|
|
25
25
|
case 0:
|
|
26
|
+
console.log('In getApp handler', options);
|
|
26
27
|
if (!(process.env.AUTHFLOW === 'implicit')) {
|
|
27
28
|
_context.n = 1;
|
|
28
29
|
break;
|
|
@@ -49,7 +50,9 @@ function _getApp() {
|
|
|
49
50
|
break;
|
|
50
51
|
}
|
|
51
52
|
debug('calling codeauth');
|
|
52
|
-
|
|
53
|
+
r = (0, _codeAuth["default"])(req, h, options);
|
|
54
|
+
console.log(options.userCache);
|
|
55
|
+
return _context.a(2, r);
|
|
53
56
|
case 2:
|
|
54
57
|
debug('default processing in getapp');
|
|
55
58
|
console.log('Processing non authenticated use case');
|
package/lib/handlers/logon.js
CHANGED
|
@@ -14,11 +14,11 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
|
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
15
15
|
*/
|
|
16
16
|
var debug = require('debug')('logon');
|
|
17
|
-
function logon(_x, _x2) {
|
|
17
|
+
function logon(_x, _x2, _x3) {
|
|
18
18
|
return _logon.apply(this, arguments);
|
|
19
19
|
}
|
|
20
20
|
function _logon() {
|
|
21
|
-
_logon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(req, h) {
|
|
21
|
+
_logon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(req, h, options) {
|
|
22
22
|
var r;
|
|
23
23
|
return _regenerator().w(function (_context) {
|
|
24
24
|
while (1) switch (_context.n) {
|
|
@@ -26,12 +26,11 @@ function _logon() {
|
|
|
26
26
|
debugger;
|
|
27
27
|
debug('.................................................in logon');
|
|
28
28
|
_context.n = 1;
|
|
29
|
-
return (0, _setCookies["default"])(req, h,
|
|
29
|
+
return (0, _setCookies["default"])(req, h, options);
|
|
30
30
|
case 1:
|
|
31
31
|
r = _context.v;
|
|
32
|
-
console.log('logon setcookie result:', r);
|
|
33
32
|
debug(r.redirect);
|
|
34
|
-
|
|
33
|
+
debug('in logon after setcookie', r.redirect);
|
|
35
34
|
return _context.a(2, h.redirect(r.redirect));
|
|
36
35
|
}
|
|
37
36
|
}, _callee);
|
|
@@ -23,7 +23,7 @@ function _proxyMapUri() {
|
|
|
23
23
|
sid = credentials.sid;
|
|
24
24
|
console.log('sid=', sid);
|
|
25
25
|
}
|
|
26
|
-
path = process.env.PROXYSERVER == null ? process.env.VIYA_SERVER : process.env.PROXYSERVER;
|
|
26
|
+
path = process.env.VIYA_SERVER; //let path = (process.env.PROXYSERVER == null) ? process.env.VIYA_SERVER : process.env.PROXYSERVER;
|
|
27
27
|
console.log('proxying to= ', path);
|
|
28
28
|
params = req.params;
|
|
29
29
|
console.log('params=', params);
|
|
@@ -4,8 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7
8
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
8
9
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
15
|
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
16
|
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
17
|
/*
|
|
@@ -23,30 +29,32 @@ function _setCookies() {
|
|
|
23
29
|
return _regenerator().w(function (_context) {
|
|
24
30
|
while (1) switch (_context.n) {
|
|
25
31
|
case 0:
|
|
26
|
-
debugger;
|
|
27
32
|
credentials = req.auth.credentials;
|
|
28
|
-
debug('setcookie', credentials
|
|
29
|
-
if (credentials != null && req.auth.error != null) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
console.log('Authentication error:', req.auth.error);
|
|
33
|
-
process.exit(0);
|
|
34
|
-
// return { status: false, error: req.auth.error, redirect: '/error' };
|
|
33
|
+
debug('setcookie', credentials);
|
|
34
|
+
if (!(credentials != null && req.auth.error != null)) {
|
|
35
|
+
_context.n = 1;
|
|
36
|
+
break;
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
debug('setcookie credentials', credentials);
|
|
39
|
+
debug('setcookie error', req.auth.error);
|
|
40
|
+
debug('logon failed');
|
|
41
|
+
return _context.a(2, {
|
|
42
|
+
status: false,
|
|
43
|
+
error: req.auth.error
|
|
44
|
+
});
|
|
45
|
+
case 1:
|
|
37
46
|
// create a cookie(sid) and save credentials in cache
|
|
38
47
|
sid = uuid.v4();
|
|
39
48
|
credentials.sid = sid;
|
|
40
49
|
if (options != null) {
|
|
41
50
|
options.allAppEnv.LOGONPAYLOAD.token = credentials.token;
|
|
42
51
|
options.allAppEnv.LOGONPAYLOAD.tokenType = 'bearer';
|
|
43
|
-
|
|
52
|
+
options.userCache = _objectSpread({}, credentials);
|
|
53
|
+
debug(options.allAppEnv.LOGONPAYLOAD);
|
|
44
54
|
}
|
|
45
|
-
|
|
46
|
-
return req.server.app.cache.set(sid, credentials, 0);
|
|
47
|
-
case 1:
|
|
55
|
+
console.log('userCache', options.userCache);
|
|
48
56
|
_context.n = 2;
|
|
49
|
-
return req.server.app.cache.set(
|
|
57
|
+
return req.server.app.cache.set(sid, credentials, 0);
|
|
50
58
|
case 2:
|
|
51
59
|
// Can we get away without setting cookie for this session?
|
|
52
60
|
// Need to also modify keepAlive
|
|
@@ -55,7 +63,6 @@ function _setCookies() {
|
|
|
55
63
|
req.cookieAuth.set({
|
|
56
64
|
sid: sid
|
|
57
65
|
});
|
|
58
|
-
// req.cookieAuth.set({auth: credentials});
|
|
59
66
|
}
|
|
60
67
|
;
|
|
61
68
|
debug('credentials query', credentials.query);
|