From e1b9df132a6ca46cd4be102ed6f26e8a0d76dbef Mon Sep 17 00:00:00 2001 From: Karl Andin Date: Thu, 16 May 2024 18:29:15 +0200 Subject: [PATCH 1/2] feat(KUI-1323): cleanup local env setup --- .env.in | 22 +++-------------- README.md | 53 +--------------------------------------- config/serverSettings.js | 6 ++--- 3 files changed, 8 insertions(+), 73 deletions(-) diff --git a/.env.in b/.env.in index 5711740c..fd54ca96 100644 --- a/.env.in +++ b/.env.in @@ -1,19 +1,5 @@ -# If KURS_PM_DATA_API_URI is omitted, http://localhost:3001/api/kurs-pm-data?defaultTimeout=10000 will be used -KURS_PM_DATA_API_URI=https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000 -# If KURS_PM_DATA_API_KEY is omitted, default key 1234 will be used -KURS_PM_DATA_API_KEY=[key] +KURS_PM_DATA_API_KEY=[Available in Azure KeyVault] +KURS_INFO_API_KEY=[Available in Azure KeyVault] +KURSPLAN_API_KEY=[Available in Azure KeyVault] -# If KURS_INFO_API_URI is omitted, http://localhost:3002/api/kursinfo?defaultTimeout=10000 will be used -KURS_INFO_API_URI=https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000 -# If KURS_INFO_API_KEY is omitted, default key 1234 will be used -KURS_INFO_API_KEY=[key] - -# If KURSPLAN_API_URI is omitted, http://localhost:3003/api/kursplan?defaultTimeout=10000 will be used -KURSPLAN_API_URI=https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000 -# If KURSPLAN_API_KEY is omitted, default key 5678 will be used -KURSPLAN_API_KEY=[key] - -# If KOPPS_URI is omitted, https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=10000 will be used - -SESSION_SECRET=[secret] -SESSION_KEY=[key] +REDIS_URI=[Available in Azure KeyVault] \ No newline at end of file diff --git a/README.md b/README.md index 15e29dec..45584074 100644 --- a/README.md +++ b/README.md @@ -39,33 +39,7 @@ Kurs-pm-web fetches data from: ### Secrets for Development -Secrets during local development are stored in a `.env` file in the root of your project. This file should be in `.gitignore`. - -Secrets (names, passwords, keys, and uri:s) for dev and prod are stored in the the course information project’s Azure key vault. - -```sh -# If KURS_PM_DATA_API_URI is omitted, http://localhost:3001/api/kurs-pm-data?defaultTimeout=10000 will be used -KURS_PM_DATA_API_URI=https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000 -# If KURS_PM_DATA_API_KEY is omitted, default key 1234 will be used -KURS_PM_DATA_API_KEY=[key] - -# If KURS_INFO_API_URI is omitted, http://localhost:3002/api/kursinfo?defaultTimeout=10000 will be used -KURS_INFO_API_URI=https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000 -# If KURS_INFO_API_KEY is omitted, default key 1234 will be used -KURS_INFO_API_KEY=[key] - -# If KURSPLAN_API_URI is omitted, http://localhost:3003/api/kursplan?defaultTimeout=10000 will be used -KURSPLAN_API_URI=https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000 -# If KURSPLAN_API_KEY is omitted, default key 5678 will be used -KURSPLAN_API_KEY=[key] - -# If KOPPS_URI is omitted, https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=10000 will be used - -SESSION_SECRET=[secret] -SESSION_KEY=[key] -``` - -These settings are also available in the `env.in` file. +Secrets during local development are stored in a gitignored `.env` file (`env.in` can be used as template for your `.env` file). More details about environment variable setup and secrets can be found in [confluence](https://confluence.sys.kth.se/confluence/x/OYKBDQ). ## For Development @@ -172,31 +146,6 @@ docker-compose up The deployment process is described in [Om kursen: Release till produktion](https://confluence.sys.kth.se/confluence/x/xIjCCg). -### Edit secrets.env - -```sh -ansible-vault edit secrets.env -``` - -### Configure secrets.env - -Secrets (names, passwords, keys, and uri:s) for dev and prod are stored in the the course information project’s Azure key vault. - -```sh -KURS_PM_DATA_API_URI=localhost:portNumber/api/kurs-pm-data?defaultTimeout=10000 -KURS_PM_DATA_API_KEY=[key] - -KURS_INFO_API_URI=localhost:portNumber/api/kursinfo?defaultTimeout=10000 -KURS_INFO_API_KEY=[key] - -# If KOPPS_URI is omitted, pathToKopps/api/kopps/v2/?defaultTimeout=10000 will be used - -SESSION_SECRET=[secret] -SESSION_KEY=[key] -APPLICATIONINSIGHTS_CONNECTION_STRING=[connection string] -REDIS_URI=[uri] -``` - ## Pre-\*\*-git-hooks We use `husky` to run [pre-commit](/.husky/pre-commit) and [pre-push](/.husky/pre-push) hooks and `lint-staged` to run eslint and prettier. diff --git a/config/serverSettings.js b/config/serverSettings.js index 03625305..84bf3cca 100644 --- a/config/serverSettings.js +++ b/config/serverSettings.js @@ -19,9 +19,9 @@ const { const devPort = devDefaults(3000) const devSsl = devDefaults(false) const devUrl = devDefaults('http://localhost:' + devPort) -const devKursPmDataApi = devDefaults('http://localhost:3001/api/kurs-pm-data?defaultTimeout=10000') -const devKursInfoApi = devDefaults('http://localhost:3002/api/kursinfo?defaultTimeout=10000') -const devKursplanApi = devDefaults('http://localhost:3003/api/kursplan?defaultTimeout=10000') +const devKursPmDataApi = devDefaults('https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000') +const devKursInfoApi = devDefaults('https://api-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000') +const devKursplanApi = devDefaults('https://api-r.referens.sys.kth.se/api/kursplan?defaultTimeout=10000') const devKoppsApi = devDefaults('https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=10000') const devSessionKey = devDefaults('kurs-pm-web.sid') const devSessionUseRedis = devDefaults(true) From 0cd4d81bdec987db16cedf43ad9a697501fa082c Mon Sep 17 00:00:00 2001 From: Karl Andin Date: Fri, 17 May 2024 15:26:25 +0200 Subject: [PATCH 2/2] feat(KUI-1323): rename env variable KURS_INFO_API_... to KURSINFO_API_... --- .azure/prod.parameters.json | 4 ++-- .azure/ref.parameters.json | 4 ++-- .env.in | 2 +- config/serverSettings.js | 4 ++-- docker-compose-integration-tests-old.yml | 4 ++-- docker-compose-performance-tests.yml | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.azure/prod.parameters.json b/.azure/prod.parameters.json index 9c43209d..d4acb872 100644 --- a/.azure/prod.parameters.json +++ b/.azure/prod.parameters.json @@ -10,7 +10,7 @@ "APPLICATIONINSIGHTS_CONNECTION_STRING", "KURSPLAN_API_KEY", "KURSPLAN_API_URI", - "KURS_INFO_API_KEY", + "KURSINFO_API_KEY", "KURS_PM_DATA_API_KEY", "REDIS_URI", "SESSION_KEY", @@ -24,7 +24,7 @@ "CONSOLE_ENABLED": "false", "IMAGE_STORAGE_URI": "https://kursinfostorageprod.blob.core.windows.net/kursinfo-image-container/", "KOPPS_URI": "https://api.kth.se/api/kopps/v2/?defaultTimeout=60000", - "KURS_INFO_API_URI": "https://api.kth.se/api/kursinfo?defaultTimeout=10000", + "KURSINFO_API_URI": "https://api.kth.se/api/kursinfo?defaultTimeout=10000", "KURS_PM_DATA_API_URI": "https://api.kth.se/api/kurs-pm-data?defaultTimeout=10000", "LOGGING_ACCESS_LOG": "true", "LOGGING_LEVEL": "INFO", diff --git a/.azure/ref.parameters.json b/.azure/ref.parameters.json index bfdcb45d..cad6d6c4 100644 --- a/.azure/ref.parameters.json +++ b/.azure/ref.parameters.json @@ -10,7 +10,7 @@ "APPLICATIONINSIGHTS_CONNECTION_STRING", "KURSPLAN_API_KEY", "KURSPLAN_API_URI", - "KURS_INFO_API_KEY", + "KURSINFO_API_KEY", "KURS_PM_DATA_API_KEY", "REDIS_URI", "SESSION_KEY", @@ -24,7 +24,7 @@ "CONSOLE_LOG": "true", "IMAGE_STORAGE_URI": "https://kursinfostoragestage.blob.core.windows.net/kursinfo-image-container/", "KOPPS_URI": "https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=60000", - "KURS_INFO_API_URI": "https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000", + "KURSINFO_API_URI": "https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000", "KURS_PM_DATA_API_URI": "https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000", "LOGGING_ACCESS_LOG": "true", "LOGGING_LEVEL": "TRACE", diff --git a/.env.in b/.env.in index fd54ca96..091b630b 100644 --- a/.env.in +++ b/.env.in @@ -1,5 +1,5 @@ KURS_PM_DATA_API_KEY=[Available in Azure KeyVault] -KURS_INFO_API_KEY=[Available in Azure KeyVault] +KURSINFO_API_KEY=[Available in Azure KeyVault] KURSPLAN_API_KEY=[Available in Azure KeyVault] REDIS_URI=[Available in Azure KeyVault] \ No newline at end of file diff --git a/config/serverSettings.js b/config/serverSettings.js index 84bf3cca..0d504ea2 100644 --- a/config/serverSettings.js +++ b/config/serverSettings.js @@ -41,14 +41,14 @@ module.exports = { // API keys apiKey: { kursPmDataApi: getEnv('KURS_PM_DATA_API_KEY', devDefaults('1234')), - kursInfoApi: getEnv('KURS_INFO_API_KEY', devDefaults('1234')), + kursInfoApi: getEnv('KURSINFO_API_KEY', devDefaults('1234')), kursplanApi: getEnv('KURSPLAN_API_KEY', devDefaults('5678')), }, // Service API's nodeApi: { kursPmDataApi: unpackNodeApiConfig('KURS_PM_DATA_API_URI', devKursPmDataApi), - kursInfoApi: unpackNodeApiConfig('KURS_INFO_API_URI', devKursInfoApi), + kursInfoApi: unpackNodeApiConfig('KURSINFO_API_URI', devKursInfoApi), kursplanApi: unpackNodeApiConfig('KURSPLAN_API_URI', devKursplanApi), }, diff --git a/docker-compose-integration-tests-old.yml b/docker-compose-integration-tests-old.yml index 9e49b6fd..209da8cb 100644 --- a/docker-compose-integration-tests-old.yml +++ b/docker-compose-integration-tests-old.yml @@ -22,8 +22,8 @@ services: - LOGGING_ACCESS_LOG=true - KURS_PM_DATA_API_URI=http://mock-api:3000/kurs-pm - KURS_PM_DATA_API_KEY=secretpassword - - KURS_INFO_API_URI=http://mock-api:3000/kursinfo - - KURS_INFO_API_KEY=secretpassword + - KURSINFO_API_URI=http://mock-api:3000/kursinfo + - KURSINFO_API_KEY=secretpassword - KURSPLAN_API_URI=http://mock-api:3000/kursplan - KURSPLAN_API_KEY=secretpassword - REDIS_URI=redis://redis:6379 diff --git a/docker-compose-performance-tests.yml b/docker-compose-performance-tests.yml index d252a1e3..c31d03c8 100644 --- a/docker-compose-performance-tests.yml +++ b/docker-compose-performance-tests.yml @@ -25,8 +25,8 @@ services: LOGGING_ACCESS_LOG: 'false' KURS_PM_DATA_API_URI: 'http://mock-api:3000/kurs-pm' KURS_PM_DATA_API_KEY: 'secretpassword' - KURS_INFO_API_URI: 'http://mock-api:3000/kursinfo' - KURS_INFO_API_KEY: 'secretpassword' + KURSINFO_API_URI: 'http://mock-api:3000/kursinfo' + KURSINFO_API_KEY: 'secretpassword' KURSPLAN_API_URI: 'http://mock-api:3000/kursplan' KURSPLAN_API_KEY: 'secretpassword' REDIS_URI: 'redis://redis:6379'