Randomize charge api token's getenv fallback value

If the env var is not defined, fall back to a random string. However,
note the random string won't work over gunicorn if using multiple
workers. In this case, it is necessary to define the env var.
This commit is contained in:
Blockstream Satellite 2021-07-20 13:25:06 -03:00
parent 608e61692a
commit 69b97e9eae
3 changed files with 4 additions and 1 deletions

View file

@ -15,6 +15,7 @@ services:
environment:
- CHARGE_ROOT=http://api-token:mySecretToken@blc:9112
- CALLBACK_URI_ROOT=http://localhost:9292
- CHARGE_API_TOKEN=mySecretToken
- ENV=development
- REDIS_URI=redis://redis:6379
volumes:

View file

@ -1,4 +1,5 @@
import os
import uuid
import yaml
from enum import Enum
@ -83,7 +84,7 @@ MESSAGE_FILE_RETENTION_TIME_DAYS = 31
SERVER_PORT = 9292
CALLBACK_URI_ROOT = os.getenv('CALLBACK_URI_ROOT',
"http://localhost:{}".format(SERVER_PORT))
CHARGE_API_TOKEN = os.getenv('CHARGE_API_TOKEN', 'mySecretToken')
CHARGE_API_TOKEN = os.getenv('CHARGE_API_TOKEN', str(uuid.uuid4()))
LIGHTNING_WEBHOOK_KEY = hmac_sha256_digest('charged-token', CHARGE_API_TOKEN)
CHARGE_ROOT = os.getenv('CHARGE_ROOT',

View file

@ -237,6 +237,7 @@ write_files:
-e "ENV=production" \
-e "CHARGE_ROOT=http://api-token:${charge_token}@localhost:9112" \
-e "CALLBACK_URI_ROOT=http://localhost:9292" \
-e "CHARGE_API_TOKEN=${charge_token}" \
-e "MIN_PER_BYTE_BID=1" \
-e "REDIS_URI=redis://localhost:6379" \
"${ionosphere_docker}"