@sassoftware/viya-serverjs 0.1.1 → 0.2.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 -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} +5 -24
- package/lib/handlers/appCallback.js +62 -0
- package/lib/handlers/codeAuth.js +61 -0
- package/lib/{core/handlers → handlers}/decodeJwt.js +2 -2
- 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 +2 -2
- package/lib/handlers/keepAlive.js +99 -0
- package/lib/handlers/keepAlive2.js +33 -0
- package/lib/handlers/logon.js +44 -0
- package/lib/handlers/logout.js +88 -0
- package/lib/handlers/proxyMapUri.js +78 -0
- package/lib/handlers/proxyOnResponse.js +26 -0
- package/lib/handlers/reactDev.js +52 -0
- package/lib/handlers/setCookies.js +110 -0
- package/lib/{core/iService.js → iService.js} +45 -30
- package/lib/index.js +177 -10
- package/lib/{core/parseDocker.js → parseDocker.js} +1 -1
- package/lib/plugins/SASauth.js +101 -0
- package/lib/plugins/appCookie.js +99 -0
- package/lib/plugins/setContext.js +56 -0
- package/lib/{core/plugins → plugins}/setDefaultRoutes.js +67 -58
- 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 +54 -10
- 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 -5
- 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 +444 -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 +56 -0
- package/src/handlers/proxyOnResponse.js +12 -0
- package/src/handlers/reactDev.js +30 -0
- package/src/handlers/setCookies.js +76 -0
- package/src/iService.js +369 -0
- package/src/index.js +243 -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 +262 -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/setupAuth.js +0 -86
- package/lib/core/plugins/token.js +0 -31
- package/lib/core/schemes/SASTokenScheme.js +0 -71
|
@@ -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,262 @@
|
|
|
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(options.allAppEnv);
|
|
169
|
+
console.log(s);
|
|
170
|
+
}
|
|
171
|
+
debug(s);
|
|
172
|
+
return s;
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
method: ["GET"],
|
|
178
|
+
path: `/appenv`,
|
|
179
|
+
options: {
|
|
180
|
+
auth: /*authDefault*/ false,
|
|
181
|
+
handler: (req, h) => {
|
|
182
|
+
let allAppEnv = options.allAppEnv;
|
|
183
|
+
if (options.userInfo != null) {
|
|
184
|
+
let uappenv = options.userInfo("APPENV", options);
|
|
185
|
+
if (uappenv != null) {
|
|
186
|
+
allAppEnv.APPENV = { ...allAppEnv.APPENV, ...uappenv };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
allAppEnv.credentials = options.credentials;
|
|
190
|
+
|
|
191
|
+
let s =
|
|
192
|
+
`let LOGONPAYLOAD = ${JSON.stringify(allAppEnv.LOGONPAYLOAD)};` +
|
|
193
|
+
`let APPENV = ${JSON.stringify(allAppEnv.APPENV)};`;
|
|
194
|
+
if (process.env.SHOWENV != null) {
|
|
195
|
+
console.log(options.allAppEnv);
|
|
196
|
+
console.log(s);
|
|
197
|
+
}
|
|
198
|
+
debug(s)
|
|
199
|
+
return s;
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
{
|
|
205
|
+
method: ["GET"],
|
|
206
|
+
path: `${appName}/{param*}`,
|
|
207
|
+
|
|
208
|
+
options: {
|
|
209
|
+
auth: authDefault,
|
|
210
|
+
handler: getApp2,
|
|
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
|
+
if (process.env.PROXYSERVER != null) {
|
|
242
|
+
let pr = {
|
|
243
|
+
method: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
|
|
244
|
+
path: `${appName}/proxy/{param*}`,
|
|
245
|
+
options: {
|
|
246
|
+
handler: {
|
|
247
|
+
proxy: {
|
|
248
|
+
mapUri: proxyMapUri,
|
|
249
|
+
xforward: true,
|
|
250
|
+
passThrough: true,
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
console.log(pr);
|
|
256
|
+
defaultTable.push(pr);
|
|
257
|
+
}
|
|
258
|
+
console.log(uTable);
|
|
259
|
+
let routeTables =
|
|
260
|
+
uTable !== null ? defaultTable.concat(uTable) : defaultTable;
|
|
261
|
+
server.route(routeTables);
|
|
262
|
+
};
|
|
@@ -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
|