1
0
personal-data/personal_data/secrets.py

41 lines
1.0 KiB
Python
Raw Normal View History

2024-04-16 22:38:57 +00:00
import logging
import os
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
2024-04-17 21:54:05 +00:00
ENV_KEY_PREFIX = 'CF_PD_'
2024-04-16 22:38:57 +00:00
2024-04-23 20:58:25 +00:00
2024-04-16 22:38:57 +00:00
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
2024-04-23 20:58:25 +00:00
CRUNCHYROLL_DEVICE_ID = load_secret('CRUNCHYROLL_DEVICE_ID')
CRUNCHYROLL_AUTH = load_secret('CRUNCHYROLL_AUTH')
2024-04-16 22:38:57 +00:00
# FFXIV
FFXIV_CHARACTER_ID = load_secret('FFXIV_CHARACTER_ID')
2024-04-28 22:01:11 +00:00
# Playstation
PLAYSTATION_PSN_ID = load_secret('PLAYSTATION_PSN_ID')
2024-04-16 22:48:21 +00:00
# Partisia Blockchain
PBC_ACCOUNT_ADDRESS = load_secret('PBC_ACCOUNT_ADDRESS')
2024-04-16 22:38:57 +00:00
# Email configuration
MAILGUN_API_KEY = load_secret('MAILGUN_API_KEY')
MAILGUN_DOMAIN = load_secret('MAILGUN_DOMAIN')
MAILGUN_RECIPIENT = load_secret('MAILGUN_RECIPIENT')