@sassoftware/viya-serverjs 0.1.2 → 0.2.1
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 -0
- package/.dockerignore +2 -0
- package/.env +29 -0
- package/.env.proxy +31 -0
- package/.env.server +29 -0
- package/.eslintignore +4 -0
- package/.eslintrc.json +42 -0
- package/Dockerfile +44 -0
- package/README.md +6 -4
- package/cli.js +9 -0
- package/images/viya-apiserverjs.png +0 -0
- package/lib/{core/config.js → config.js} +6 -25
- package/lib/handlers/appCallback.js +62 -0
- package/lib/handlers/codeAuth.js +61 -0
- package/lib/{core/handlers → handlers}/decodeJwt.js +1 -1
- package/lib/handlers/favicon.js +45 -0
- package/lib/handlers/getApp.js +77 -0
- package/lib/handlers/getApp2.js +48 -0
- package/lib/handlers/getUser.js +49 -0
- package/lib/{core/handlers → handlers}/index.js +1 -1
- package/lib/handlers/keepAlive.js +99 -0
- package/lib/handlers/keepAlive2.js +33 -0
- package/lib/handlers/logon.js +43 -0
- package/lib/handlers/logout.js +88 -0
- package/lib/handlers/proxyMapUri.js +76 -0
- package/lib/handlers/proxyOnResponse.js +26 -0
- package/lib/handlers/reactDev.js +52 -0
- package/lib/handlers/setCookies.js +112 -0
- package/lib/{core/iService.js → iService.js} +45 -30
- package/lib/index.js +184 -10
- package/lib/plugins/SASauth.js +101 -0
- package/lib/plugins/appCookie.js +99 -0
- package/lib/plugins/setContext.js +56 -0
- package/lib/plugins/setDefaultRoutes.js +248 -0
- package/lib/plugins/setupAuth.js +87 -0
- package/lib/{core/plugins → plugins}/setupUserRoutes.js +21 -12
- package/lib/plugins/token.js +31 -0
- package/lib/schemes/SASTokenScheme.js +71 -0
- package/package.json +56 -14
- package/packages/core/config.js +86 -0
- package/packages/core/handlers/appCallback.js +40 -0
- package/packages/core/handlers/codeAuth.js +31 -0
- package/packages/core/handlers/decodeJwt.js +11 -0
- package/packages/core/handlers/favicon.js +24 -0
- package/packages/core/handlers/getApp.js +41 -0
- package/packages/core/handlers/getApp2.js +26 -0
- package/packages/core/handlers/getUser.js +20 -0
- package/packages/core/handlers/index.js +36 -0
- package/packages/core/handlers/keepAlive.js +54 -0
- package/packages/core/handlers/keepAlive2.js +13 -0
- package/packages/core/handlers/logon.js +24 -0
- package/packages/core/handlers/logout.js +43 -0
- package/{lib → packages}/core/handlers/proxyMapUri.js +25 -36
- package/packages/core/handlers/proxyOnResponse.js +12 -0
- package/packages/core/handlers/reactDev.js +30 -0
- package/packages/core/handlers/setCookies.js +78 -0
- package/packages/core/iService.js +369 -0
- package/packages/core/index.js +249 -0
- package/packages/core/parseDocker.js +33 -0
- package/packages/core/plugins/SASauth.js +79 -0
- package/packages/core/plugins/appCookie.js +49 -0
- package/packages/core/plugins/setContext.js +34 -0
- package/packages/core/plugins/setDefaultRoutes.js +262 -0
- package/packages/core/plugins/setupAuth.js +48 -0
- package/packages/core/plugins/setupUserRoutes.js +48 -0
- package/packages/core/plugins/token.js +10 -0
- package/packages/core/schemes/SASTokenScheme.js +43 -0
- package/packages/core/visionIndex.html +24 -0
- package/packages/examples/apitest/.env +11 -0
- package/packages/examples/apitest/.eslintrc.json +42 -0
- package/packages/examples/apitest/Dockerfile +41 -0
- package/packages/examples/apitest/api.js +88 -0
- package/packages/examples/apitest/appenv.js +6 -0
- package/packages/examples/apitest/docker-compose.yml +10 -0
- package/packages/examples/apitest/package.json +19 -0
- package/packages/examples/apitest/public/data/Cluster_SDOH1.sas +182 -0
- package/packages/examples/apitest/public/data/Cluster_SDOH6.sas +180 -0
- package/packages/examples/apitest/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/apitest/public/data/NeuralNetwork_High_med.sas +2409 -0
- package/packages/examples/apitest/public/data/NeuralNetwork_high_med1.sas +2409 -0
- 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 +429 -0
- package/packages/examples/apitest/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/apitest/public/data/cmdList.txt +15 -0
- package/packages/examples/apitest/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/apitest/public/data/iris.csv +151 -0
- 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 +316 -0
- package/packages/examples/apitest/public/index2.html +102 -0
- package/packages/examples/apitest/public/logon.html +42 -0
- package/packages/examples/apitest/public/myapp/secondary.html +1 -0
- package/packages/examples/apitest/public/myapp/test.js +2 -0
- package/packages/examples/apitest/public/onlogoff.html +53 -0
- package/packages/examples/apitest/start.sh +15 -0
- package/packages/examples/app/.env +32 -0
- package/packages/examples/app/.envProxy +19 -0
- package/packages/examples/app/.envimpl +12 -0
- package/packages/examples/app/.eslintrc.json +42 -0
- package/packages/examples/app/Dockerfile +42 -0
- package/packages/examples/app/appenv.js +6 -0
- package/packages/examples/app/certs/ca.crt +19 -0
- package/packages/examples/app/certs/tls.crt +25 -0
- package/packages/examples/app/certs/tls.key +28 -0
- package/packages/examples/app/certs/tls.sh +5 -0
- package/packages/examples/app/docker-compose.yml +12 -0
- package/packages/examples/app/index.js +15 -0
- package/packages/examples/app/package.json +20 -0
- package/packages/examples/app/public/casread.html +324 -0
- package/packages/examples/app/public/data/Cluster_SDOH1.sas +182 -0
- package/packages/examples/app/public/data/Cluster_SDOH6.sas +180 -0
- package/packages/examples/app/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/app/public/data/NeuralNetwork_High_med.sas +2409 -0
- package/packages/examples/app/public/data/NeuralNetwork_high_med1.sas +2409 -0
- 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 +429 -0
- package/packages/examples/app/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/app/public/data/cmdList.txt +15 -0
- package/packages/examples/app/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/app/public/data/iris.csv +151 -0
- 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 +332 -0
- package/packages/examples/app/public/indexProxy.html +346 -0
- package/packages/examples/app/public/indextest.html +316 -0
- package/packages/examples/app/public/logon.html +44 -0
- package/packages/examples/app/public/micburger.html +345 -0
- package/packages/examples/app/public/micburger.txt.html +311 -0
- package/packages/examples/app/public/myapp/secondary.html +1 -0
- package/packages/examples/app/public/myapp/test.js +2 -0
- package/packages/examples/app/public/sara.txt +345 -0
- package/packages/examples/app/public/testva2.html +311 -0
- package/packages/examples/app/startup.sh +15 -0
- package/packages/examples/appdocker/.env +21 -0
- package/packages/examples/appdocker/.envProxy +22 -0
- package/packages/examples/appdocker/.envimpl +12 -0
- package/packages/examples/appdocker/.eslintrc.json +42 -0
- package/packages/examples/appdocker/Dockerfile +43 -0
- package/packages/examples/appdocker/appenv.js +6 -0
- package/packages/examples/appdocker/certs/ca.crt +19 -0
- package/packages/examples/appdocker/certs/tls.crt +25 -0
- package/packages/examples/appdocker/certs/tls.key +28 -0
- package/packages/examples/appdocker/certs/tls.sh +5 -0
- package/packages/examples/appdocker/docker-compose.yml +12 -0
- package/packages/examples/appdocker/index.js +15 -0
- package/packages/examples/appdocker/package.json +20 -0
- package/packages/examples/appdocker/public/data/Cluster_SDOH1.sas +182 -0
- package/packages/examples/appdocker/public/data/Cluster_SDOH6.sas +180 -0
- package/packages/examples/appdocker/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/appdocker/public/data/NeuralNetwork_High_med.sas +2409 -0
- package/packages/examples/appdocker/public/data/NeuralNetwork_high_med1.sas +2409 -0
- 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 +429 -0
- package/packages/examples/appdocker/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/appdocker/public/data/cmdList.txt +15 -0
- package/packages/examples/appdocker/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/appdocker/public/data/iris.csv +151 -0
- 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 +346 -0
- package/packages/examples/appdocker/public/indexProxy.html +346 -0
- package/packages/examples/appdocker/public/indextest.html +316 -0
- package/packages/examples/appdocker/public/logon.html +44 -0
- package/packages/examples/appdocker/public/myapp/secondary.html +1 -0
- package/packages/examples/appdocker/public/myapp/test.js +2 -0
- package/packages/examples/appdocker/startup.sh +15 -0
- package/packages/examples/apptest/.env +28 -0
- package/packages/examples/apptest/.envProxy +22 -0
- package/packages/examples/apptest/.envimpl +12 -0
- package/packages/examples/apptest/.eslintrc.json +42 -0
- package/packages/examples/apptest/Dockerfile +44 -0
- package/packages/examples/apptest/appDir/app1/design.html +350 -0
- package/packages/examples/apptest/appDir/app1/index.html +353 -0
- package/packages/examples/apptest/appDir/index.html +350 -0
- package/packages/examples/apptest/appenv.js +6 -0
- package/packages/examples/apptest/docker-compose.yml +12 -0
- package/packages/examples/apptest/index.js +444 -0
- package/packages/examples/apptest/package.json +24 -0
- package/packages/examples/apptest/public/casread2.html +321 -0
- package/packages/examples/apptest/public/data/Cluster_SDOH1.sas +182 -0
- package/packages/examples/apptest/public/data/Cluster_SDOH6.sas +180 -0
- package/packages/examples/apptest/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/apptest/public/data/NeuralNetwork_High_med.sas +2409 -0
- package/packages/examples/apptest/public/data/NeuralNetwork_high_med1.sas +2409 -0
- 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 +429 -0
- package/packages/examples/apptest/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/apptest/public/data/cmdList.txt +15 -0
- package/packages/examples/apptest/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/apptest/public/data/iris.csv +151 -0
- package/packages/examples/apptest/public/data/model1.sas7bdat +0 -0
- package/packages/examples/apptest/public/design.html +349 -0
- package/packages/examples/apptest/public/favicon.ico +0 -0
- package/packages/examples/apptest/public/help.html +1 -0
- package/packages/examples/apptest/public/index.html +353 -0
- package/packages/examples/apptest/public/index2.html +353 -0
- package/packages/examples/apptest/public/indexProxy.html +346 -0
- package/packages/examples/apptest/public/indextest.html +316 -0
- package/packages/examples/apptest/public/logon.html +44 -0
- package/packages/examples/apptest/public/myapp/q.html +349 -0
- package/packages/examples/apptest/public/myapp/secondary.html +1 -0
- package/packages/examples/apptest/public/myapp/test.js +2 -0
- package/packages/examples/apptest/public/push1.html +187 -0
- package/packages/examples/apptest/startup.sh +15 -0
- package/packages/examples/apptesti/.env +13 -0
- package/packages/examples/apptesti/.eslintrc.json +42 -0
- package/packages/examples/apptesti/Dockerfile +42 -0
- package/packages/examples/apptesti/appenv.js +6 -0
- package/packages/examples/apptesti/certs/ca.crt +19 -0
- package/packages/examples/apptesti/certs/tls.crt +25 -0
- package/packages/examples/apptesti/certs/tls.key +28 -0
- package/packages/examples/apptesti/certs/tls.sh +5 -0
- package/packages/examples/apptesti/docker-compose.yml +12 -0
- package/{lib/cli.js → packages/examples/apptesti/index.js} +4 -6
- package/packages/examples/apptesti/package.json +20 -0
- package/packages/examples/apptesti/public/data/Cluster_SDOH1.sas +182 -0
- package/packages/examples/apptesti/public/data/Cluster_SDOH6.sas +180 -0
- package/packages/examples/apptesti/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/apptesti/public/data/NeuralNetwork_High_med.sas +2409 -0
- package/packages/examples/apptesti/public/data/NeuralNetwork_high_med1.sas +2409 -0
- 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 +429 -0
- package/packages/examples/apptesti/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/apptesti/public/data/cmdList.txt +15 -0
- package/packages/examples/apptesti/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/apptesti/public/data/iris.csv +151 -0
- 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 +346 -0
- package/packages/examples/apptesti/public/indexProxy.html +346 -0
- package/packages/examples/apptesti/public/indextest.html +316 -0
- package/packages/examples/apptesti/public/logon.html +44 -0
- package/packages/examples/apptesti/public/main.html +346 -0
- package/packages/examples/apptesti/public/myapp/secondary.html +1 -0
- package/packages/examples/apptesti/public/myapp/test.js +2 -0
- package/packages/examples/apptesti/startup.sh +15 -0
- package/packages/examples/basic/.env +10 -0
- package/packages/examples/basic/.eslintrc.json +42 -0
- package/packages/examples/basic/Dockerfile +41 -0
- package/packages/examples/basic/api.js +88 -0
- package/packages/examples/basic/appenv.js +6 -0
- package/packages/examples/basic/docker-compose.yml +10 -0
- package/packages/examples/basic/package.json +19 -0
- package/packages/examples/basic/public/data/Cluster_SDOH1.sas +182 -0
- package/packages/examples/basic/public/data/Cluster_SDOH6.sas +180 -0
- package/packages/examples/basic/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/basic/public/data/NeuralNetwork_High_med.sas +2409 -0
- package/packages/examples/basic/public/data/NeuralNetwork_high_med1.sas +2409 -0
- 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 +429 -0
- package/packages/examples/basic/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/basic/public/data/cmdList.txt +15 -0
- package/packages/examples/basic/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/basic/public/data/iris.csv +151 -0
- 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 +29 -0
- package/packages/examples/basic/public/index2.html +102 -0
- package/packages/examples/basic/public/logon.html +42 -0
- package/packages/examples/basic/public/myapp/secondary.html +1 -0
- package/packages/examples/basic/public/myapp/test.js +2 -0
- package/packages/examples/basic/public/onlogoff.html +53 -0
- package/packages/examples/basic/start.sh +15 -0
- package/packages/examples/proxytest/.env +23 -0
- package/packages/examples/proxytest/.envimpl +11 -0
- package/packages/examples/proxytest/.eslintrc.json +42 -0
- package/packages/examples/proxytest/Dockerfile +42 -0
- package/packages/examples/proxytest/appenv.js +6 -0
- package/packages/examples/proxytest/docker-compose.yml +12 -0
- package/packages/examples/proxytest/index.js +57 -0
- package/packages/examples/proxytest/package.json +18 -0
- package/packages/examples/proxytest/public/data/Cluster_SDOH1.sas +182 -0
- package/packages/examples/proxytest/public/data/Cluster_SDOH6.sas +180 -0
- package/packages/examples/proxytest/public/data/LeNet_snzrle.astore +0 -0
- package/packages/examples/proxytest/public/data/NeuralNetwork_High_med.sas +2409 -0
- package/packages/examples/proxytest/public/data/NeuralNetwork_high_med1.sas +2409 -0
- 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 +429 -0
- package/packages/examples/proxytest/public/data/cluster_test2.sas7bdat +0 -0
- package/packages/examples/proxytest/public/data/cmdList.txt +15 -0
- package/packages/examples/proxytest/public/data/gradBoost.sashdat +0 -0
- package/packages/examples/proxytest/public/data/iris.csv +151 -0
- 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 +357 -0
- package/packages/examples/proxytest/public/index.js +57 -0
- package/packages/examples/proxytest/public/indextest.html +316 -0
- package/packages/examples/proxytest/public/logon.html +44 -0
- package/packages/examples/proxytest/public/main.html +357 -0
- package/packages/examples/proxytest/public/myapp/secondary.html +1 -0
- package/packages/examples/proxytest/public/myapp/test.js +2 -0
- package/packages/examples/proxytest/public/restaf.js +2461 -0
- package/packages/examples/proxytest/public/restaf.min.js +11 -0
- package/packages/examples/proxytest/public/sas/iris.txt +10 -0
- package/packages/examples/proxytest/startup.sh +15 -0
- package/public/casread2.html +321 -0
- package/public/data/Cluster_SDOH1.sas +182 -0
- package/public/data/Cluster_SDOH6.sas +180 -0
- package/public/data/LeNet_snzrle.astore +0 -0
- package/public/data/NeuralNetwork_High_med.sas +2409 -0
- package/public/data/NeuralNetwork_high_med1.sas +2409 -0
- package/public/data/ast/GBlocalcopy.sasast +0 -0
- package/public/data/ast/LeNet_snzrle.astore +0 -0
- package/public/data/ast/gb_IrisGB.sasast +0 -0
- package/public/data/ast/paysimsvdd.sasast +0 -0
- package/public/data/ast/svmlocalcopy.sasast +0 -0
- package/public/data/cars.csv +429 -0
- package/public/data/cluster_test2.sas7bdat +0 -0
- package/public/data/cmdList.txt +15 -0
- package/public/data/gradBoost.sashdat +0 -0
- package/public/data/iris.csv +151 -0
- package/public/data/model1.sas7bdat +0 -0
- package/public/design.html +350 -0
- package/public/display.html +354 -0
- package/public/favicon.ico +0 -0
- package/public/help.html +1 -0
- package/public/index.html +354 -0
- package/public/index2.html +353 -0
- package/public/indexProxy.html +350 -0
- package/public/indextest.html +316 -0
- package/public/logon.html +44 -0
- package/public/myapp/q.html +349 -0
- package/public/myapp/secondary.html +1 -0
- package/public/myapp/test.js +2 -0
- package/public/push1.html +187 -0
- package/server.js +474 -0
- package/src/config.js +90 -0
- package/src/handlers/appCallback.js +40 -0
- package/src/handlers/codeAuth.js +31 -0
- package/src/handlers/decodeJwt.js +11 -0
- package/src/handlers/favicon.js +24 -0
- package/src/handlers/getApp.js +52 -0
- package/src/handlers/getApp2.js +26 -0
- package/src/handlers/getUser.js +20 -0
- package/src/handlers/index.js +36 -0
- package/src/handlers/keepAlive.js +54 -0
- package/src/handlers/keepAlive2.js +13 -0
- package/src/handlers/logon.js +24 -0
- package/src/handlers/logout.js +43 -0
- package/src/handlers/proxyMapUri.js +53 -0
- package/src/handlers/proxyOnResponse.js +12 -0
- package/src/handlers/reactDev.js +30 -0
- package/src/handlers/setCookies.js +78 -0
- package/src/iService.js +369 -0
- package/src/index.js +249 -0
- package/src/parseDocker.js +32 -0
- package/src/plugins/SASauth.js +79 -0
- package/src/plugins/appCookie.js +49 -0
- package/src/plugins/setContext.js +34 -0
- package/src/plugins/setDefaultRoutes.js +260 -0
- package/src/plugins/setupAuth.js +48 -0
- package/src/plugins/setupUserRoutes.js +48 -0
- package/src/plugins/token.js +10 -0
- package/src/schemes/SASTokenScheme.js +43 -0
- package/src/visionIndex.html +24 -0
- package/start.sh +15 -0
- package/lib/core/handlers/appCallback.js +0 -51
- package/lib/core/handlers/codeAuth.js +0 -61
- package/lib/core/handlers/favicon.js +0 -45
- package/lib/core/handlers/getApp.js +0 -67
- package/lib/core/handlers/getApp2.js +0 -48
- package/lib/core/handlers/getUser.js +0 -49
- package/lib/core/handlers/keepAlive.js +0 -96
- package/lib/core/handlers/keepAlive2.js +0 -33
- package/lib/core/handlers/logon.js +0 -44
- package/lib/core/handlers/logout.js +0 -88
- package/lib/core/handlers/proxyOnResponse.js +0 -26
- package/lib/core/handlers/reactDev.js +0 -52
- package/lib/core/handlers/setCookies.js +0 -116
- package/lib/core/index.js +0 -195
- package/lib/core/plugins/SASauth.js +0 -100
- package/lib/core/plugins/appCookie.js +0 -98
- package/lib/core/plugins/setContext.js +0 -55
- package/lib/core/plugins/setDefaultRoutes.js +0 -239
- package/lib/core/plugins/setupAuth.js +0 -86
- package/lib/core/plugins/token.js +0 -31
- package/lib/core/schemes/SASTokenScheme.js +0 -71
- /package/lib/{core/parseDocker.js → parseDocker.js} +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
// console.log('SASAuth options', bellAuthOptions);
|
|
73
|
+
debug('belloptions', bellAuthOptions);
|
|
74
|
+
server.log('SASAuth',bellAuthOptions);
|
|
75
|
+
await server.register(bell);
|
|
76
|
+
server.auth.strategy('sas', 'bell', bellAuthOptions);
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
@@ -0,0 +1,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(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
|
+
validateFunc: async (req, session) => {
|
|
21
|
+
server.log('Cookie validateFunc', `path - ${req.path}`);
|
|
22
|
+
|
|
23
|
+
if (session == null) {
|
|
24
|
+
console.log('session is null');
|
|
25
|
+
return {valid: false};
|
|
26
|
+
}
|
|
27
|
+
let credentials = null;
|
|
28
|
+
let sid;
|
|
29
|
+
if (Array.isArray(session) === true && session.length > 0) {
|
|
30
|
+
sid = session[0].sid;
|
|
31
|
+
} else {
|
|
32
|
+
sid = session.sid;
|
|
33
|
+
}
|
|
34
|
+
if (sid != null) {
|
|
35
|
+
credentials = await req.server.app.cache.get(sid);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (credentials == null) {
|
|
39
|
+
return {valid: false};
|
|
40
|
+
}
|
|
41
|
+
server.log('Cookie validateFunc', sid);
|
|
42
|
+
return {valid: true, credentials: credentials};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
// console.log('cookie options', cookieOptions);
|
|
46
|
+
server.log('Cookie Options',cookieOptions);
|
|
47
|
+
server.auth.strategy('session', 'cookie', cookieOptions);
|
|
48
|
+
|
|
49
|
+
};
|
|
@@ -0,0 +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
|
+
}
|
|
34
|
+
export default setContext;
|
|
@@ -0,0 +1,260 @@
|
|
|
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 {
|
|
20
|
+
getApp,
|
|
21
|
+
getApp2,
|
|
22
|
+
appCallback,
|
|
23
|
+
favicon,
|
|
24
|
+
keepAlive,
|
|
25
|
+
keepAlive2,
|
|
26
|
+
logout,
|
|
27
|
+
logon,
|
|
28
|
+
setupUserRoutes,
|
|
29
|
+
reactDev,
|
|
30
|
+
proxyMapUri,
|
|
31
|
+
} from "../handlers";
|
|
32
|
+
let debug = require("debug")("routes");
|
|
33
|
+
module.exports = function setDefaultRoutes(server, options) {
|
|
34
|
+
debug("setDefaultRoutes");
|
|
35
|
+
let appName = "/" + options.appName;
|
|
36
|
+
let authDefault = false;
|
|
37
|
+
let authLogon = false;
|
|
38
|
+
if (options.authFlow === "server") {
|
|
39
|
+
authDefault =
|
|
40
|
+
options.serverMode === "app"
|
|
41
|
+
? false
|
|
42
|
+
: {
|
|
43
|
+
strategies: ["token", "session"],
|
|
44
|
+
mode: "required",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
authLogon = {
|
|
48
|
+
mode: "required",
|
|
49
|
+
strategy: "sas",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
let getAppb = getApp.bind(
|
|
53
|
+
null,
|
|
54
|
+
process.env.USETOKEN === "YES" ? options : null
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
console.log("Default strategy", authDefault);
|
|
58
|
+
console.log("Logon strategy", authLogon);
|
|
59
|
+
options.authDefault = authDefault;
|
|
60
|
+
options.authLogon = authLogon;
|
|
61
|
+
|
|
62
|
+
debug(options.userRouteTable);
|
|
63
|
+
let uTable =
|
|
64
|
+
options.userRouteTable !== null
|
|
65
|
+
? setupUserRoutes(options.userRouteTable, options)
|
|
66
|
+
: null;
|
|
67
|
+
|
|
68
|
+
let defaultTable = [
|
|
69
|
+
{
|
|
70
|
+
method: ["GET"],
|
|
71
|
+
path: `/health`,
|
|
72
|
+
options: {
|
|
73
|
+
auth: false,
|
|
74
|
+
handler: async (req, h) => {
|
|
75
|
+
return h.response({ x: 1 }).code(200);
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
{
|
|
81
|
+
method: ["GET"],
|
|
82
|
+
path: `${appName}/logon`,
|
|
83
|
+
options: {
|
|
84
|
+
auth: (options.authFlow === "server") ?
|
|
85
|
+
{ mode: "try", strategy: "sas" } : null,
|
|
86
|
+
//https://futurestud.io/tutorials/hapi-redirect-to-previous-page-after-login
|
|
87
|
+
// set auth to null on all protected routes
|
|
88
|
+
plugins: {
|
|
89
|
+
"hapi-auth-cookie": { redirectTo: false },
|
|
90
|
+
},
|
|
91
|
+
handler: logon,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
method: ["GET"],
|
|
96
|
+
path: `${appName}`,
|
|
97
|
+
|
|
98
|
+
options: {
|
|
99
|
+
auth: (process.env.USELOGON === 'YES') ? null : options.serverMode === "app" ? authLogon : authDefault,
|
|
100
|
+
handler: getAppb,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
{
|
|
105
|
+
method: ["GET"],
|
|
106
|
+
path: `${appName}/api`,
|
|
107
|
+
options: {
|
|
108
|
+
auth: authDefault,
|
|
109
|
+
handler: async (req, h) => {
|
|
110
|
+
return h.redirect(`${appName}/documentation`);
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
method: ["GET"],
|
|
116
|
+
path: `/develop`,
|
|
117
|
+
options: {
|
|
118
|
+
auth: false,
|
|
119
|
+
cors: true,
|
|
120
|
+
handler: reactDev,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
{
|
|
125
|
+
method: ["GET"],
|
|
126
|
+
path: `${appName}/callback`,
|
|
127
|
+
options: {
|
|
128
|
+
auth: authDefault,
|
|
129
|
+
handler: appCallback,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
method: ["GET"],
|
|
134
|
+
path: `${appName}/logout`,
|
|
135
|
+
options: {
|
|
136
|
+
auth: authDefault,
|
|
137
|
+
handler: logout,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
method: ["GET", "POST"],
|
|
142
|
+
path: `${appName}/keepAlive`,
|
|
143
|
+
|
|
144
|
+
options: {
|
|
145
|
+
auth: authDefault,
|
|
146
|
+
handler: keepAlive,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
method: ["GET"],
|
|
151
|
+
path: `${appName}/appenv`,
|
|
152
|
+
options: {
|
|
153
|
+
auth: /*authDefault*/ false,
|
|
154
|
+
handler: (req, h) => {
|
|
155
|
+
let allAppEnv = options.allAppEnv;
|
|
156
|
+
if (options.userInfo != null) {
|
|
157
|
+
let uappenv = options.userInfo("APPENV", options);
|
|
158
|
+
if (uappenv != null) {
|
|
159
|
+
allAppEnv.APPENV = { ...allAppEnv.APPENV, ...uappenv };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
allAppEnv.credentials = options.credentials;
|
|
163
|
+
|
|
164
|
+
let s =
|
|
165
|
+
`let LOGONPAYLOAD = ${JSON.stringify(allAppEnv.LOGONPAYLOAD)};` +
|
|
166
|
+
`let APPENV = ${JSON.stringify(allAppEnv.APPENV)};`;
|
|
167
|
+
if (process.env.SHOWENV != null) {
|
|
168
|
+
console.log(s);
|
|
169
|
+
}
|
|
170
|
+
debug(s);
|
|
171
|
+
return s;
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
method: ["GET"],
|
|
177
|
+
path: `/appenv`,
|
|
178
|
+
options: {
|
|
179
|
+
auth: /*authDefault*/ false,
|
|
180
|
+
handler: (req, h) => {
|
|
181
|
+
let allAppEnv = options.allAppEnv;
|
|
182
|
+
if (options.userInfo != null) {
|
|
183
|
+
let uappenv = options.userInfo("APPENV", options);
|
|
184
|
+
if (uappenv != null) {
|
|
185
|
+
allAppEnv.APPENV = { ...allAppEnv.APPENV, ...uappenv };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
allAppEnv.credentials = options.credentials;
|
|
189
|
+
|
|
190
|
+
let s =
|
|
191
|
+
`let LOGONPAYLOAD = ${JSON.stringify(allAppEnv.LOGONPAYLOAD)};` +
|
|
192
|
+
`let APPENV = ${JSON.stringify(allAppEnv.APPENV)};`;
|
|
193
|
+
if (process.env.SHOWENV != null) {
|
|
194
|
+
debug(options.allAppEnv);
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
debug(s)
|
|
198
|
+
return s;
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
/*
|
|
203
|
+
{
|
|
204
|
+
method: ["GET"],
|
|
205
|
+
path: `${appName}/{param*}`,
|
|
206
|
+
|
|
207
|
+
options: {
|
|
208
|
+
auth: authDefault,
|
|
209
|
+
handler: getApp2,
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
{
|
|
215
|
+
method: ["GET"],
|
|
216
|
+
path: `/{param*}`,
|
|
217
|
+
|
|
218
|
+
options: {
|
|
219
|
+
auth: authDefault,
|
|
220
|
+
handler: getApp2,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
method: ["GET"],
|
|
225
|
+
path: `/favicon.ico`,
|
|
226
|
+
options: {
|
|
227
|
+
auth: false,
|
|
228
|
+
handler: favicon,
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
method: ["GET", "POST"],
|
|
233
|
+
path: `${appName}/keepAlive2`,
|
|
234
|
+
options: {
|
|
235
|
+
auth: authDefault,
|
|
236
|
+
handler: keepAlive2,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
let pr = {
|
|
242
|
+
method: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
|
|
243
|
+
path: `${appName}/proxy/{param*}`,
|
|
244
|
+
options: {
|
|
245
|
+
handler: {
|
|
246
|
+
proxy: {
|
|
247
|
+
mapUri: proxyMapUri,
|
|
248
|
+
xforward: true,
|
|
249
|
+
passThrough: true,
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
debug(pr);
|
|
255
|
+
defaultTable.push(pr);
|
|
256
|
+
|
|
257
|
+
let routeTables =
|
|
258
|
+
uTable !== null ? defaultTable.concat(uTable) : defaultTable;
|
|
259
|
+
server.route(routeTables);
|
|
260
|
+
};
|
|
@@ -0,0 +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
|
+
|
|
19
|
+
let SASauth = require('./SASauth');
|
|
20
|
+
let appCookie = require('./appCookie');
|
|
21
|
+
let token = require('./token');
|
|
22
|
+
let setDefaultRoutes = require('./setDefaultRoutes');
|
|
23
|
+
|
|
24
|
+
/** Notes:
|
|
25
|
+
* If api then register sasAuth and token - no cookies
|
|
26
|
+
* If app, then register sasAuth and cookie(session) but no token
|
|
27
|
+
*/
|
|
28
|
+
async function setupAuth (server, options){
|
|
29
|
+
|
|
30
|
+
if (options.authFlow === 'server') {
|
|
31
|
+
await server.register({plugin: SASauth, options: options});
|
|
32
|
+
// await server.register({plugin: appCookie, options: options});
|
|
33
|
+
await appCookie(server,options);
|
|
34
|
+
|
|
35
|
+
let def = 'session';
|
|
36
|
+
if (options.serverMode === 'api') {
|
|
37
|
+
await server.register({ plugin: token });
|
|
38
|
+
def = 'token';
|
|
39
|
+
}
|
|
40
|
+
server.log('***********************Default auth', def);
|
|
41
|
+
server.auth.default(def);
|
|
42
|
+
// console.log(server.registerations);
|
|
43
|
+
}
|
|
44
|
+
setDefaultRoutes(server, options);
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default setupAuth;
|
|
@@ -0,0 +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
|
+
}
|
|
48
|
+
export default setupUserRoutes;
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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>
|
|
24
|
+
</html>
|
package/start.sh
ADDED
|
@@ -0,0 +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
|
|
15
|
+
node server.js
|
|
@@ -1,51 +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
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = void 0;
|
|
11
|
-
var _codeAuth = _interopRequireDefault(require("./codeAuth"));
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
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); }
|
|
14
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
15
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
16
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
|
-
// handle all callback
|
|
18
|
-
var debug = require("debug")("callback");
|
|
19
|
-
debugger;
|
|
20
|
-
function appCallback(_x, _x2) {
|
|
21
|
-
return _appCallback.apply(this, arguments);
|
|
22
|
-
}
|
|
23
|
-
function _appCallback() {
|
|
24
|
-
_appCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, h) {
|
|
25
|
-
var indexHTML;
|
|
26
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
27
|
-
while (1) switch (_context.prev = _context.next) {
|
|
28
|
-
case 0:
|
|
29
|
-
debug("in callback");
|
|
30
|
-
debug("AUTHFLOW: ".concat(process.env.AUTHFLOW));
|
|
31
|
-
if (!(process.env.AUTHFLOW === "server")) {
|
|
32
|
-
_context.next = 6;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
return _context.abrupt("return", (0, _codeAuth["default"])(req, h));
|
|
36
|
-
case 6:
|
|
37
|
-
indexHTML = "index.html";
|
|
38
|
-
if (process.entry != null) {
|
|
39
|
-
indexHTML = process.entry.REDIRECT_ENTRY != null ? process.entry.REDIRECT_ENTRY : process.env.APPENTRY == null ? "index.html" : process.env.APPENTRY;
|
|
40
|
-
}
|
|
41
|
-
console.log("Redirecting to default ".concat(indexHTML));
|
|
42
|
-
return _context.abrupt("return", h.file("".concat(indexHTML)));
|
|
43
|
-
case 10:
|
|
44
|
-
case "end":
|
|
45
|
-
return _context.stop();
|
|
46
|
-
}
|
|
47
|
-
}, _callee);
|
|
48
|
-
}));
|
|
49
|
-
return _appCallback.apply(this, arguments);
|
|
50
|
-
}
|
|
51
|
-
var _default = exports["default"] = appCallback;
|