1
0
personal-data/personal_data/secrets.py

46 lines
1.2 KiB
Python

import logging
import os
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
ENV_KEY_PREFIX = 'CF_PD_'
def load_secret(env_key: str) -> str:
filepath = os.environ.get(ENV_KEY_PREFIX + env_key)
if filepath is None:
filepath = f'./secrets/{env_key.lower()}'
try:
with open(filepath) as f:
value = f.read().strip()
logger.info('Loaded secret: %s', env_key)
return value
except Exception:
logger.exception('Could not load secret %s', env_key)
return None
# Crunchyroll
CRUNCHYROLL_DEVICE_ID = load_secret('CRUNCHYROLL_DEVICE_ID')
CRUNCHYROLL_AUTH = load_secret('CRUNCHYROLL_AUTH')
# FFXIV
FFXIV_CHARACTER_ID = load_secret('FFXIV_CHARACTER_ID')
# Playstation
PLAYSTATION_PSN_ID = load_secret('PLAYSTATION_PSN_ID')
# Partisia Blockchain
PBC_ACCOUNT_ADDRESS = load_secret('PBC_ACCOUNT_ADDRESS')
# Kucoin
KUCOIN_KEY = load_secret('KUCOIN_KEY')
KUCOIN_SECRET = load_secret('KUCOIN_SECRET')
KUCOIN_PASS = load_secret('KUCOIN_PASS')
# Email configuration
MAILGUN_API_KEY = load_secret('MAILGUN_API_KEY')
MAILGUN_DOMAIN = load_secret('MAILGUN_DOMAIN')
MAILGUN_RECIPIENT = load_secret('MAILGUN_RECIPIENT')