Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,23 @@ Please use a config file instead. This will give you more control over each envi
The defaults can be found in [config](./src/config/index.ts). Place your config files in `runner/config`
See [https://github.com/node-config/node-config#readme](https://github.com/node-config/node-config#readme) for more info.

| name | description | required | default | valid | notes |
| --------------------- | -------------------------------------------------------------------------------- | :------: | ------- | :-------------------------: | :---------------------------------------------------------------------------------------------------------------------: |
| NODE_ENV | Node environment | no | | development,test,production | |
| PORT | Port number | no | 3009 | | |
| NOTIFY_TEMPLATE_ID | Notify api key | yes | | | Template ID required to send form payloads via [GOV.UK Notify](https://www.notifications.service.gov.uk) email service. |
| NOTIFY_API_KEY | Notify api key | yes | | | API KEY required to send form payloads via [GOV.UK Notify](https://www.notifications.service.gov.uk) email service. |
| LOG_LEVEL | Log level | no | debug | trace,debug,info,error | |
| PHASE_TAG | Tag to use for phase banner | no | beta | alpha, beta, empty string | |
| HTTP_PROXY | HTTP proxy to use, e.g. the one from CDP. Currently used for Hapi Wreck. | no | | | |
| HTTPS_PROXY | HTTPS proxy to use, e.g. the one from CDP. Currently used for Hapi Wreck. | no | | | |
| NO_PROXY | HTTP proxy to use, e.g. the one from CDP. Currently used for Hapi Wreck. | no | | | |
| AWS_ACCESS_KEY_ID | AWS key id | yes | dummy | | |
| AWS_SECRET_ACCESS_KEY | AWS access key | yes | dummy | | |
| SNS_ENDPOINT | Endpoint for SNS messaging | yes | | | |
| SNS_ADAPTER_TOPIC_ARN | The SNS topic for the submission adapter - in Amazon Resource Name (ARN) format. | yes | | | |
| SNS_SAVE_TOPIC_ARN | The SNS topic for the save-and-exit - in Amazon Resource Name (ARN) format. | yes | | | |
| name | description | required | default | valid | notes |
| ----------------------- | ----------------------------------------------------------------------------------------------------- | :------: | ------- | :-------------------------: | :---------------------------------------------------------------------------------------------------------------------: |
| NODE_ENV | Node environment | no | | development,test,production | |
| PORT | Port number | no | 3009 | | |
| NOTIFY_TEMPLATE_ID | Notify api key | yes | | | Template ID required to send form payloads via [GOV.UK Notify](https://www.notifications.service.gov.uk) email service. |
| NOTIFY_API_KEY | Notify api key | yes | | | API KEY required to send form payloads via [GOV.UK Notify](https://www.notifications.service.gov.uk) email service. |
| LOG_LEVEL | Log level | no | debug | trace,debug,info,error | |
| PHASE_TAG | Tag to use for phase banner | no | beta | alpha, beta, empty string | |
| HTTP_PROXY | HTTP proxy to use, e.g. the one from CDP. Currently used for Hapi Wreck. | no | | | |
| HTTPS_PROXY | HTTPS proxy to use, e.g. the one from CDP. Currently used for Hapi Wreck. | no | | | |
| NO_PROXY | HTTP proxy to use, e.g. the one from CDP. Currently used for Hapi Wreck. | no | | | |
| AWS_ACCESS_KEY_ID | AWS key id | yes | dummy | | |
| AWS_SECRET_ACCESS_KEY | AWS access key | yes | dummy | | |
| SNS_ENDPOINT | Endpoint for SNS messaging | yes | | | |
| SNS_ADAPTER_TOPIC_ARN | The SNS topic for the submission adapter - in Amazon Resource Name (ARN) format. | yes | | | |
| SNS_SAVE_TOPIC_ARN | The SNS topic for the save-and-exit - in Amazon Resource Name (ARN) format. | yes | | | |
| PRIVATE_KEY_FOR_SECRETS | Base64-encoded private key (paired witht he public key from forms-manager) for decryption of secrets. | yes | | | |

For proxy options, see https://www.npmjs.com/package/proxy-from-env which is used by https://github.com/TooTallNate/proxy-agents/tree/main/packages/proxy-agent.

Expand All @@ -216,6 +217,7 @@ USE_SINGLE_INSTANCE_CACHE=true
SNS_ENDPOINT="http://localhost:4566"
SNS_ADAPTER_TOPIC_ARN="arn:aws:sns:eu-west-2:000000000000:forms_runner_submission_events"
SNS_SAVE_TOPIC_ARN="arn:aws:sns:eu-west-2:000000000000:forms_runner_events"
PRIVATE_KEY_FOR_SECRETS="<base64-encoded-private-key>"
```

# Testing
Expand Down
5 changes: 3 additions & 2 deletions src/server/services/helpers/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { config } from '~/src/config/index.js'
* @returns {string} base64-encoded result
*/
export function decryptSecret(secretValue) {
const privateKey = config.get('privateKeyForSecrets')
if (!privateKey) {
const privateKeyEncoded = config.get('privateKeyForSecrets')
if (!privateKeyEncoded) {
throw new Error('Private key is missing')
}
const privateKey = Buffer.from(privateKeyEncoded, 'base64').toString()
const buffer = Buffer.from(secretValue, 'base64')
const decrypted = crypto.privateDecrypt(privateKey, buffer)
return decrypted.toString()
Expand Down
Loading